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


Java JButton.setActionCommand方法代码示例

本文整理汇总了Java中javax.swing.JButton.setActionCommand方法的典型用法代码示例。如果您正苦于以下问题:Java JButton.setActionCommand方法的具体用法?Java JButton.setActionCommand怎么用?Java JButton.setActionCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JButton的用法示例。


在下文中一共展示了JButton.setActionCommand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buttonPanel

import javax.swing.JButton; //导入方法依赖的package包/类
private Component buttonPanel() {
	JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));

	accept = new JButton("Accept");
	accept.setFont(new Font("Arial", Font.PLAIN, 14));
	accept.setPreferredSize(new Dimension(110, 30));
	accept.setMnemonic(KeyEvent.VK_A);
	accept.setActionCommand("accept");
	accept.addActionListener(this);

	JButton cancel = new JButton("Cancel");
	cancel.setFont(new Font("Arial", Font.PLAIN, 14));
	cancel.setPreferredSize(new Dimension(110, 30));
	cancel.setMnemonic(KeyEvent.VK_C);
	cancel.setActionCommand("cancel");
	cancel.addActionListener(this);

	panel.add(accept);
	panel.add(Box.createRigidArea(new Dimension(50, 0)));
	panel.add(cancel);

	return panel;
}
 
开发者ID:AitorB,项目名称:POPBL_V,代码行数:24,代码来源:RecordDialog.java

示例2: show

import javax.swing.JButton; //导入方法依赖的package包/类
private void show(Window window, String command) {
    JButton button = new JButton(command);
    button.setActionCommand(command);
    button.addActionListener(this);
    button.setFont(button.getFont().deriveFont(64.0f));

    window.add(button);
    window.pack();
    window.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:Test4759934.java

示例3: makeNavigationButton

import javax.swing.JButton; //导入方法依赖的package包/类
protected JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {
    // Look for the image.
    String imgLocation = "images/" + imageName + ".gif";
    URL imageURL = ToolBarDemo.class.getResource(imgLocation);

    // Create and initialize the button.
    JButton button = new JButton();
    button.setActionCommand(actionCommand);
    button.setToolTipText(toolTipText);
    button.addActionListener(this);

    if (imageURL != null) { // image found
        button.setIcon(new ImageIcon(imageURL, altText));
    } else { // no image found
        button.setText(altText);
        System.err.println("Resource not found: " + imgLocation);
    }

    return button;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:21,代码来源:ToolBarDemo.java

示例4: ColorChooserPanel

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * The constructor to use.
 *
 * @param freeColClient The top level component that holds all
 *     other components.
 * @param l The ActionListener for the OK and cancel buttons.
 */
public ColorChooserPanel(FreeColClient freeColClient, ActionListener l) {
    super(freeColClient, new MigLayout("", "", ""));

    this.colorChooser = new JColorChooser();
    add(this.colorChooser);

    add(okButton, "newline 20, split 2, tag ok");
    okButton.addActionListener(l);

    JButton cancelButton = Utility.localizedButton("cancel");
    add(cancelButton, "tag cancel");
    cancelButton.setActionCommand(CANCEL);
    cancelButton.addActionListener(l);
    setCancelComponent(cancelButton);

    setOpaque(true);
    setSize(getPreferredSize());
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:26,代码来源:ColorChooserPanel.java

示例5: DialogCellEditor

import javax.swing.JButton; //导入方法依赖的package包/类
public DialogCellEditor(){
    button = new JButton();
    button.setBackground(Color.WHITE);
    button.setActionCommand(EDIT);
    button.addActionListener(this);
    button.setBorderPainted(false);
}
 
开发者ID:anousv,项目名称:OrthancAnonymization,代码行数:8,代码来源:DialogCellEditor.java

示例6: init

import javax.swing.JButton; //导入方法依赖的package包/类
private void init() {

            add(new javax.swing.Box.Filler(new java.awt.Dimension(10, 0),
                    new java.awt.Dimension(10, 0),
                    new java.awt.Dimension(10, 32767)));
            JLabel label = new JLabel("Properties");
            label.setFont(new Font("Default", Font.BOLD, 12));
            add(label);

            add(new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767)));
            toggleImage = new JToggleButton(Utils.getIconByResourceName("/ui/resources/or/image/image"));
            toggleImage.addItemListener(ImageORTable.this);
            toggleImage.setActionCommand("ToggleImage");
            toggleImage.setToolTipText("Show/Hide Image");
            add(toggleImage);

            JButton offset = new JButton(Utils.getIconByResourceName("/ui/resources/or/image/findOffset"));
            offset.addActionListener(ImageORTable.this);
            offset.setToolTipText("Show Offset");
            offset.setActionCommand("Show Offset");
            add(offset);

            JButton findOn = new JButton(Utils.getIconByResourceName("/ui/resources/or/image/findOnScreen"));
            findOn.addActionListener(ImageORTable.this);
            findOn.setToolTipText("Find on Screen");
            findOn.setActionCommand("Find on Screen");
            add(findOn);

            JButton editor = new JButton(Utils.getIconByResourceName("/ui/resources/or/image/propViewer"));
            editor.addActionListener(ImageORTable.this);
            editor.setToolTipText("Show Property Editor");
            editor.setActionCommand("Show Property Editor");
            add(editor);
        }
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:35,代码来源:ImageORTable.java

示例7: ProgressDialog

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Create the dialog.
 */
public ProgressDialog() {
    setBounds(100, 100, 450, 141);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    lblStatus = new JLabel("Status: Initializing");
    lblStatus.setFont(new Font("Tahoma", Font.PLAIN, 12));
    pb = new JProgressBar();
    GroupLayout gl_contentPanel = new GroupLayout(contentPanel);
    gl_contentPanel
            .setHorizontalGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING,
                    gl_contentPanel.createSequentialGroup().addContainerGap()
                            .addGroup(gl_contentPanel.createParallelGroup(Alignment.TRAILING)
                                    .addComponent(pb, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 404,
                                            Short.MAX_VALUE)
                                    .addComponent(lblStatus, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 404,
                                            Short.MAX_VALUE))
                            .addContainerGap()));
    gl_contentPanel.setVerticalGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_contentPanel.createSequentialGroup().addContainerGap().addComponent(lblStatus)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(pb, GroupLayout.DEFAULT_SIZE, 28,
                            Short.MAX_VALUE)));
    contentPanel.setLayout(gl_contentPanel);
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            JButton cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    dispose();
                }
            });
            cancelButton.setActionCommand("Cancel");
            buttonPane.add(cancelButton);
        }
    }
}
 
开发者ID:mob41,项目名称:osumer,代码行数:43,代码来源:ProgressDialog.java

示例8: bottomPanel

import javax.swing.JButton; //导入方法依赖的package包/类
private Component bottomPanel() {
	JPanel panel = new JPanel(new FlowLayout());
	panel.setOpaque(false);

	record = new JButton("  REC", new ImageIcon(References.STARTREC_IMAGE));
	record.setFont(new Font("Arial", Font.BOLD, 60));
	record.setActionCommand("record");
	record.addActionListener(this);
	record.setContentAreaFilled(false);
	record.setEnabled(false);

	panel.add(record);

	return panel;
}
 
开发者ID:AitorB,项目名称:POPBL_V,代码行数:16,代码来源:RecordPanel.java

示例9: getLinkButton

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Return a button suitable for linking to another panel
 * (e.g. ColopediaPanel).
 *
 * @param text a {@code String} value
 * @param icon an {@code Icon} value
 * @param action a {@code String} value
 * @return a {@code JButton} value
 */
public static JButton getLinkButton(String text, Icon icon, String action) {
    JButton button = new JButton(text, icon);
    button.setMargin(EMPTY_MARGIN);
    button.setOpaque(false);
    button.setForeground(LINK_COLOR);
    button.setAlignmentY(0.8f);
    button.setBorder(blankBorder(0, 0, 0, 0));
    button.setActionCommand(action);
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    return button;
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:21,代码来源:Utility.java

示例10: createToolBarButton

import javax.swing.JButton; //导入方法依赖的package包/类
private JButton createToolBarButton(String key, ActionListener listener) {
	JButton button = new JButton(getTranslation("toolbar."+key));
	button.setActionCommand(key);
	button.setToolTipText(getTranslation("toolbar."+key, TranslationType.TOOLTIP));
	URL resource = getResource("images/toolbar/"+key+".gif");
	if(resource!=null) {
		button.setText(new String());
		button.setIcon(new ImageIcon(getResource("images/toolbar/"+key+".gif"), getTranslation("toolbar."+key, TranslationType.ALTERNATIVE)));
	}
	button.addActionListener(listener);
	return button;
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:13,代码来源:Application.java

示例11: createLoadButton

import javax.swing.JButton; //导入方法依赖的package包/类
protected Component createLoadButton() {
	JButton b = new JButton("Load");
	b.addActionListener(this);
	b.setActionCommand("load");
	return b;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:7,代码来源:CustomDB.java

示例12: ColorBarPropertyEditPanel

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Creates a new edit panel for a color bar.
 * 
 * @param colorBar  the color bar.
 */
public ColorBarPropertyEditPanel(ColorBar colorBar) {
    super((NumberAxis) colorBar.getAxis());
    this.invertPalette = colorBar.getColorPalette().isInverse(); //dmo added
    this.stepPalette = colorBar.getColorPalette().isStepped(); //dmo added
    this.currentPalette = new PaletteSample(colorBar.getColorPalette());
    this.availablePaletteSamples = new PaletteSample[2];
    this.availablePaletteSamples[0] = new PaletteSample(new RainbowPalette());
    this.availablePaletteSamples[1] = new PaletteSample(new GreyPalette());

    JTabbedPane other = getOtherTabs();

    JPanel palettePanel = new JPanel(new LCBLayout(4));
    palettePanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    palettePanel.add(new JPanel());
    this.invertPaletteCheckBox = new JCheckBox(
        localizationResources.getString("Invert_Palette"), this.invertPalette
    );
    this.invertPaletteCheckBox.setActionCommand("invertPalette");
    this.invertPaletteCheckBox.addActionListener(this);
    palettePanel.add(this.invertPaletteCheckBox);
    palettePanel.add(new JPanel());

    palettePanel.add(new JPanel());
    this.stepPaletteCheckBox = new JCheckBox(localizationResources.getString("Step_Palette"),
            this.stepPalette);
    this.stepPaletteCheckBox.setActionCommand("stepPalette");
    this.stepPaletteCheckBox.addActionListener(this);
    palettePanel.add(this.stepPaletteCheckBox);
    palettePanel.add(new JPanel());

    palettePanel.add(new JLabel(localizationResources.getString("Palette")));
    JButton button = new JButton(localizationResources.getString("Set_palette..."));
    button.setActionCommand("PaletteChoice");
    button.addActionListener(this);
    palettePanel.add(this.currentPalette);
    palettePanel.add(button);

    other.add(localizationResources.getString("Palette"), palettePanel);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:47,代码来源:ColorBarPropertyEditPanel.java

示例13: AbstractAddEditConstraintDialog

import javax.swing.JButton; //导入方法依赖的package包/类
protected AbstractAddEditConstraintDialog(
		NetworkEntity<AbstractConstraint> ne, int lyr, Window owner,
		Dimension dim) {
	super(owner);
	setLayout(new BorderLayout());
	setSize(dim);
	setModalityType(DEFAULT_MODALITY_TYPE);
	setResizable(false);
	setLocationRelativeTo(getOwner());
	entity = ne;
	layer = lyr;

	if (layer == 0) {
		constraintStr = "Resource";
	} else {
		constraintStr = "Demand";
	}
	// set the title after entity and constraintStr have been set
	setTitle(getTitleText());
	// Button panel.
	JPanel btnPanel = new JPanel();
	JButton actionBtn = new JButton(getButtonText());
	actionBtn.addActionListener(this);
	btnPanel.add(actionBtn);

	JButton cancelBtn = new JButton("Cancel");
	cancelBtn.setActionCommand("cancel");
	cancelBtn.addActionListener(this);
	btnPanel.add(cancelBtn);

	// The content panel. It contains the ComboBox and the params panel.
	final JPanel content = new JPanel(new FlowLayout(FlowLayout.CENTER));
	content.add(new JLabel(getComboBoxLabelText()));
	comboBox = new JComboBox<Object>(getComboBoxObjects());
	content.add(comboBox);
	paramsPanel = new JPanel(new GridLayout(1, 2, 10, 10));
	content.add(paramsPanel);
	content.updateUI();
	comboBox.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			// remove all elements from the panel, do the specified action
			// and update
			paramsPanel.removeAll();
			doComboBoxAction();
			paramsPanel.updateUI();
		}
	});
	add(content, BorderLayout.CENTER);
	add(btnPanel, BorderLayout.SOUTH);
	setVisible(true);
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:53,代码来源:AbstractAddEditConstraintDialog.java

示例14: update

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Updates this panel's labels so that the information it displays
 * is up to date.
 */
public final void update() {
    removeAll();

    final Player player = getMyPlayer();
    final Europe europe = player.getEurope();

    add(question, "span, wrap 20");

    // The prices may have changed, recreate the buttons
    buttons.clear();
    for (UnitType ut : sort(units, priceComparator)) {
        int price = europe.getUnitPrice(ut);
        boolean enable = player.checkGold(price);
        JButton newButton = new JButton();
        newButton.setLayout(new MigLayout("wrap 2", "[60]", "[30][30]"));
        ImageIcon icon = new ImageIcon(getImageLibrary().getSmallUnitImage(
            ut, !enable));
        JLabel name = Utility.localizedLabel(ut);
        name.setEnabled(enable);
        JLabel gold = Utility.localizedLabel(StringTemplate
            .template("goldAmount")
            .addAmount("%amount%", price));
        gold.setEnabled(enable);
        newButton.setEnabled(enable);
        newButton.add(new JLabel(icon), "span 1 2");
        newButton.add(name);
        newButton.add(gold);
        newButton.setActionCommand(ut.getId());
        newButton.addActionListener(this);
        buttons.add(newButton);
        add(newButton, "grow");
    }

    add(okButton, "newline 20, span, tag ok");

    setSize(getPreferredSize());
    revalidate();

    shouldEnable = player.checkGold(europe.getUnitPrice(first(units)));
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:45,代码来源:NewUnitPanel.java

示例15: KeyGenPane

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Create the panel.
 */
public KeyGenPane(User user)
{
	this.name = user.getUser();
	this.mail = user.getMail();
	this.pass = user.getPassword();

	bgTask = new BackgroundTask();
	progressBar = new JProgressBar();
	progressBar.setStringPainted(true);
	progressBar.setMaximum(100);
	progressBar.setMinimum(0);
	progressBar.setValue(1);
	JLabel taskLabel = new JLabel(
			"<html>Bitte haben Sie einen Augenblick Geduld. <br>Die Schlüssel werden generiert.</html>");

	button = new JButton("Start");
	button.setActionCommand("weiter");
	button.addActionListener(new ActionHandler());
	button.setEnabled(true);

	JButton btnNewButton = new JButton("abbrechen");
	GroupLayout groupLayout = new GroupLayout(this);
	groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.TRAILING).addGroup(groupLayout
			.createSequentialGroup()
			.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
					.addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(btnNewButton)
							.addPreferredGap(ComponentPlacement.RELATED, 236, Short.MAX_VALUE).addComponent(button))
					.addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(taskLabel,
							GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE))
					.addGroup(groupLayout.createSequentialGroup().addGap(67).addComponent(progressBar,
							GroupLayout.PREFERRED_SIZE, 317, GroupLayout.PREFERRED_SIZE)))
			.addContainerGap()));
	groupLayout
			.setVerticalGroup(
					groupLayout.createParallelGroup(Alignment.TRAILING)
							.addGroup(
									groupLayout.createSequentialGroup().addGap(63).addComponent(taskLabel)
											.addPreferredGap(ComponentPlacement.RELATED, 99, Short.MAX_VALUE)
											.addComponent(progressBar, GroupLayout.PREFERRED_SIZE,
													GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
											.addGap(57)
											.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
													.addComponent(button).addComponent(btnNewButton))
											.addContainerGap()));
	setLayout(groupLayout);
}
 
开发者ID:AnonymOnline,项目名称:saveOrganizer,代码行数:50,代码来源:KeyGenPane.java


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