Browse Source

REPORT-4604 设计器视觉修改

UIButtonGroup选中字体颜色变白 (19)
master
MoMeak 7 years ago
parent
commit
d06e1b0219
  1. 21
      designer_base/src/com/fr/design/gui/ibutton/UIButtonGroup.java
  2. 4
      designer_base/src/com/fr/design/gui/ibutton/UIButtonUI.java

21
designer_base/src/com/fr/design/gui/ibutton/UIButtonGroup.java

@ -8,11 +8,14 @@ import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import sun.swing.SwingUtilities2;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import javax.swing.plaf.basic.BasicHTML;
import javax.swing.text.View;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
@ -145,6 +148,24 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver {
} }
}; };
labelButton.setUI(new UIButtonUI() {
protected void paintText(Graphics g, AbstractButton b, String text, Rectangle textRec) {
View v = (View) b.getClientProperty(BasicHTML.propertyKey);
if (v != null) {
v.paint(g, textRec);
return;
}
FontMetrics fm = SwingUtilities2.getFontMetrics(b, g);
int mnemonicIndex = b.getDisplayedMnemonicIndex();
if (isPressed(b)) {
g.setColor(Color.white);
} else {
g.setColor(Color.black);
}
SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemonicIndex, textRec.x + getTextShiftOffset(), textRec.y + fm.getAscent() + getTextShiftOffset());
}
});
initButton(labelButton); initButton(labelButton);
} }
} }

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

@ -68,6 +68,10 @@ public class UIButtonUI extends BasicButtonUI {
} }
private void paintText(Graphics g, AbstractButton b, String text) { private void paintText(Graphics g, AbstractButton b, String text) {
paintText(g, b, text ,textRec);
}
protected void paintText(Graphics g, AbstractButton b, String text, Rectangle textRec) {
View v = (View) b.getClientProperty(BasicHTML.propertyKey); View v = (View) b.getClientProperty(BasicHTML.propertyKey);
if (v != null) { if (v != null) {
v.paint(g, textRec); v.paint(g, textRec);

Loading…
Cancel
Save