本文整理汇总了Java中javax.swing.JButton.addActionListener方法的典型用法代码示例。如果您正苦于以下问题:Java JButton.addActionListener方法的具体用法?Java JButton.addActionListener怎么用?Java JButton.addActionListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JButton
的用法示例。
在下文中一共展示了JButton.addActionListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTableCellEditorComponent
import javax.swing.JButton; //导入方法依赖的package包/类
@Override
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, final int row, final int column) {
final Component c = super.getTableCellEditorComponent(table, value, isSelected, row, column);
final JButton button = new JButton("?");
button.setMargin(new Insets(0, 0, 0, 0));
button.setToolTipText(Column.WHO_IS.getLabel());
button.setPreferredSize(new Dimension(Column.WHO_IS.getWidth(), c.getHeight()));
button.setMaximumSize(button.getPreferredSize());
if (Env.INSTANCE.getOs() == OS.win) {
button.setBorder(null);
}
button.setEnabled(!_searching);
button.addActionListener(e -> {
final RoutePoint point = _route.getRoute().get(_table.convertRowIndexToModel(row));
WhoIsPanel.showWhoIsDialog(RouteTablePanel.this, _services, point);
if (table.isEditing()) {
table.getCellEditor().stopCellEditing();
}
_whois.clear();
});
return button;
}
示例2: buildButtonsPanel
import javax.swing.JButton; //导入方法依赖的package包/类
private JPanel buildButtonsPanel() {
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
panel.setLayout(new FlowLayout(FlowLayout.CENTER, 3, 3));
JButton newContactButton = new JButton("New contact...");
newContactButton.addActionListener(new NewContactActionListener());
panel.add(newContactButton);
sendCashButton = new JButton("Send ZEN");
sendCashButton.addActionListener(new SendCashActionListener());
sendCashButton.setEnabled(false);
panel.add(sendCashButton);
copyToClipboardButton = new JButton("Copy address to clipboard");
copyToClipboardButton.setEnabled(false);
copyToClipboardButton.addActionListener(new CopyToClipboardActionListener());
panel.add(copyToClipboardButton);
deleteContactButton = new JButton("Delete contact");
deleteContactButton.setEnabled(false);
deleteContactButton.addActionListener(new DeleteAddressActionListener());
panel.add(deleteContactButton);
return panel;
}
示例3: CustomizeCellEditor
import javax.swing.JButton; //导入方法依赖的package包/类
/** Constructor. */
public CustomizeCellEditor() {
editorComponent = new JButton("..."); // NOI18N
editorComponent.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
PropertyPanel panel = i18nString.getSupport().getPropertyPanel();
panel.setI18nString(i18nString);
DialogDescriptor dd = new DialogDescriptor(panel,"Customize Property");
dd.setModal(true);
dd.setOptionType(DialogDescriptor.DEFAULT_OPTION);
dd.setOptions(new Object[] {DialogDescriptor.OK_OPTION});
dd.setAdditionalOptions(new Object[0]);
dd.setButtonListener(CustomizeCellEditor.this);
Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
dialog.setVisible(true);
}
});
}
示例4: getJButtonOntologyClassVisualsation
import javax.swing.JButton; //导入方法依赖的package包/类
/**
* Returns the JButton for a OntologyClassVisualsation like for TimeSeries or XyChart's.
*
* @param dynType the current DynType
* @param startArgIndex the start argument index
* @return the JButton for special class
*/
private JButton getJButtonOntologyClassVisualsation(DynType dynType) {
final DynType dynTypeCurrent = dynType;
JButton jButtonSpecialClass = new JButton();
jButtonSpecialClass.setFont(new Font("Arial", Font.BOLD, 11));
jButtonSpecialClass.setText("Edit");
jButtonSpecialClass.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dynTable.setOntologyClassVisualsationVisible(dynTypeCurrent);
}
});
return jButtonSpecialClass;
}
示例5: ApproximateStringSearchDemo
import javax.swing.JButton; //导入方法依赖的package包/类
public ApproximateStringSearchDemo() {
super(new BorderLayout());
startButton = new JButton("Start");
startButton.setActionCommand("startButton");
startButton.addActionListener(this);
knnField = new JTextField(Integer.toString(knn), 5);
optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
optionPane.add(startButton);
optionPane.add(new JLabel("K:"));
optionPane.add(knnField);
add(optionPane, BorderLayout.NORTH);
canvas = new JPanel(new GridLayout(1, 2));
canvas.setBackground(Color.WHITE);
add(canvas, BorderLayout.CENTER);
}
示例6: SideBar
import javax.swing.JButton; //导入方法依赖的package包/类
public SideBar(Document forDocument) {
super(new BorderLayout());
this.forDocument = forDocument;
add(new BreadCrumbComponent(), BorderLayout.CENTER);
JButton closeButton = CloseButtonFactory.createBigCloseButton();
add(closeButton, BorderLayout.EAST);
prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, this, prefs));
closeButton.addActionListener(new ActionListener() {
@Override public void actionPerformed(ActionEvent e) {
prefs.putBoolean(KEY_BREADCRUMBS, false);
}
});
setBorder(new SeparatorBorder());
preferenceChange(null);
}
示例7: NodeViewerData
import javax.swing.JButton; //导入方法依赖的package包/类
public NodeViewerData() {
this.setLayout(new BorderLayout());
this.dataArea = new JTextPane();
this.toolbar = new JToolBar();
this.toolbar.setFloatable(false);
JScrollPane scroller = new JScrollPane(this.dataArea);
scroller
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
this.add(scroller, BorderLayout.CENTER);
this.add(this.toolbar, BorderLayout.NORTH);
JButton saveButton = new JButton(ZooInspector.iconResource.get(IconResource.ICON_SAVE,""));
saveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (selectedNode != null) {
if (JOptionPane.showConfirmDialog(NodeViewerData.this,
"Are you sure you want to save this node?"
+ " (this action cannot be reverted)",
"Confirm Save", JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {
zooInspectorManager.setData(selectedNode, dataArea
.getText());
}
}
}
});
this.toolbar.add(saveButton);
}
示例8: setup
import javax.swing.JButton; //导入方法依赖的package包/类
private void setup()
{
JLabel label = new JLabel(CurrentLocale.get("com.tle.admin.workflow.stepdialog.title"));
model = new GenericListModel<Class<? extends WorkflowNode>>();
list = new JList(model);
list.setCellRenderer(new WorkflowCellRenderer());
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.addListSelectionListener(this);
list.addMouseListener(this);
ok = new JButton(CurrentLocale.get("com.tle.admin.ok"));
cancel = new JButton(CurrentLocale.get("com.tle.admin.cancel"));
ok.addActionListener(this);
cancel.addActionListener(this);
final int height1 = label.getPreferredSize().height;
final int height2 = ok.getPreferredSize().height;
final int width1 = cancel.getPreferredSize().width;
final int[] rows = {height1, TableLayout.FILL, height2,};
final int[] cols = {TableLayout.FILL, width1, width1,};
content = new JPanel(new TableLayout(rows, cols));
content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
content.add(label, new Rectangle(0, 0, 3, 1));
content.add(new JScrollPane(list), new Rectangle(0, 1, 3, 1));
content.add(ok, new Rectangle(1, 2, 1, 1));
content.add(cancel, new Rectangle(2, 2, 1, 1));
updateButtons();
}
示例9: smallButton
import javax.swing.JButton; //导入方法依赖的package包/类
private JButton smallButton(String text, boolean enabled)
{
JButton b = new JButton(text);
b.setEnabled(enabled);
b.addActionListener(this);
return b;
}
示例10: createMaximizeButton
import javax.swing.JButton; //导入方法依赖的package包/类
/**
* Creates button to maximize currently selected document in the given tab displayer.
* @param controller Tab displayer's controller.
* @return Button to maximize selected document tab.
*/
public static JButton createMaximizeButton( final Controller controller ) {
final JButton btn = new JButton();
btn.setIcon( ImageUtilities.loadImageIcon( "org/netbeans/core/multitabs/resources/maximize.png", true) ); //NOI18N
btn.setToolTipText( NbBundle.getMessage(ButtonFactory.class, "Hint_MaximizeRestore") );
btn.addActionListener( new ActionListener() {
@Override
public void actionPerformed( ActionEvent e ) {
controller.postActionEvent( new TabActionEvent( btn, TabbedContainer.COMMAND_MAXIMIZE, -1 ) );
}
});
btn.setFocusable( false );
return btn;
}
示例11: createToolBarButton
import javax.swing.JButton; //导入方法依赖的package包/类
protected JButton createToolBarButton(String toolTip, Icon icon, ActionListener act) {
JButton button = new RolloverButton(icon);
button.setMargin(new Insets(0, 0, 0, 0));
button.setRequestFocusEnabled(false);
button.setToolTipText(toolTip);
button.setRequestFocusEnabled(false);
button.addActionListener(act);
return button;
}
示例12: createCompileButton
import javax.swing.JButton; //导入方法依赖的package包/类
/**
* Constructs a compile button according to parameters
* @param compileButtonText the text of the compile button
* @return the constructed button
*/
public JButton createCompileButton(String compileButtonText)
{
JButton compileButton = new JButton(compileButtonText);
ActionListener compileButtonListener = new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
try
{
compile();
}
catch (IOException e1)
{
source.getParentFile().mkdirs();
compiler.run(null, null, null, source.getPath());
try
{
loadClass();
}
catch(MalformedURLException e2) {}
}
}
};
compileButton.addActionListener(compileButtonListener);
return compileButton;
}
示例13: FontCellEditor
import javax.swing.JButton; //导入方法依赖的package包/类
/**
* Constructor.
*/
public FontCellEditor() {
button = new JButton("AaBbYyZz");
button.setActionCommand(EDIT);
button.addActionListener(this);
// Set up the dialog that the button brings up.
fontChooser = new FontChooser();
}
示例14: createAndShowTestDialog
import javax.swing.JButton; //导入方法依赖的package包/类
private static void createAndShowTestDialog(String description,
String failMessage, Runnable action) {
final JDialog dialog = new JDialog();
dialog.setTitle("Test: " + (++testCount));
dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
JTextArea textArea = new JTextArea(description);
textArea.setEditable(false);
final JButton testButton = new JButton("Print Table");
final JButton passButton = new JButton("PASS");
passButton.setEnabled(false);
passButton.addActionListener((e) -> {
dialog.dispose();
});
final JButton failButton = new JButton("FAIL");
failButton.setEnabled(false);
failButton.addActionListener((e) -> {
throw new RuntimeException(failMessage);
});
testButton.addActionListener((e) -> {
testButton.setEnabled(false);
action.run();
passButton.setEnabled(true);
failButton.setEnabled(true);
});
JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.add(textArea, BorderLayout.CENTER);
JPanel buttonPanel = new JPanel(new FlowLayout());
buttonPanel.add(testButton);
buttonPanel.add(passButton);
buttonPanel.add(failButton);
mainPanel.add(buttonPanel, BorderLayout.SOUTH);
dialog.add(mainPanel);
dialog.pack();
dialog.setVisible(true);
}
示例15: Controls
import javax.swing.JButton; //导入方法依赖的package包/类
public Controls() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
setBorder(new EmptyBorder(1, 1, 1, 1));
setBackground(Color.blue);
JPanel t = new JPanel();
t.setBorder(new EmptyBorder(5, 5, 5, 5));
label = new JLabel();
label.setLayout(new BorderLayout());
t.add(label);
t.setSize(1185, 50);
add(t);
JPanel p = new JPanel();
start = new JButton("Start");
start.addActionListener(this);
p.add(start);
processVoting = new JButton("ProcessVoting");
processVoting.addActionListener(this);
p.add(processVoting);
add(p);
textArea = new JPanel();
screen = new JTextArea(17, 100);
screen.setLineWrap(true);
screen.setForeground(Color.blue);// set color for font
screen.setBackground(Color.WHITE);// set background color
// screen.setText("\n" + "Results from encryption and decryption");
JScrollPane scrollingArea = new JScrollPane(screen);
scrollingArea.setSize(15, 100);
textArea.add(scrollingArea, BorderLayout.CENTER);
add(textArea);
}