下面列出了javax.swing.AbstractButton#setBorderPainted ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void mouseEntered(MouseEvent e) {
Component component = e.getComponent();
if (component instanceof AbstractButton) {
AbstractButton button = (AbstractButton) component;
button.setBorderPainted(true);
}
}
@Override
public void mouseExited(MouseEvent e) {
Component component = e.getComponent();
if (component instanceof AbstractButton) {
AbstractButton button = (AbstractButton) component;
button.setBorderPainted(false);
}
}
protected void installDefaults(AbstractButton b) {
super.installDefaults(b);
b.setOpaque(false);
b.setBorderPainted(false);
b.setRolloverEnabled(true);
dashedRectGapX = UIManager.getInt("ButtonUI.dashedRectGapX");
dashedRectGapY = UIManager.getInt("ButtonUI.dashedRectGapY");
dashedRectGapWidth = UIManager.getInt("ButtonUI.dashedRectGapWidth");
dashedRectGapHeight = UIManager.getInt("ButtonUI.dashedRectGapHeight");
focusColor = UIManager.getColor("ButtonUI.focus");
b.setHorizontalAlignment(AbstractButton.LEFT);
}
public static AbstractButton makeTexturedToolBarButton(AbstractButton button, String segmentPosition) {
if (null == segmentPosition || segmentPosition.isEmpty() || segmentPosition.equals(SEGMENT_POSITION_ONLY)) {
button.putClientProperty("JButton.buttonType", "textured");
} else {
button.putClientProperty("JButton.buttonType", "segmentedTextured");
button.putClientProperty("JButton.segmentPosition", segmentPosition);
}
button.setText(null);
button.setBorderPainted(true);
button.setPreferredSize(Constants.seaGlassButtonDimension);
return button;
}
@Override
public void installUI(JComponent c) {
super.installUI(c);
c.setBorder(null);
if (c instanceof AbstractButton) {
AbstractButton btn = (AbstractButton) c;
btn.setBorder(new EmptyBorder(getScaledInt(5), getScaledInt(10), getScaledInt(5), getScaledInt(10)));
btn.setBorderPainted(false);
}
}
@Override
public void installUI(JComponent c) {
super.installUI(c);
if (c instanceof AbstractButton) {
AbstractButton btn = (AbstractButton) c;
// btn.setMargin(new Insets(10,10,10,10));
btn.setBorder(new EmptyBorder(getScaledInt(5), getScaledInt(10), getScaledInt(5), getScaledInt(10)));
// btn.setIcon(new XDMBlankIcon(15, 10));
btn.setBorderPainted(false);
// btn.setMargin(new Insets(10, 10, 10, 10));
// btn.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
}
}
/**
* Triggers the drawing of the border when the mouse entered the button area.
*
* @param e the mouse event.
*/
public void mouseEntered(final MouseEvent e) {
if (e.getSource() instanceof AbstractButton) {
final AbstractButton button = (AbstractButton) e.getSource();
if (button.isEnabled()) {
button.setBorderPainted(true);
}
}
}
@Override
public void mouseEntered(final MouseEvent event) {
final Component component = event.getComponent();
if (component instanceof AbstractButton) {
final AbstractButton button = (AbstractButton) component;
button.setBorderPainted(false);
}
}
private static void removeButtonContentAreaAndBorder(AbstractButton button) {
boolean canRemove = true;
if (button instanceof JToggleButton) {
canRemove = !button.isSelected();
}
if (canRemove) {
button.setContentAreaFilled(false);
button.setBorderPainted(false);
}
}
@Override
public void mouseEntered(MouseEvent evt) {
Object src = evt.getSource();
if (src instanceof AbstractButton) {
AbstractButton button = (AbstractButton) evt.getSource();
if (button.isEnabled()) {
button.setContentAreaFilled(true);
button.setBorderPainted(true);
}
}
}
public void mouseEntered(MouseEvent e) {
Component component = e.getComponent();
if (component instanceof AbstractButton) {
AbstractButton button = (AbstractButton) component;
button.setBorderPainted(true);
}
}
public void mouseEntered(MouseEvent e) {
Component component = e.getComponent();
if (component instanceof AbstractButton) {
AbstractButton button = (AbstractButton) component;
button.setBorderPainted(true);
}
}
@Override
public void mouseExited(final MouseEvent e) {
final Component component = e.getComponent();
if (component instanceof AbstractButton) {
final AbstractButton button = (AbstractButton) component;
button.setBorderPainted(false);
}
}
public void mouseExited(MouseEvent e) {
Component component = e.getComponent();
if (component instanceof AbstractButton) {
AbstractButton button = (AbstractButton) component;
button.setBorderPainted(false);
}
}
@Override
public void mouseExited(final MouseEvent event) {
final Component component = event.getComponent();
if (component instanceof AbstractButton) {
final AbstractButton button = (AbstractButton) component;
button.setBorderPainted(false);
}
}
public static void formatNext(AbstractButton button) {
button.setIcon(createIcon(true, .75f));
button.setRolloverIcon(createIcon(true, .85f));
button.setSelectedIcon(createIcon(true, 1f));
button.setDisabledIcon(createIcon(true, .3f));
button.setUI(new BevelButtonUI());
button.setContentAreaFilled(true);
button.putClientProperty("JButton.segmentPosition", "last");
button.setBorderPainted(true);
}
private void setSelectedState(AbstractButton b) {
if (b.isEnabled()) {
b.setBorderPainted(true);
b.setBackground(SELECTED_BACKGROUND_COLOR);
} else {
b.setBorderPainted(false);
b.setBackground(getDefaultBackground().darker());
}
}
private void setNormalState(AbstractButton b) {
b.setBorderPainted(false);
// b.setForeground(getDefaultForeground());
b.setBackground(getDefaultBackground());
}
protected void format(AbstractButton button) {
button.setBorderPainted(false);
button.setContentAreaFilled(false);
button.setUI(new BasicButtonUI());
}
/**
* Adds a button to this enabler.
*
* @param button the button.
*/
public void addButton(final AbstractButton button) {
button.addMouseListener(this);
button.setBorderPainted(false);
}