diff options
Diffstat (limited to 'src/cppcheckplus/menu/MyMenuBar.java')
-rw-r--r-- | src/cppcheckplus/menu/MyMenuBar.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/cppcheckplus/menu/MyMenuBar.java b/src/cppcheckplus/menu/MyMenuBar.java new file mode 100644 index 0000000..7d5d102 --- /dev/null +++ b/src/cppcheckplus/menu/MyMenuBar.java | |||
@@ -0,0 +1,56 @@ | |||
1 | |||
2 | package cppcheckplus.menu; | ||
3 | |||
4 | import java.awt.Dimension; | ||
5 | import java.awt.Graphics; | ||
6 | import java.awt.Graphics2D; | ||
7 | import java.awt.Image; | ||
8 | import java.awt.TexturePaint; | ||
9 | import javax.swing.BorderFactory; | ||
10 | import javax.swing.ImageIcon; | ||
11 | import javax.swing.JMenuBar; | ||
12 | import javax.swing.border.Border; | ||
13 | |||
14 | import cppcheckplus.control.MyContorlUtil; | ||
15 | |||
16 | |||
17 | public class MyMenuBar extends JMenuBar | ||
18 | { | ||
19 | |||
20 | private Image backgroundLeftImage; | ||
21 | private Image backgroundRightImage; | ||
22 | private ImageIcon backgroundImageIcon; | ||
23 | private TexturePaint paint; | ||
24 | private Border border; | ||
25 | |||
26 | public MyMenuBar() | ||
27 | { | ||
28 | backgroundLeftImage = MyContorlUtil.getImage("control/images/menubar_background_left.png"); | ||
29 | backgroundRightImage = MyContorlUtil.getImage("control/images/menubar_background_right.png"); | ||
30 | backgroundImageIcon = MyContorlUtil.getImageIcon("control/images/menubar_background.png"); | ||
31 | paint = MyContorlUtil.createTexturePaint("control/images/menubar_background.png"); | ||
32 | border = BorderFactory.createEmptyBorder(); | ||
33 | init(); | ||
34 | } | ||
35 | private void init() | ||
36 | { | ||
37 | setBorder(border); | ||
38 | } | ||
39 | @Override | ||
40 | protected void paintComponent(Graphics g) | ||
41 | { | ||
42 | super.paintComponent(g); | ||
43 | Graphics2D g2d = (Graphics2D)g; | ||
44 | g2d.setPaint(paint); | ||
45 | g2d.fillRect(0, 0, getWidth(), getHeight()); | ||
46 | g2d.drawImage(backgroundLeftImage, 0, 0, null); | ||
47 | g2d.drawImage(backgroundRightImage, getWidth() - backgroundRightImage.getWidth(null), 0, null); | ||
48 | } | ||
49 | @Override | ||
50 | public Dimension getPreferredSize() | ||
51 | { | ||
52 | return new Dimension(super.getPreferredSize().width, backgroundImageIcon.getIconHeight()); | ||
53 | } | ||
54 | |||
55 | } | ||
56 | |||