當前位置: 首頁>>代碼示例>>Java>>正文


Java JRadioButton.setActionCommand方法代碼示例

本文整理匯總了Java中javax.swing.JRadioButton.setActionCommand方法的典型用法代碼示例。如果您正苦於以下問題:Java JRadioButton.setActionCommand方法的具體用法?Java JRadioButton.setActionCommand怎麽用?Java JRadioButton.setActionCommand使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JRadioButton的用法示例。


在下文中一共展示了JRadioButton.setActionCommand方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: GenealogyExample

import javax.swing.JRadioButton; //導入方法依賴的package包/類
public GenealogyExample() {
    super(new BorderLayout());

    // Construct the panel with the toggle buttons.
    JRadioButton showDescendant = new JRadioButton("Show descendants", true);
    final JRadioButton showAncestor = new JRadioButton("Show ancestors");
    ButtonGroup bGroup = new ButtonGroup();
    bGroup.add(showDescendant);
    bGroup.add(showAncestor);
    showDescendant.addActionListener(this);
    showAncestor.addActionListener(this);
    showAncestor.setActionCommand(SHOW_ANCESTOR_CMD);
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(showDescendant);
    buttonPanel.add(showAncestor);

    // Construct the tree.
    tree = new GenealogyTree(getGenealogyGraph());
    JScrollPane scrollPane = new JScrollPane(tree);
    scrollPane.setPreferredSize(new Dimension(200, 200));

    // Add everything to this panel.
    add(buttonPanel, BorderLayout.PAGE_START);
    add(scrollPane, BorderLayout.CENTER);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:26,代碼來源:GenealogyExample.java

示例2: newRadio

import javax.swing.JRadioButton; //導入方法依賴的package包/類
public JRadioButton newRadio(ActionListener listener, ButtonGroup group) {
	JRadioButton button = new JRadioButton(name(), this == getDefault());
	button.setActionCommand(name());
	button.addActionListener(listener);
	group.add(button);
	return button;
}
 
開發者ID:cccssw,項目名稱:enigma-vk,代碼行數:8,代碼來源:ClassMatchingGui.java

示例3: addDPIDefaultVals

import javax.swing.JRadioButton; //導入方法依賴的package包/類
/**
 * Add a list of radio buttons, representing default, generally used, values
 * for the DPI.
 */
private void addDPIDefaultVals() {
    // set the layout of the panel, based on the amount of elements to be displayed on it
    jPDefaultValues.setLayout(new GridLayout(DPI_VALUES.length, 1));

    for (int index = 0; index < DPI_VALUES.length; index++) {
        String text = DPI_VALUES[index] + " DPI";

        // create a radio button with the given text
        JRadioButton jrbDPIValues = new JRadioButton(text);

        // set its action command to a number for easier usage later (to retrieve the value of the DPI)
        jrbDPIValues.setActionCommand(Integer.toString(DPI_VALUES[index]));

        // add action listener to synchronize the text field with the radio buttons
        jrbDPIValues.addActionListener(e -> jFTFDPIValue.setValue(Integer.parseInt(bgScreenDPIs.getSelection().getActionCommand())));

        // add mouse listener to display the help message when the mouse is on top of the radio buttons
        jrbDPIValues.addMouseListener(new java.awt.event.MouseAdapter() {
            @Override
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jPDefaultValuesMouseEntered(evt);
            }
        });

        jrbDPIValues.setBackground(Color.white);

        // add the radio button to the button group
        bgScreenDPIs.add(jrbDPIValues);

        // add the radio button to the panel displaying it
        jPDefaultValues.add(jrbDPIValues);

        // select the radio button which has the same value as the user preffered one (if any)
        if (DPI_VALUES[index] == userPreferences.getPreferredDPI()) {
            jrbDPIValues.setSelected(true);
            jFTFDPIValue.setValue(DPI_VALUES[index]);
        }
    }
}
 
開發者ID:buni-rock,項目名稱:Pixie,代碼行數:44,代碼來源:UserConfigs.java

示例4: radio

import javax.swing.JRadioButton; //導入方法依賴的package包/類
protected JRadioButton radio(String name)
{
    JRadioButton rb = new JRadioButton(name);
    rb.setActionCommand(name);
    radios.put(name, rb);
    buttonGroup.add(rb);
    return rb;
}
 
開發者ID:drytoastman,項目名稱:scorekeeperfrontend,代碼行數:9,代碼來源:BaseDialog.java

示例5: addModeButton

import javax.swing.JRadioButton; //導入方法依賴的package包/類
private void addModeButton(ButtonGroup group, JPanel panel, Mode mode)
{
    String label = mode.name().charAt(0) + mode.name().toLowerCase().substring(1);
    JRadioButton button = new JRadioButton(label);

    button.setActionCommand("MODE_" + mode.name());
    button.setSelected(mode == Mode.INI);
    panel.add(button);
    button.addActionListener(_actionListener);
    group.add(button);
}
 
開發者ID:JetBrains,項目名稱:intellij-deps-ini4j,代碼行數:12,代碼來源:Demo.java

示例6: initComponents

import javax.swing.JRadioButton; //導入方法依賴的package包/類
private void initComponents() {
	jrbOneShot = new JRadioButton("One Shot");
	jrbOneShot.setMnemonic(KeyEvent.VK_O);
	jrbOneShot.setActionCommand("One Shot");
	jrbOneShot.setSelected(true);
	jrbOneShot.addActionListener(this);
	
	jrbMonteCarlo = new JRadioButton("Monte-Carlo");
	jrbMonteCarlo.setMnemonic(KeyEvent.VK_M);
	jrbMonteCarlo.setActionCommand("Monte-Carlo");
	jrbMonteCarlo.addActionListener(this);
	
	buttonGroup = new ButtonGroup();
	buttonGroup.add(jrbOneShot); buttonGroup.add(jrbMonteCarlo);
	
	jlTimeUnits = new JLabel("Time units: ");
	jlMaxIterations = new JLabel("Max iterations: ");
	
	jlSelectExtensions = new JLabel("Select your report extension(s)");
	jcbExtensions = new ArrayList<JCheckBox>(6);
	jcbDocx = new JCheckBox("docx"); jcbExtensions.add(jcbDocx);
	jcbHtml = new JCheckBox("html"); jcbExtensions.add(jcbHtml);
	jcbPdf = new JCheckBox("pdf"); jcbExtensions.add(jcbPdf);
	jcbPptx = new JCheckBox("pptx"); jcbExtensions.add(jcbPptx);
	jcbOdt = new JCheckBox("odt"); jcbExtensions.add(jcbOdt);
	jcbXlsx = new JCheckBox("xlsx"); jcbExtensions.add(jcbXlsx);
	
	jcbPdf.setSelected(true);
	
	for(JCheckBox jcb : jcbExtensions) jcb.setEnabled(false);
	
	this.jlSelectModelingProject = new JLabel("Select your modeling project");
	this.jcbModelingProjects = new JComboBox<String>();
	
	// Retrieval of all user workspaces modeling projects
	for(String project : WorkspaceManager.getModelingProjects())
		this.jcbModelingProjects.addItem(project);
	this.jcbModelingProjects.setSelectedIndex(0);
	this.jcbModelingProjects.addActionListener(this);
	this.jcbModelingProjects.setEnabled(false);
	
	this.jlSelectReportTemplate = new JLabel("Select the report template you want to use");
	this.jcbReportTemplates = new JComboBox<String>();
	
	// Retrieval of all report templates of the selected project (the first one by default)
	for(String template : WorkspaceManager.getTemplates(this.jcbModelingProjects.getItemAt(0)))
		this.jcbReportTemplates.addItem(template);
	if(this.jcbReportTemplates.getModel().getSize() == 0)
		this.jcbReportTemplates.addItem("No report templates available !");
	this.jcbReportTemplates.setSelectedIndex(0);
	this.jcbReportTemplates.addActionListener(this);
	this.jcbReportTemplates.setEnabled(false);
	
	jtfTimeUnits = new JTextField("1000");
	PlainDocument docTimeUnits = (PlainDocument) jtfTimeUnits.getDocument();
    docTimeUnits.setDocumentFilter(new IntFilter());
    
    jtfMaxIterations = new JTextField("100");
    PlainDocument docMaxIterations = (PlainDocument) jtfMaxIterations.getDocument();
    docMaxIterations.setDocumentFilter(new IntFilter());
    // "One Shot" simulation selected by default
	jtfMaxIterations.setEnabled(false); 
    
	jtfTimeUnits.setColumns(5);
	jtfMaxIterations.setColumns(5);
	
	jbStart = new JButton("Start");
	jbStart.addActionListener(this);
	jbStop = new JButton("Stop");
	jbStop.addActionListener(this);
	jbStop.setEnabled(false);
	
	jpLoader = new PanelLoader("status bar", 100);
}
 
開發者ID:cetic,項目名稱:SimQRI,代碼行數:75,代碼來源:SimulationManagementWindow.java

示例7: BaseDialog

import javax.swing.JRadioButton; //導入方法依賴的package包/類
/**
 * Set up and show the dialog. The first Component argument determines which
 * frame the dialog depends on; it should be a component in the dialog's
 * controlling frame. The second Component argument should be null if you
 * want the dialog to come up with its left corner in the center of the
 * screen; otherwise, it should be the component on top of which the dialog
 * should appear.
 */

public BaseDialog(Component frameComp, Component locationComp,
		String title, I_TickerManager tickerManager) {
	super(JOptionPane.getFrameForComponent(frameComp), title, true);
	this.frameComp = frameComp;
	dateChooser = new JDateChooser(Calendar.getInstance().getTime());
	dateChooser.setLocale(new Locale("fi", "FI"));

	this.tickerManager = tickerManager;

	// Create and initialize the buttons.
	cancelButton = new JButton(BUTTON_CANCEL);
	cancelButton.addActionListener(this);
	cancelButton.setActionCommand(BUTTON_CANCEL);

	okButton = new JButton(BUTTON_OK);
	okButton.setActionCommand(BUTTON_OK);
	okButton.addActionListener(this);
	getRootPane().setDefaultButton(okButton);
	okButton.setEnabled(false);

	rateField = new JTextField(FIELD_LEN);
	rateField.setVisible(true);
	rateField.setText("1.0000");

	rateFieldLabel = new JLabel("Valuuttakurssi: ");
	rateFieldLabel.setLabelFor(rateField);
	rateFieldLabel.setVisible(true);

	localCurrencyButton = new JRadioButton(localCurrencyString);
	foreignCurrencyButton = new JRadioButton(foreignCurrencyString);
	currencyGroup = new ButtonGroup();

	localCurrencyButton.setActionCommand(localCurrencyString);
	foreignCurrencyButton.setActionCommand(foreignCurrencyString);
	localCurrencyButton.setSelected(true);
	currencyGroup.add(localCurrencyButton);
	currencyGroup.add(foreignCurrencyButton);
	updateRateFieldCcy("EUR", false);
	localCurrencyButton.addActionListener(this);
	foreignCurrencyButton.addActionListener(this);
	foreignCurrencyButton.setEnabled(false);
	
}
 
開發者ID:skarna1,項目名稱:javaportfolio,代碼行數:53,代碼來源:BaseDialog.java


注:本文中的javax.swing.JRadioButton.setActionCommand方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。