Browse Source

数值调整控件按钮颜色

master
hzzz 7 years ago
parent
commit
ee554425ed
  1. 3
      designer_base/src/com/fr/design/gui/ibutton/UIButtonUI.java
  2. 42
      designer_base/src/com/fr/design/gui/ispinner/UISpinner.java

3
designer_base/src/com/fr/design/gui/ibutton/UIButtonUI.java

@ -60,6 +60,7 @@ public class UIButtonUI extends BasicButtonUI {
private void paintContent(Graphics g, AbstractButton b, String text) {
if (b.getIcon() != null) {
g.setColor(Color.red);
paintIcon(g, b);
}
if (!StringUtils.isEmpty(text)) {
@ -160,7 +161,7 @@ public class UIButtonUI extends BasicButtonUI {
paintModelIcon(model, icon, g, c);
}
private void paintModelIcon(ButtonModel model, Icon icon, Graphics g, JComponent c) {
protected void paintModelIcon(ButtonModel model, Icon icon, Graphics g, JComponent c) {
if (model.isPressed() && model.isArmed()) {
icon.paintIcon(c, g, iconRec.x + getTextShiftOffset(),
iconRec.y + getTextShiftOffset());

42
designer_base/src/com/fr/design/gui/ispinner/UISpinner.java

@ -6,8 +6,9 @@ import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
@ -16,6 +17,7 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.plaf.ButtonUI;
import java.awt.*;
import java.awt.event.*;
@ -164,6 +166,34 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
}
}
private class ButtionUI extends UIButtonUI {
private boolean isNormalPaint = true;
@Override
protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) {
if (isPressed(b) && b.isPressedPainted()) {
isNormalPaint = false;
Color pressColor = UIConstants.COMBOBOX_BTN_PRESS;
GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), pressColor);
} else if (isRollOver(b)) {
isNormalPaint = false;
Color hoverColor = UIConstants.COMBOBOX_BTN_ROLLOVER;
GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), hoverColor);
} else if (b.isNormalPainted()) {
isNormalPaint = true;
GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted());
}
}
@Override
protected void paintModelIcon(ButtonModel model, Icon icon, Graphics g, JComponent c) {
if (isNormalPaint) {
g.setColor(UIConstants.COMBOBOX_BTN_NORMAL);
g.fillRect(0, 0, c.getWidth(), c.getHeight());
}
super.paintModelIcon(model, icon, g, c);
}
}
private void initComponents() {
textField = initNumberField();
@ -174,12 +204,22 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
public boolean shouldResponseChangeListener() {
return false;
}
@Override
public ButtonUI getUI() {
return new ButtionUI();
}
};
preButton.setRoundBorder(true, Constants.LEFT);
nextButton = new UIButton(UIConstants.ARROW_DOWN_ICON) {
public boolean shouldResponseChangeListener() {
return false;
}
@Override
public ButtonUI getUI() {
return new ButtionUI();
}
};
nextButton.setRoundBorder(true, Constants.LEFT);
setLayout(new BorderLayout());

Loading…
Cancel
Save