diff options
Diffstat (limited to 'src/cppcheckplus/toolbar/MyToolBar.java')
-rw-r--r-- | src/cppcheckplus/toolbar/MyToolBar.java | 93 |
1 files changed, 46 insertions, 47 deletions
diff --git a/src/cppcheckplus/toolbar/MyToolBar.java b/src/cppcheckplus/toolbar/MyToolBar.java index e0473a6..26f14d2 100644 --- a/src/cppcheckplus/toolbar/MyToolBar.java +++ b/src/cppcheckplus/toolbar/MyToolBar.java | |||
@@ -1,6 +1,6 @@ | |||
1 | |||
2 | package cppcheckplus.toolbar; | 1 | package cppcheckplus.toolbar; |
3 | 2 | ||
3 | import cppcheckplus.control.MyContorlUtil; | ||
4 | import java.awt.Dimension; | 4 | import java.awt.Dimension; |
5 | import java.awt.FlowLayout; | 5 | import java.awt.FlowLayout; |
6 | import java.awt.Graphics; | 6 | import java.awt.Graphics; |
@@ -10,51 +10,50 @@ import javax.swing.BorderFactory; | |||
10 | import javax.swing.Icon; | 10 | import javax.swing.Icon; |
11 | import javax.swing.JPanel; | 11 | import javax.swing.JPanel; |
12 | 12 | ||
13 | import cppcheckplus.control.MyContorlUtil; | ||
14 | |||
15 | 13 | ||
16 | public class MyToolBar extends JPanel | 14 | public class MyToolBar extends JPanel { |
17 | { | 15 | private String backgroundImageURL; |
18 | private String backgroundImageURL; | 16 | private int preferredHeight; |
19 | private int preferredHeight; | 17 | private TexturePaint paint; |
20 | private TexturePaint paint; | 18 | private int buttonGap; |
21 | private int buttonGap; | 19 | |
22 | 20 | public MyToolBar() { | |
23 | public MyToolBar() | 21 | preferredHeight = |
24 | { | 22 | MyContorlUtil.getImageIcon("control/images/toolbar_background.png") |
25 | preferredHeight = MyContorlUtil.getImageIcon("control/images/toolbar_background.png").getIconHeight(); | 23 | .getIconHeight(); |
26 | paint = MyContorlUtil.createTexturePaint("control/images/toolbar_background.png"); | 24 | paint = MyContorlUtil.createTexturePaint( |
27 | buttonGap = 2; | 25 | "control/images/toolbar_background.png"); |
28 | init(); | 26 | buttonGap = 2; |
29 | } | 27 | init(); |
30 | 28 | } | |
31 | private void init() | 29 | |
32 | { | 30 | private void init() { |
33 | setLayout(new FlowLayout(3, buttonGap, 0)); | 31 | setLayout(new FlowLayout(3, buttonGap, 0)); |
34 | setBorder(BorderFactory.createEmptyBorder(2, 5, 0, 5)); | 32 | setBorder(BorderFactory.createEmptyBorder(2, 5, 0, 5)); |
35 | } | 33 | } |
36 | public void addButton(Icon icon, String tooltip,String actionCommand,boolean rover) | 34 | |
37 | { | 35 | public void addButton(Icon icon, String tooltip, String actionCommand, |
38 | MyToolBarButton barButton; | 36 | boolean rover) { |
39 | if (rover) | 37 | MyToolBarButton barButton; |
40 | barButton = new MyToolBarRoverButton(); | 38 | if (rover) { |
41 | else | 39 | barButton = new MyToolBarRoverButton(); |
42 | barButton = new MyToolBarButton(); | 40 | } else { |
43 | barButton.setIcon(icon); | 41 | barButton = new MyToolBarButton(); |
44 | barButton.setToolTipText(tooltip); | 42 | } |
45 | barButton.setActionCommand(actionCommand); | 43 | barButton.setIcon(icon); |
46 | add(barButton); | 44 | barButton.setToolTipText(tooltip); |
47 | } | 45 | barButton.setActionCommand(actionCommand); |
48 | protected void paintComponent(Graphics g) | 46 | add(barButton); |
49 | { | 47 | } |
50 | super.paintComponent(g); | 48 | |
51 | Graphics2D g2d = (Graphics2D)g; | 49 | protected void paintComponent(Graphics g) { |
52 | g2d.setPaint(paint); | 50 | super.paintComponent(g); |
53 | g2d.fillRect(0, 0, getWidth(), getHeight()); | 51 | Graphics2D g2d = (Graphics2D) g; |
54 | } | 52 | g2d.setPaint(paint); |
55 | 53 | g2d.fillRect(0, 0, getWidth(), getHeight()); | |
56 | public Dimension getPreferredSize() | 54 | } |
57 | { | 55 | |
58 | return new Dimension(super.getPreferredSize().width, preferredHeight); | 56 | public Dimension getPreferredSize() { |
59 | } | 57 | return new Dimension(super.getPreferredSize().width, preferredHeight); |
58 | } | ||
60 | } | 59 | } |