Skip to content

Commit

Permalink
add style submenu
Browse files Browse the repository at this point in the history
  • Loading branch information
DJ-Raven committed Mar 23, 2024
1 parent 20679e9 commit fd4cfd8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
Binary file not shown.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>raven.popup</groupId>
<artifactId>swing-glasspane-popup</artifactId>
<version>1.4.0</version>
<version>1.5.0</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/raven/drawer/component/menu/SimpleMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,12 @@ private void init() {
setLayout(menuLayout);
// Use opaque true on the first submenu panel to fix g2d draw arrow line
setOpaque(menuLevel == 0);
putClientProperty(FlatClientProperties.STYLE, "" +
if (simpleMenuOption.simpleMenuStyle != null) {
simpleMenuOption.simpleMenuStyle.styleMenuPanel(this, copyArray(this.index));
}
FlatLafStyleUtils.appendStyleIfAbsent(FlatClientProperties.STYLE, "" +
"background:null");

iconWidth = 22;
int index = 0;
int validationIndex = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public abstract class SimpleMenuStyle {
public void styleMenu(JComponent component) {
}

public void styleMenuPanel(JPanel panel, int[] index) {
}

public void styleMenuItem(JButton menu, int[] index) {
}

Expand Down
6 changes: 6 additions & 0 deletions src/test/java/test/MyDrawerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,14 @@ public void selected(MenuAction action, int[] index) {
}
});
simpleMenuOption.setMenuStyle(new SimpleMenuStyle() {
@Override
public void styleMenuPanel(JPanel panel, int[] index) {
// style submenu panel here
}

@Override
public void styleMenuItem(JButton menu, int[] index) {
menu.setContentAreaFilled(false);
menu.putClientProperty(FlatClientProperties.STYLE, "" +
"[light]foreground:#FAFAFA;" +
"arc:0");
Expand Down

0 comments on commit fd4cfd8

Please sign in to comment.