diff options
author | 2025-02-19 13:45:27 +0800 | |
---|---|---|
committer | 2025-02-19 13:45:27 +0800 | |
commit | eaba1ffa193104f90751371bfa9814552a2a6243 (patch) | |
tree | 07fbb22993b79dcbf8e1dd4521918e50523e1315 /src/cppcheckplus/menu/MyRootMenu.java | |
download | project-eaba1ffa193104f90751371bfa9814552a2a6243.tar.gz project-eaba1ffa193104f90751371bfa9814552a2a6243.zip |
Init
Diffstat (limited to 'src/cppcheckplus/menu/MyRootMenu.java')
-rw-r--r-- | src/cppcheckplus/menu/MyRootMenu.java | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/cppcheckplus/menu/MyRootMenu.java b/src/cppcheckplus/menu/MyRootMenu.java new file mode 100644 index 0000000..b5d442d --- /dev/null +++ b/src/cppcheckplus/menu/MyRootMenu.java | |||
@@ -0,0 +1,62 @@ | |||
1 | |||
2 | |||
3 | package cppcheckplus.menu; | ||
4 | |||
5 | import java.awt.Color; | ||
6 | import java.awt.Graphics; | ||
7 | import java.awt.Graphics2D; | ||
8 | import java.awt.TexturePaint; | ||
9 | |||
10 | import javax.swing.BorderFactory; | ||
11 | import javax.swing.JMenu; | ||
12 | import javax.swing.border.Border; | ||
13 | |||
14 | import cppcheckplus.control.MyContorlUtil; | ||
15 | |||
16 | |||
17 | public class MyRootMenu extends JMenu | ||
18 | { | ||
19 | private Color foregroundColor; | ||
20 | private String selectedBackgroundImageURL; | ||
21 | private TexturePaint paint; | ||
22 | private Border border; | ||
23 | |||
24 | public MyRootMenu() | ||
25 | { | ||
26 | foregroundColor = MyContorlUtil.DEFAULT_TEXT_COLOR; | ||
27 | paint = MyContorlUtil.createTexturePaint("control/images/menubar_background_selected.png"); | ||
28 | border = BorderFactory.createEmptyBorder(0, 5, 0, 4); | ||
29 | init(); | ||
30 | |||
31 | } | ||
32 | |||
33 | public MyRootMenu(String text) | ||
34 | { | ||
35 | super(text); | ||
36 | foregroundColor = MyContorlUtil.DEFAULT_TEXT_COLOR; | ||
37 | paint = MyContorlUtil.createTexturePaint("control/images/menubar_background_selected.png"); | ||
38 | border = BorderFactory.createEmptyBorder(0, 5, 0, 4); | ||
39 | init(); | ||
40 | } | ||
41 | |||
42 | private void init() | ||
43 | { | ||
44 | setFont(MyContorlUtil.FONT_14_BOLD); | ||
45 | setBorder(border); | ||
46 | setForeground(foregroundColor); | ||
47 | } | ||
48 | |||
49 | protected void paintComponent(Graphics g) | ||
50 | { | ||
51 | if (isSelected()) | ||
52 | { | ||
53 | Graphics2D g2d = (Graphics2D)g; | ||
54 | g2d.setPaint(paint); | ||
55 | g2d.fillRect(0, 0, getWidth(), getHeight()); | ||
56 | super.paintComponent(g); | ||
57 | } else | ||
58 | { | ||
59 | super.paintComponent(g); | ||
60 | } | ||
61 | } | ||
62 | } | ||