本文整理匯總了Java中javax.swing.ButtonGroup類的典型用法代碼示例。如果您正苦於以下問題:Java ButtonGroup類的具體用法?Java ButtonGroup怎麽用?Java ButtonGroup使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ButtonGroup類屬於javax.swing包,在下文中一共展示了ButtonGroup類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: TelaBuscarVeiculo
import javax.swing.ButtonGroup; //導入依賴的package包/類
public TelaBuscarVeiculo() {
initComponents();
jtb_Veiculos.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
ButtonGroup group = new ButtonGroup();
group.add(jrb_Marca);
group.add(jrb_Modelo);
group.add(jrb_Ano);
group.add(jrb_MenorPreco);
group.add(jrb_MaiorPreco);
DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
centerRenderer.setHorizontalAlignment( JLabel.CENTER );
jtb_Veiculos.setDefaultRenderer(Object.class, centerRenderer);
}
示例2: setRadioButtons
import javax.swing.ButtonGroup; //導入依賴的package包/類
private void setRadioButtons()
{
int numeroScelte = progetto.scelteDomandaAttualeSize();
ArrayList<String> testoScelte = new ArrayList();
for(int i = 0; i < numeroScelte; i++)
testoScelte.add(progetto.mostraSceltaDomandaAttuale(i));
gruppo = new ButtonGroup();
for(int i = 0; i < numeroScelte; i++)
{
JRadioButton radio = new JRadioButton(testoScelte.get(i));
radio.setFont(fontScelta);
RadioButtonListener rbl = new RadioButtonListener(progetto);
radio.addActionListener(rbl);
gruppo.add(radio);
center.add(radio);
}
}
示例3: connect
import javax.swing.ButtonGroup; //導入依賴的package包/類
public void connect(PropertyEditor pe, PropertyEnv env) {
if (!tableUI && (env != null) && useTitle) {
setBorder(new TitledBorder(env.getFeatureDescriptor().getDisplayName()));
} else {
setBorder(null);
}
editor = pe;
String[] tags = editor.getTags();
group = new ButtonGroup();
InvRadioButton[] buttons = getButtons(tags.length);
if (env != null) {
setEnabled(env.isEditable());
}
for (int i = 0; i < tags.length; i++) {
InvRadioButton jr = buttons[i];
configureButton(jr, tags[i]);
add(jr);
}
}
示例4: MetalThemeMenu
import javax.swing.ButtonGroup; //導入依賴的package包/類
@SuppressWarnings("LeakingThisInConstructor")
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
super(name);
themes = themeArray;
ButtonGroup group = new ButtonGroup();
for (int i = 0; i < themes.length; i++) {
JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i].
getName());
group.add(item);
add(item);
item.setActionCommand(i + "");
item.addActionListener(this);
if (i == 0) {
item.setSelected(true);
}
}
}
示例5: getContextMenu
import javax.swing.ButtonGroup; //導入依賴的package包/類
/** Updates items in popup menu and returns itself.
*/
public JPopupMenu getContextMenu () {
removeAll ();
// generate list of available toolbar panels
ButtonGroup bg = new ButtonGroup ();
String current = ToolbarPool.getDefault ().getConfiguration ();
for( String name : ToolbarPool.getDefault().getConfigurationsNow() ) {
JRadioButtonMenuItem mi = new JRadioButtonMenuItem (name, (name.compareTo (current) == 0));
mi.addActionListener (this);
bg.add (mi);
this.add (mi);
}
return this;
}
示例6: buildViewMenu
import javax.swing.ButtonGroup; //導入依賴的package包/類
private void buildViewMenu() {
// --> View
JMenu menu = Utility.localizedMenu("menuBar.view");
menu.setOpaque(false);
menu.setMnemonic(KeyEvent.VK_V);
menu.add(getCheckBoxMenuItem(MapControlsAction.id));
menu.add(getCheckBoxMenuItem(DisplayGridAction.id));
menu.add(getCheckBoxMenuItem(ChangeWindowedModeAction.id));
menu.addSeparator();
ButtonGroup tileTextGroup = new ButtonGroup();
for (DisplayText type : DisplayText.values()) {
menu.add(getRadioButtonMenuItem(DisplayTileTextAction.id + type.getKey(),
tileTextGroup));
}
menu.addSeparator();
menu.add(getMenuItem(ZoomInAction.id));
menu.add(getMenuItem(ZoomOutAction.id));
add(menu);
}
示例7: getDefaultComponent
import javax.swing.ButtonGroup; //導入依賴的package包/類
public Component getDefaultComponent(Container aContainer) {
Component c = getFirstComponent(aContainer);
if (c instanceof AbstractButton) {
ButtonModel bm = ((AbstractButton)c).getModel();
if (bm instanceof DefaultButtonModel) {
ButtonGroup bg = ((DefaultButtonModel)bm).getGroup();
Enumeration<AbstractButton> en = bg == null ? null : bg.getElements();
while (en != null && en.hasMoreElements()) {
AbstractButton ab = en.nextElement();
if (ab.isSelected()) return ab;
}
}
}
return c;
}
示例8: initRadioButtons
import javax.swing.ButtonGroup; //導入依賴的package包/類
private void initRadioButtons() {
applicationDescButtonModel = new ToggleButtonModel();
appletDescButtonModel = new ToggleButtonModel();
compDescButtonModel = new ToggleButtonModel();
bg = new ButtonGroup();
applicationDescButtonModel.setGroup(bg);
appletDescButtonModel.setGroup(bg);
compDescButtonModel.setGroup(bg);
String desc = evaluator.getProperty(JNLP_DESCRIPTOR);
if (desc != null) {
if (desc.equals(DescType.application.toString())) {
applicationDescButtonModel.setSelected(true);
} else if (desc.equals(DescType.applet.toString())) {
appletDescButtonModel.setSelected(true);
} else if (desc.equals(DescType.component.toString())) {
compDescButtonModel.setSelected(true);
}
} else {
applicationDescButtonModel.setSelected(true);
}
}
示例9: createTypeMenu
import javax.swing.ButtonGroup; //導入依賴的package包/類
/**
* @return menu that allows to select possible column types
*/
private JMenu createTypeMenu() {
ButtonGroup typeGroup = new ButtonGroup();
JMenu typeChangeItem = new JMenu(CHANGE_TYPE_LABEL);
typeChangeItem.setToolTipText(CHANGE_TYPE_TIP);
for (final ColumnType columnType : ColumnType.values()) {
final JCheckBoxMenuItem checkboxItem = new JCheckBoxMenuItem(
DataImportWizardUtils.getNameForColumnType(columnType));
if (columnType == metaData.getColumnMetaData(columnIndex).getType()) {
checkboxItem.setSelected(true);
}
checkboxItem.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
changeType(columnType);
}
}
});
typeGroup.add(checkboxItem);
typeChangeItem.add(checkboxItem);
}
return typeChangeItem;
}
示例10: updatePerspectives
import javax.swing.ButtonGroup; //導入依賴的package包/類
private void updatePerspectives(List<Perspective> perspectives) {
removeAll();
perspectiveMap.clear();
workspaceMenuGroup = new ButtonGroup();
for (Perspective p : perspectives) {
String name = p.getName();
Action action = new WorkspaceAction(PerspectiveMenu.this.perspectiveController, p, name);
if (p.isUserDefined()) {
action.putValue(Action.ACTION_COMMAND_KEY, "perspective-" + name);
action.putValue(Action.NAME, name);
ImageIcon createIcon = SwingTools
.createIcon("16/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.workspace_user.icon"));
action.putValue(Action.LARGE_ICON_KEY, createIcon);
action.putValue(Action.SMALL_ICON, createIcon);
action.putValue(Action.SHORT_DESCRIPTION,
I18N.getMessage(I18N.getGUIBundle(), "gui.action.workspace_user.tip", name));
}
JMenuItem menuItem = new JRadioButtonMenuItem(action);
add(menuItem);
perspectiveMap.put(p.getName(), menuItem);
workspaceMenuGroup.add(menuItem);
}
if (perspectiveMap.containsKey(perspectiveName)) {
perspectiveMap.get(perspectiveName).setSelected(true);
}
}
示例11: getReplacemetPanel
import javax.swing.ButtonGroup; //導入依賴的package包/類
private Component getReplacemetPanel() {
JPanel group = new JPanel(new GridLayout(0, 1));
group.setBorder(BorderFactory.createTitledBorder(ResourceLoader
.getString("ArrowReplacementType.name")));
group.add(safe = new JRadioButton("ArrowReplacementType.safe"));
group.add(children = new JRadioButton("ArrowReplacementType.branching"));
group.add(all = new JRadioButton("ArrowReplacementType.everywhere"));
safe.setSelected(true);
ButtonGroup g = new ButtonGroup();
g.add(children);
g.add(all);
g.add(safe);
setReplaceEnable(false);
return group;
}
示例12: createButtons
import javax.swing.ButtonGroup; //導入依賴的package包/類
@Override
protected void createButtons(ButtonGroup group) {
JToggleButton button1 = createOpenViewButton(group, editorView);
button1.setSelected(true);
buttonsPanel.add(button1);
buttonsPanel.add(createOpenViewButton(group, htmlView));
Iterator<DocBookExporter> iterator = AdditionalPluginLoader
.loadProviders(DocBookExporter.class);
while (iterator.hasNext()) {
final DocBookExporter exporter = iterator.next();
JButton tb = new JButton();
tb.setText(exporter.getActionName());
tb.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
exporter.createReport(getFramework(),
new ReportLoadCallback() {
@Override
public InputStream getDocBookInputStream() {
// TODO Auto-generated method stub
return null;
}
});
}
});
buttonsPanel.add(tb);
}
}
示例13: initSave
import javax.swing.ButtonGroup; //導入依賴的package包/類
void initSave() {
savePanel = new JPanel(new GridLayout(0,1));
savePanel.setBorder( BorderFactory.createTitledBorder("Save Options"));
ButtonGroup gp = new ButtonGroup();
saveToFile = new JToggleButton("Save ASCII table");
savePanel.add( saveToFile );
gp.add( saveToFile );
saveToClipboard = new JToggleButton("Copy to clipboard");
savePanel.add( saveToClipboard );
gp.add( saveToClipboard );
saveJPEG = new JToggleButton("Save JPEG image");
savePanel.add( saveJPEG );
gp.add( saveJPEG );
savePNG = new JToggleButton("Save PNG image");
savePanel.add( savePNG );
gp.add( savePNG );
print = new JToggleButton("Print");
savePanel.add( print );
gp.add( print );
}
示例14: PrintIconRadioJButton
import javax.swing.ButtonGroup; //導入依賴的package包/類
public PrintIconRadioJButton( ControlJFrame objPcontrolJFrame,
String strPkey,
String strPimage,
boolean bolPselected,
ButtonGroup objPbuttonGroup,
ActionListener objPactionListener) {
// Create widgets :
this.objGjLabel =
new ExtendedJLabel(objPcontrolJFrame, objPcontrolJFrame .getJuggleMasterPro()
.getImageIcon(strPimage, Constants.bytS_UNCLASS_NO_VALUE));
this.objGjRadioButton = new JRadioButton(Tools.getLocaleString(strPkey));
this.objGjRadioButton.setFont(objPcontrolJFrame.getFont());
this.objGjRadioButton.setOpaque(true);
this.objGjRadioButton.setMnemonic(Tools.getMnemonicChar(strPkey));
this.objGjRadioButton.addActionListener(objPactionListener);
this.objGjRadioButton.setSelected(bolPselected);
objPbuttonGroup.add(this.objGjRadioButton);
// Add widgets :
this.setLayout(new FlowLayout(FlowLayout.LEADING));
this.add(this.objGjLabel);
this.add(this.objGjRadioButton);
this.setOpaque(true);
}
示例15: getPanel
import javax.swing.ButtonGroup; //導入依賴的package包/類
@Override
public IPanel getPanel(final int i) {
if ((i == 0) && (!modelTypeAdded)) {
ButtonGroup bg = new ButtonGroup();
idef0.setSelected(true);
bg.add(idef0);
bg.add(dfd);
bg.add(dfds);
JPanel jPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
jPanel.add(idef0);
jPanel.add(dfd);
jPanel.add(dfds);
JPanel panel = (JPanel) super.getPanel(i);
panel.add(jPanel, BorderLayout.SOUTH);
modelTypeAdded = true;
}
if (super.getPanelCount() == i) {
return ouners;
}
return super.getPanel(i);
}