java AbstractButton_Java AbstractButton.repaint方法代码示例

import javax.swing.AbstractButton; //导入方法依赖的package包/类

private JButton createDropDownButton() {

Icon icon = ImageUtilities.loadImageIcon("org/netbeans/modules/debugger/resources/evaluator/drop_down_arrow.png", false);

final JButton button = new DropDownButton();

button.setIcon(icon);

String tooltipText = NbBundle.getMessage(CodeEvaluatorUI.class, "CTL_Expressions_Dropdown_tooltip");

button.setToolTipText(tooltipText);

button.setEnabled(false);

Dimension size = new Dimension(icon.getIconWidth() + 3, icon.getIconHeight() + 2);

button.setPreferredSize(size);

button.setMargin(new Insets(0, 0, 0, 0));

button.setFocusable(false);

AbstractAction action = new AbstractAction() {

@Override

public void actionPerformed(ActionEvent e) {

if ("pressed".equals(e.getActionCommand())) {

JComponent jc = (JComponent) e.getSource();

Point p = new Point(0, 0);

SwingUtilities.convertPointToScreen(p, jc);

if (!ButtonPopupSwitcher.isShown()) {

SwitcherTableItem[] items = createSwitcherItems();

ButtonPopupSwitcher.selectItem(jc, items, p.x, p.y);

}

//Other portion of issue 37487, looks funny if the

//button becomes pressed

if (jc instanceof AbstractButton) {

AbstractButton jb = (AbstractButton) jc;

jb.getModel().setPressed(false);

jb.getModel().setRollover(false);

jb.getModel().setArmed(false);

jb.repaint();

}

}

} // actionPerformed

@Override

public boolean isEnabled() {

return !getEditItemsList().isEmpty();

}

};

action.putValue(Action.SMALL_ICON, icon);

action.putValue(Action.SHORT_DESCRIPTION, tooltipText);

button.setAction(action);

return button;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值