当前位置: 首页>>代码示例>>Java>>正文


Java JButton.addActionListener方法代码示例

本文整理汇总了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;
}
 
开发者ID:leolewis,项目名称:openvisualtraceroute,代码行数:23,代码来源:RouteTablePanel.java

示例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;
}
 
开发者ID:ZencashOfficial,项目名称:zencash-swing-wallet-ui,代码行数:27,代码来源:AddressBookPanel.java

示例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);
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:TestStringWizardPanel.java

示例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;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:23,代码来源:DynTableCellRenderEditor.java

示例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);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:22,代码来源:ApproximateStringSearchDemo.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:SideBarFactoryImpl.java

示例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);

}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:30,代码来源:NodeViewerData.java

示例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();
}
 
开发者ID:equella,项目名称:Equella,代码行数:35,代码来源:StepDialog.java

示例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;
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:8,代码来源:EntryPanel.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ButtonFactory.java

示例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;
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:10,代码来源:JasonID.java

示例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;
}
 
开发者ID:arjunvnair,项目名称:ArJ-class-editor,代码行数:33,代码来源:ArJClassEditor.java

示例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();
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:12,代码来源:FontCellEditor.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:ImageableAreaTest.java

示例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);

}
 
开发者ID:peterstefanov,项目名称:paillier,代码行数:34,代码来源:GUI.java


注:本文中的javax.swing.JButton.addActionListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。