Browse Source

REPORT-55715 【组件背景分离】组件复用-颜色选择器和设计器里其他地方的颜色选择器不太一样,看起来有点奇怪

【问题原因】
新颜色选择框的右侧Button与UIComboBox右侧的Button风格不一致,导致视觉上开起来不和谐;
而且因为因为新颜色选择框右侧Button背景为白色边框为灰色,而UIComboBox边框和背景都为灰色,
所以即使给颜色选择框和UIComboBox相同的宽度,看起来也不没有对齐

【改动思路】
统一下颜色选择框的右侧按钮显示效果,保持与UIComboBox中右侧按钮一致
final/10.0
Starryi 3 years ago
parent
commit
006ae3f936
  1. 38
      designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java

38
designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java

@ -10,16 +10,20 @@ import java.awt.RenderingHints;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.AbstractButton;
import javax.swing.JPanel;
import javax.swing.border.AbstractBorder;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
import javax.swing.plaf.ButtonUI;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.stable.Constants;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.design.style.background.BackgroundJComponent;
import com.fr.stable.Constants;
/**
* @author kunsnat E-mail:kunsnat@gmail.com
@ -29,7 +33,7 @@ import com.fr.design.style.background.BackgroundJComponent;
public abstract class AbstractSelectBox<T> extends AbstractPopBox implements MouseListener {
private static final long serialVersionUID = 2355250206956896774L;
private UIToggleButton triggleButton;
private UIButton triggleButton;
protected void initBox(int preWidth) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
@ -37,8 +41,34 @@ public abstract class AbstractSelectBox<T> extends AbstractPopBox implements Mou
displayComponent = new BackgroundJComponent();
displayComponent.setEmptyBackground();
displayComponent.setBorder(new TriggleLineBorder());
triggleButton = new UIToggleButton(UIConstants.ARROW_DOWN_ICON);
triggleButton = new UIButton(UIConstants.ARROW_DOWN_ICON) {
public boolean shouldResponseChangeListener() {
return false;
}
@Override
public ButtonUI getUI() {
return new UIButtonUI() {
@Override
protected boolean isPressed(AbstractButton b) {
return model.isArmed() && model.isPressed();
}
@Override
protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) {
if (isPressed(b) && b.isPressedPainted()) {
GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), UIConstants.COMBOBOX_BTN_PRESS);
} else if (isRollOver(b)) {
GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), UIConstants.COMBOBOX_BTN_ROLLOVER);
} else if (b.isNormalPainted()) {
GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), UIConstants.COMBOBOX_BTN_NORMAL);
}
}
};
}
};
triggleButton.setPreferredSize(new Dimension(20, 20));
triggleButton.setRoundBorder(true, Constants.LEFT);
JPanel displayPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
displayPane.add(displayComponent, BorderLayout.CENTER);

Loading…
Cancel
Save