diff options
Diffstat (limited to 'src/cppcheckplus/menu/MyMenu.java')
-rw-r--r-- | src/cppcheckplus/menu/MyMenu.java | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/cppcheckplus/menu/MyMenu.java b/src/cppcheckplus/menu/MyMenu.java new file mode 100644 index 0000000..3570408 --- /dev/null +++ b/src/cppcheckplus/menu/MyMenu.java | |||
@@ -0,0 +1,71 @@ | |||
1 | |||
2 | package cppcheckplus.menu; | ||
3 | |||
4 | import java.awt.Color; | ||
5 | import java.awt.Dimension; | ||
6 | import java.awt.Graphics; | ||
7 | import java.awt.Graphics2D; | ||
8 | import javax.swing.BorderFactory; | ||
9 | import javax.swing.JMenu; | ||
10 | import javax.swing.border.Border; | ||
11 | |||
12 | import cppcheckplus.control.MyContorlUtil; | ||
13 | |||
14 | |||
15 | public class MyMenu extends JMenu | ||
16 | { | ||
17 | private Color backgroundColor; | ||
18 | private Color foregroundColor; | ||
19 | private int borderThickness; | ||
20 | private Border border; | ||
21 | private int preferredHeight; | ||
22 | |||
23 | public MyMenu() | ||
24 | { | ||
25 | backgroundColor = MyContorlUtil.MENUITEM_BACKGROUND; | ||
26 | foregroundColor = MyContorlUtil.DEFAULT_TEXT_COLOR; | ||
27 | borderThickness = 1; | ||
28 | border = BorderFactory.createLineBorder(backgroundColor, borderThickness); | ||
29 | preferredHeight = 25; | ||
30 | init(); | ||
31 | } | ||
32 | |||
33 | public MyMenu(String text) | ||
34 | { | ||
35 | super(text); | ||
36 | backgroundColor = MyContorlUtil.MENUITEM_BACKGROUND; | ||
37 | foregroundColor = MyContorlUtil.DEFAULT_TEXT_COLOR; | ||
38 | borderThickness = 1; | ||
39 | border = BorderFactory.createLineBorder(backgroundColor, borderThickness); | ||
40 | preferredHeight = 25; | ||
41 | init(); | ||
42 | } | ||
43 | |||
44 | private void init() | ||
45 | { | ||
46 | setForeground(foregroundColor); | ||
47 | setFont(MyContorlUtil.FONT_14_BOLD); | ||
48 | setOpaque(true); | ||
49 | setBackground(backgroundColor); | ||
50 | setBorder(border); | ||
51 | } | ||
52 | @Override | ||
53 | protected void paintComponent(Graphics g) | ||
54 | { | ||
55 | if (isSelected()) | ||
56 | { | ||
57 | Graphics2D g2d = (Graphics2D)g; | ||
58 | g2d.setColor(MyContorlUtil.MENUITEM_SELECTED_BACKGROUND); | ||
59 | g2d.fillRect(0, 0, getWidth(), getHeight()); | ||
60 | super.paintComponent(g); | ||
61 | } else | ||
62 | { | ||
63 | super.paintComponent(g); | ||
64 | } | ||
65 | } | ||
66 | @Override | ||
67 | public Dimension getPreferredSize() | ||
68 | { | ||
69 | return new Dimension(super.getPreferredSize().width, preferredHeight); | ||
70 | } | ||
71 | } | ||