Browse Source

REPORT-42238 【10.0.13】JDK11设计器图标模糊问题优化

No.2:提交UpdateAction
research/11.0
Yvan 4 years ago
parent
commit
1df5af6bc3
  1. 41
      designer-base/src/main/java/com/fr/design/actions/UpdateAction.java

41
designer-base/src/main/java/com/fr/design/actions/UpdateAction.java

@ -78,6 +78,16 @@ public abstract class UpdateAction extends ShortCut implements Action {
private String searchText = StringUtils.EMPTY;
/**
* 按钮在按压状态的图标key
*/
public static final String PRESSED_ICON = "pressedIcon";
/**
* 按钮在灰化状态的图标key
*/
public static final String DISABLED_ICON = "disabledIcon";
/**
@ -251,6 +261,14 @@ public abstract class UpdateAction extends ShortCut implements Action {
}
public void setPressedIcon(Icon pressedIcon) {
this.putValue(UpdateAction.PRESSED_ICON, pressedIcon);
}
public void setDisabledIcon(Icon disabledIcon) {
this.putValue(UpdateAction.DISABLED_ICON, disabledIcon);
}
@Override
public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
@ -271,6 +289,8 @@ public abstract class UpdateAction extends ShortCut implements Action {
UIMenuItem menuItem = new UIMenuItem(this);
// 设置名字用作单元测
menuItem.setName(getName());
setPressedIcon4Button(menuItem);
setDisabledIcon4Button(menuItem);
object = menuItem;
this.putValue(UIMenuItem.class.getName(), object);
@ -282,6 +302,8 @@ public abstract class UpdateAction extends ShortCut implements Action {
UIMenuEastAttrItem menuItem = new UIMenuEastAttrItem(this);
// 设置名字用作单元测
menuItem.setName(getName());
setPressedIcon4Button(menuItem);
setDisabledIcon4Button(menuItem);
this.putValue(UIMenuItem.class.getName(), menuItem);
return menuItem;
}
@ -307,6 +329,8 @@ public abstract class UpdateAction extends ShortCut implements Action {
}
button.setIcon((Icon) this.getValue(Action.SMALL_ICON));
setPressedIcon4Button(button);
setDisabledIcon4Button(button);
button.addActionListener(this);
button.registerKeyboardAction(this, this.getAccelerator(), JComponent.WHEN_IN_FOCUSED_WINDOW);
@ -454,6 +478,8 @@ public abstract class UpdateAction extends ShortCut implements Action {
object = new UseMenuItem(this);
this.putValue(UseMenuItem.class.getName(), object);
}
setPressedIcon4Button((UseMenuItem) object);
setDisabledIcon4Button((UseMenuItem) object);
return (UseMenuItem) object;
}
@ -594,4 +620,17 @@ public abstract class UpdateAction extends ShortCut implements Action {
shortPinyin.append(PinyinHelper.getShortPinyin(title)).append(separator);
}
}
private void setPressedIcon4Button(AbstractButton button) {
Icon pressedIcon = (Icon) this.getValue(UpdateAction.PRESSED_ICON);
if (pressedIcon != null) {
button.setPressedIcon(pressedIcon);
}
}
private void setDisabledIcon4Button(AbstractButton button) {
Icon disabledIcon = (Icon) this.getValue(UpdateAction.DISABLED_ICON);
if (disabledIcon != null) {
button.setDisabledIcon(disabledIcon);
}
}
}

Loading…
Cancel
Save