本文整理汇总了Java中javax.swing.AbstractButton.addActionListener方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractButton.addActionListener方法的具体用法?Java AbstractButton.addActionListener怎么用?Java AbstractButton.addActionListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.AbstractButton
的用法示例。
在下文中一共展示了AbstractButton.addActionListener方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeButtonPanel
import javax.swing.AbstractButton; //导入方法依赖的package包/类
protected JPanel makeButtonPanel(AbstractButton... buttons) {
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, GAP, GAP));
for (final AbstractButton button : buttons) {
if (button != null) {
buttonPanel.add(button);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ActionStatisticsCollector.getInstance().log(ActionStatisticsCollector.TYPE_DIALOG, key,
button.getActionCommand());
}
});
}
}
return buttonPanel;
}
示例2: initActionListener
import javax.swing.AbstractButton; //导入方法依赖的package包/类
private void initActionListener(Component[] cps) {
for (Component cp : cps) {
if (cp instanceof AbstractButton) {
AbstractButton ccp = (AbstractButton) cp;
ccp.addActionListener(this);
}
}
}
示例3: initialize
import javax.swing.AbstractButton; //导入方法依赖的package包/类
/**
* Initializes a specified presenter.
*
* @param presenter presenter to initialize
*/
private void initialize(AbstractButton presenter, boolean useIcons) {
if (useIcons) {
// set the presenter's icon:
Image icon = ImageUtilities.loadImage(
"org/netbeans/modules/url/urlObject.png"); //NOI18N
try {
FileObject file = dataObject.getPrimaryFile();
icon = FileUIUtils.getImageDecorator(file.getFileSystem()).
annotateIcon(icon,
BeanInfo.ICON_COLOR_16x16,
dataObject.files());
} catch (FileStateInvalidException fsie) {
// OK, so we use the default icon
}
presenter.setIcon(new ImageIcon(icon));
}
/* set the presenter's text and ensure it is maintained up-to-date: */
NameChangeListener listener = new NameChangeListener(presenter);
presenter.addPropertyChangeListener(
WeakListeners.propertyChange(listener, dataObject));
updateName(presenter);
/*
* The above code works with the assumption that it is called
* from the AWT event dispatching thread (it manipulates
* the presenter's display name). The same applies to
* NameChangeListener's method propertyChange(...).
*
* At least, both mentioned parts of code should be called from
* the same thread since method updateText(...) is not thread-safe.
*/
presenter.addActionListener(this);
HelpCtx.setHelpIDString(presenter,
dataObject.getHelpCtx().getHelpID());
}
示例4: subscribeActual
import javax.swing.AbstractButton; //导入方法依赖的package包/类
@Override
protected void subscribeActual(Observer<? super ActionEvent> observer) {
AbstractButton w = widget;
ActionEventConsumer aec = new ActionEventConsumer(observer, w);
observer.onSubscribe(aec);
w.addActionListener(aec);
if (aec.get() == null) {
w.removeActionListener(aec);
}
}
示例5: attachButton
import javax.swing.AbstractButton; //导入方法依赖的package包/类
/** Attaches given button to this recognizer, it means starts listening
* on its various mouse and action events
*/
public void attachButton (AbstractButton button) {
button.addActionListener(this);
button.addMouseListener(this);
button.addMouseMotionListener(this);
}
示例6: getToolbarPresenter
import javax.swing.AbstractButton; //导入方法依赖的package包/类
@Override
public Component getToolbarPresenter() {
final AbstractButton suspendIOButton = new JToggleButton();
Actions.connect(suspendIOButton, this);
updateButton(suspendIOButton);
final class Controller implements Runnable, ActionListener {
private RequestProcessor.Task updateTask;
Controller() {
updateTask = RP.create(this);
scheduleUpdate(0);
}
@Override
public void run() {
if (!EventQueue.isDispatchThread()) {
EventQueue.invokeLater(this);
return;
}
if (!suspendIOButton.isShowing()) {
return;
}
updateButton(suspendIOButton);
scheduleUpdate(0);
}
@Override
public void actionPerformed(ActionEvent e) {
updateButton(suspendIOButton);
run();
scheduleUpdate(100);
}
private void scheduleUpdate(int time) {
if (time == 0) {
time = 1500;
}
updateTask.schedule(time);
}
}
Controller c = new Controller();
suspendIOButton.addActionListener(c);
return suspendIOButton;
}
示例7: ButtonBridge
import javax.swing.AbstractButton; //导入方法依赖的package包/类
public ButtonBridge(AbstractButton button, Action action) {
super(button, action);
button.addActionListener(action);
this.button = button;
button.addActionListener(this);
}