Browse Source

下拉框按钮非点击状态颜色 & 下拉框选项背景色

master
hzzz 7 years ago
parent
commit
9f5f83c878
  1. 29
      designer_base/src/com/fr/design/gui/ibutton/UIButtonUI.java
  2. 2
      designer_base/src/com/fr/design/gui/icombobox/UIComboBoxRenderer.java

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

@ -1,27 +1,16 @@
package com.fr.design.gui.ibutton; package com.fr.design.gui.ibutton;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.plaf.basic.BasicButtonUI;
import javax.swing.plaf.basic.BasicHTML;
import javax.swing.text.View;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.ReportAndFSManagePane;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.stable.StringUtils;
import sun.swing.SwingUtilities2; import sun.swing.SwingUtilities2;
import com.fr.stable.StringUtils; import javax.swing.*;
import com.fr.design.utils.gui.GUIPaintUtils; import javax.swing.plaf.basic.BasicButtonUI;
import javax.swing.plaf.basic.BasicHTML;
import javax.swing.text.View;
import java.awt.*;
public class UIButtonUI extends BasicButtonUI { public class UIButtonUI extends BasicButtonUI {
@ -66,7 +55,7 @@ public class UIButtonUI extends BasicButtonUI {
protected boolean isPressed(AbstractButton b) { protected boolean isPressed(AbstractButton b) {
ButtonModel model = b.getModel(); ButtonModel model = b.getModel();
return (model.isArmed() && model.isPressed()) || b.isSelected(); return model.isArmed() && model.isPressed();
} }
private void paintContent(Graphics g, AbstractButton b, String text) { private void paintContent(Graphics g, AbstractButton b, String text) {
@ -127,7 +116,7 @@ public class UIButtonUI extends BasicButtonUI {
return; return;
} }
Icon selectedIcon = null; Icon selectedIcon = null;
/* the fallback icon should be based on the selected state */ /* the fallback icon should be based on the selected state */
if (model.isSelected()) { if (model.isSelected()) {
selectedIcon = (Icon) b.getSelectedIcon(); selectedIcon = (Icon) b.getSelectedIcon();
if (selectedIcon != null) { if (selectedIcon != null) {

2
designer_base/src/com/fr/design/gui/icombobox/UIComboBoxRenderer.java

@ -27,7 +27,7 @@ public class UIComboBoxRenderer extends DefaultListCellRenderer {
cellHasFocus = cellHasFocus && !this.isEnabled(); cellHasFocus = cellHasFocus && !this.isEnabled();
JLabel renderer =(JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); JLabel renderer =(JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
renderer.setForeground(Color.black); renderer.setForeground(Color.black);
list.setSelectionBackground(UIConstants.FLESH_BLUE); list.setSelectionBackground(UIConstants.COMBOBOX_BTN_PRESS);
list.setSelectionForeground(Color.black); list.setSelectionForeground(Color.black);
renderer.setText(" " + renderer.getText()); renderer.setText(" " + renderer.getText());
return renderer; return renderer;

Loading…
Cancel
Save