blob: 602aa620d213fe6c3b1bc62ccb1114517b349196 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.customcontrols;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import javax.swing.Box;
import javax.swing.JSeparator;
import javax.swing.JToolBar;
import net.java.sip.communicator.impl.gui.lookandfeel.SIPCommToolBarSeparatorUI;
import net.java.sip.communicator.impl.gui.utils.ImageLoader;
/**
* The SIPCommToolBar is a <tt>JToolBar</tt>, which has its own drag icon
* and seperatator. The drag icon is shown in the beginning of the toolbar,
* before any of the containing toolbar buttons. It allows to drag the toolbar
* out of the container, where it is added and show it in a separate window.
* The separator is a line that could be added between two buttons. This way
* the developer could visualy group buttons with similar functionality.
*
* @author Yana Stamcheva
*/
public class SIPCommToolBar extends JToolBar {
/**
* Creates an instance of <tt>SIPCommToolBar</tt>.
*/
public SIPCommToolBar() {
this.add(Box.createRigidArea(new Dimension(4, 4)));
}
/**
* Adds a separator to this toolbar. The separator is added after
* the last component in the toolbar.
*/
public void addSeparator() {
JToolBar.Separator s = new JToolBar.Separator(new Dimension(8, 22));
s.setUI(new SIPCommToolBarSeparatorUI());
if (getOrientation() == VERTICAL) {
s.setOrientation(JSeparator.HORIZONTAL);
} else {
s.setOrientation(JSeparator.VERTICAL);
}
add(s);
}
/**
* Overrides the <code>paintBorder</code> method of <tt>JToolBar</tt>
* to paint the drag icon in the beginning of the toolbar.
*/
protected void paintBorder(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
BufferedImage dragImage = ImageLoader
.getImage(ImageLoader.TOOLBAR_DRAG_ICON);
g2.drawImage(dragImage, 0, (this.getHeight() - dragImage
.getHeight(null)) / 2 - 2, null);
}
}
|