summaryrefslogtreecommitdiffstats
path: root/src/cppcheckplus/menu/MyRootMenu.java
diff options
context:
space:
mode:
authorWe-unite <3205135446@qq.com>2025-02-19 13:45:27 +0800
committerWe-unite <3205135446@qq.com>2025-02-19 13:45:27 +0800
commiteaba1ffa193104f90751371bfa9814552a2a6243 (patch)
tree07fbb22993b79dcbf8e1dd4521918e50523e1315 /src/cppcheckplus/menu/MyRootMenu.java
downloadproject-eaba1ffa193104f90751371bfa9814552a2a6243.tar.gz
project-eaba1ffa193104f90751371bfa9814552a2a6243.zip
Init
Diffstat (limited to 'src/cppcheckplus/menu/MyRootMenu.java')
-rw-r--r--src/cppcheckplus/menu/MyRootMenu.java62
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
3package cppcheckplus.menu;
4
5import java.awt.Color;
6import java.awt.Graphics;
7import java.awt.Graphics2D;
8import java.awt.TexturePaint;
9
10import javax.swing.BorderFactory;
11import javax.swing.JMenu;
12import javax.swing.border.Border;
13
14import cppcheckplus.control.MyContorlUtil;
15
16
17public 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}