修改一些问题

This commit is contained in:
wenli 2024-07-29 08:59:57 +08:00
parent cf5b085243
commit 024cb688ae
3 changed files with 32 additions and 23 deletions

View File

@ -90,7 +90,7 @@ public class IconLoader {
* @return {@link FlatSVGIcon} * @return {@link FlatSVGIcon}
*/ */
public static FlatSVGIcon getSvgIcon(String path, int w, int h) { public static FlatSVGIcon getSvgIcon(String path, int w, int h) {
if (StrUtil.isBlank(path)|| !FileUtil.isFile(path)) { if (StrUtil.isBlank(path)|| IconLoader.class.getResourceAsStream("/"+path) == null) {
path = "icons/item.svg"; path = "icons/item.svg";
} }
FlatSVGIcon flatSVGIcon = new FlatSVGIcon(path, w, h); FlatSVGIcon flatSVGIcon = new FlatSVGIcon(path, w, h);

View File

@ -59,7 +59,7 @@ public class MainFrame extends JFrame {
private JButton themeBut; private JButton themeBut;
private JButton refreshBut; private JButton refreshBut;
private JButton noticeBut; private JButton noticeBut;
private JPopupMenu themePopupMenu;
private MainFrame() { private MainFrame() {
MainPrefs.init(PREFS_ROOT_PATH); MainPrefs.init(PREFS_ROOT_PATH);
@ -282,7 +282,15 @@ public class MainFrame extends JFrame {
public JMenuBar getTitleMenuBar() { public JMenuBar getTitleMenuBar() {
if (titleMenuBar == null) { if (titleMenuBar == null) {
titleMenuBar = new JMenuBar(); titleMenuBar = new JMenuBar() {
@Override
public void updateUI() {
super.updateUI();
if (themePopupMenu != null) {
SwingUtilities.updateComponentTreeUI(themePopupMenu);
}
}
};
// left // left
titleMenuBar.add(getTitleLabel()); titleMenuBar.add(getTitleLabel());
titleMenuBar.add(Box.createGlue()); titleMenuBar.add(Box.createGlue());
@ -400,8 +408,9 @@ public class MainFrame extends JFrame {
*/ */
private void showPopupSkinButtonActionPerformed(ActionEvent e) { private void showPopupSkinButtonActionPerformed(ActionEvent e) {
Component invoker = (Component) e.getSource(); Component invoker = (Component) e.getSource();
JPopupMenu themePopupMenu = new JPopupMenu(); if (themePopupMenu == null) {
themePopupMenu = new JPopupMenu();
ButtonGroup group = new ButtonGroup(); ButtonGroup group = new ButtonGroup();
JCheckBoxMenuItem lighterMenuItem = new JCheckBoxMenuItem("白色"); JCheckBoxMenuItem lighterMenuItem = new JCheckBoxMenuItem("白色");
@ -420,6 +429,8 @@ public class MainFrame extends JFrame {
themePopupMenu.add(glazzedMenuItem); themePopupMenu.add(glazzedMenuItem);
group.add(glazzedMenuItem); group.add(glazzedMenuItem);
}
themePopupMenu.show(invoker, 0, invoker.getHeight()); themePopupMenu.show(invoker, 0, invoker.getHeight());

View File

@ -72,11 +72,9 @@ public class SidePane extends WPanel {
}else if (StrUtil.contains(icon,":")){ }else if (StrUtil.contains(icon,":")){
icon="icons/menu/"+icon.split(":")[1]+".svg"; icon="icons/menu/"+icon.split(":")[1]+".svg";
} }
FlatSVGIcon svgIcon = new FlatSVGIcon(icon, 25, 25); FlatSVGIcon svgIcon = IconLoader.getSvgIcon(icon,25,25);
svgIcon.setColorFilter(new FlatSVGIcon.ColorFilter(color -> {
return component.getForeground();
}));
((JLabel) component).setIcon(svgIcon); ((JLabel) component).setIcon(svgIcon);
} }