本文整理汇总了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);
}
示例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;
}
示例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]);
}
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}