List of usage examples for javax.swing ButtonGroup ButtonGroup
public ButtonGroup()
ButtonGroup
. From source file:net.sf.jabref.external.DroppedFileHandler.java
public DroppedFileHandler(JabRefFrame frame, BasePanel panel) { this.frame = frame; this.panel = panel; ButtonGroup grp = new ButtonGroup(); grp.add(linkInPlace);// ww w . ja v a2s . c o m grp.add(copyRadioButton); grp.add(moveRadioButton); FormLayout layout = new FormLayout("left:15dlu,pref,pref,pref", "bottom:14pt,pref,pref,pref,pref"); layout.setRowGroups(new int[][] { { 1, 2, 3, 4, 5 } }); FormBuilder builder = FormBuilder.create().layout(layout); builder.add(linkInPlace).xyw(1, 1, 4); builder.add(destDirLabel).xyw(1, 2, 4); builder.add(copyRadioButton).xyw(2, 3, 3); builder.add(moveRadioButton).xyw(2, 4, 3); builder.add(renameCheckBox).xyw(2, 5, 1); builder.add(renameToTextBox).xyw(4, 5, 1); optionsPanel.add(builder.getPanel()); }
From source file:RenderQualityTest.java
/** * Makes a set of buttons for a rendering hint key and values * /*from w ww.jav a 2s . c om*/ * @param key * the key name * @param value1 * the name of the first value for the key * @param value2 * the name of the second value for the key */ void makeButtons(String key, String value1, String value2) { try { final RenderingHints.Key k = (RenderingHints.Key) RenderingHints.class.getField(key).get(null); final Object v1 = RenderingHints.class.getField(value1).get(null); final Object v2 = RenderingHints.class.getField(value2).get(null); JLabel label = new JLabel(key); buttonBox.add(label, new GBC(0, r).setAnchor(GBC.WEST)); ButtonGroup group = new ButtonGroup(); JRadioButton b1 = new JRadioButton(value1, true); buttonBox.add(b1, new GBC(1, r).setAnchor(GBC.WEST)); group.add(b1); b1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { hints.put(k, v1); canvas.setRenderingHints(hints); } }); JRadioButton b2 = new JRadioButton(value2, false); buttonBox.add(b2, new GBC(2, r).setAnchor(GBC.WEST)); group.add(b2); b2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { hints.put(k, v2); canvas.setRenderingHints(hints); } }); hints.put(k, v1); r++; } catch (Exception e) { e.printStackTrace(); } }
From source file:org.broad.igv.peaks.PeakTrackMenu.java
public void addDisplayModeItems() { addSeparator();/*from ww w . j a v a 2 s . c o m*/ ButtonGroup group = new ButtonGroup(); Track.DisplayMode displayMode = track.getDisplayMode(); JRadioButtonMenuItem m1 = new JRadioButtonMenuItem("Compressed"); m1.setSelected(displayMode == Track.DisplayMode.COLLAPSED); m1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { track.setDisplayMode(Track.DisplayMode.COLLAPSED); IGV.getInstance().doRefresh(); } }); JRadioButtonMenuItem m3 = new JRadioButtonMenuItem("Time Series"); m3.setSelected(displayMode == Track.DisplayMode.EXPANDED); m3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { track.setDisplayMode(Track.DisplayMode.EXPANDED); IGV.getInstance().doRefresh(); } }); add(m1); add(m3); group.add(m1); group.add(m3); }
From source file:REDemo.java
/** Construct the REDemo object including its GUI */ public REDemo() { super();//from w w w. j a v a2s.c o m JPanel top = new JPanel(); top.add(new JLabel("Pattern:", JLabel.RIGHT)); patternTF = new JTextField(20); patternTF.getDocument().addDocumentListener(new PatternListener()); top.add(patternTF); top.add(new JLabel("Syntax OK?")); compiledOK = new JCheckBox(); top.add(compiledOK); ChangeListener cl = new ChangeListener() { public void stateChanged(ChangeEvent ce) { tryMatch(); } }; JPanel switchPane = new JPanel(); ButtonGroup bg = new ButtonGroup(); match = new JRadioButton("Match"); match.setSelected(true); match.addChangeListener(cl); bg.add(match); switchPane.add(match); find = new JRadioButton("Find"); find.addChangeListener(cl); bg.add(find); switchPane.add(find); findAll = new JRadioButton("Find All"); findAll.addChangeListener(cl); bg.add(findAll); switchPane.add(findAll); JPanel strPane = new JPanel(); strPane.add(new JLabel("String:", JLabel.RIGHT)); stringTF = new JTextField(20); stringTF.getDocument().addDocumentListener(new StringListener()); strPane.add(stringTF); strPane.add(new JLabel("Matches:")); matchesTF = new JTextField(3); strPane.add(matchesTF); setLayout(new GridLayout(0, 1, 5, 5)); add(top); add(strPane); add(switchPane); }
From source file:com.floreantpos.ui.views.LoginPasswordEntryView.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor./*from w ww . j a v a 2 s . c o m*/ */ // <editor-fold defaultstate="collapsed" // desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { buttonPanel = new javax.swing.JPanel(); bottomPanel = new javax.swing.JPanel(); btnShutdown = new com.floreantpos.swing.PosButton(); setPreferredSize(new Dimension(320, 593)); setLayout(new BorderLayout()); buttonPanel.setOpaque(false); buttonPanel.setPreferredSize(new java.awt.Dimension(200, 180)); buttonPanel.setLayout(new MigLayout("", "[111px][111px][111px,grow]", "[60px][60px][60px][60px]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ lblTerminalId = new JLabel("TERMINAL ID:"); //$NON-NLS-1$ lblTerminalId.setForeground(Color.BLACK); lblTerminalId.setFont(new Font("Dialog", Font.BOLD, 18)); //$NON-NLS-1$ lblTerminalId.setHorizontalAlignment(SwingConstants.CENTER); add(lblTerminalId, BorderLayout.NORTH); bottomPanel.setLayout(new MigLayout("hidemode 3, fill")); //$NON-NLS-1$ bottomPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(btnRegularMode); //buttonGroup.add(btnCashierMode); buttonGroup.add(btnKitchenMode); btnRegularMode.setFocusable(false); // btnCashierMode.setFocusable(false); btnKitchenMode.setFocusable(false); ModeSelectionListener l = new ModeSelectionListener(); btnRegularMode.addActionListener(l); // btnCashierMode.addActionListener(l); btnKitchenMode.addActionListener(l); btnRegularMode.setSelected(TerminalConfig.isRegularMode()); // btnCashierMode.setSelected(TerminalConfig.isCashierMode()); btnKitchenMode.setSelected(TerminalConfig.isKitchenMode()); if (!btnRegularMode.isSelected() && !btnKitchenMode.isSelected()) { btnRegularMode.setSelected(true); } JPanel modePanel = new JPanel(new GridLayout(1, 0, 2, 2)); modePanel.add(btnRegularMode); // modePanel.add(btnCashierMode); modePanel.add(btnKitchenMode); bottomPanel.add(modePanel, "h 60!, grow, wrap"); //$NON-NLS-1$ psbtnLogin = new PosButton(); psbtnLogin.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doLogin(); } }); psbtnLogin.setText("LOGIN"); //$NON-NLS-1$ bottomPanel.add(psbtnLogin, "grow, wrap, gapbottom 20px"); //$NON-NLS-1$ PosButton btnClockOUt = new PosButton(new ClockInOutAction(false, true)); bottomPanel.add(btnClockOUt, "grow, wrap, h 60!"); //$NON-NLS-1$ if (TerminalConfig.isShowDbConfigureButton()) { btnConfigureDatabase = new com.floreantpos.swing.PosButton(); btnConfigureDatabase.setAction(goAction); btnConfigureDatabase.setText(com.floreantpos.POSConstants.CONFIGURE_DATABASE); btnConfigureDatabase.setFocusable(false); btnConfigureDatabase.setActionCommand("DBCONFIG"); //$NON-NLS-1$ bottomPanel.add(btnConfigureDatabase, "grow, wrap, h 60!"); //$NON-NLS-1$ } btnShutdown.setAction(goAction); btnShutdown.setText(com.floreantpos.POSConstants.SHUTDOWN); btnShutdown.setFocusable(false); if (TerminalConfig.isFullscreenMode()) { if (btnConfigureDatabase != null) { btnConfigureDatabase.setVisible(false); } if (btnShutdown != null) { btnShutdown.setVisible(false); } } bottomPanel.add(btnShutdown, "grow, wrap, h 60!"); //$NON-NLS-1$ add(bottomPanel, BorderLayout.SOUTH); lblTerminalId.setText(""); //$NON-NLS-1$ }
From source file:components.MenuSelectionManagerDemo.java
public JMenuBar createMenuBar() { JMenuBar menuBar;//from w w w . ja v a2 s . c o m JMenu menu, submenu; JMenuItem menuItem; JRadioButtonMenuItem rbMenuItem; JCheckBoxMenuItem cbMenuItem; //Create the menu bar. menuBar = new JMenuBar(); //Build the first menu. menu = new JMenu("A Menu"); menu.setMnemonic(KeyEvent.VK_A); menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items"); menuBar.add(menu); //a group of JMenuItems menuItem = new JMenuItem("A text-only menu item", KeyEvent.VK_T); //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("This doesn't really do anything"); menuItem.addActionListener(this); menu.add(menuItem); ImageIcon icon = createImageIcon("images/middle.gif"); menuItem = new JMenuItem("Both text and icon", icon); menuItem.setMnemonic(KeyEvent.VK_B); menuItem.addActionListener(this); menu.add(menuItem); menuItem = new JMenuItem(icon); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(this); menu.add(menuItem); //a group of radio button menu items menu.addSeparator(); ButtonGroup group = new ButtonGroup(); rbMenuItem = new JRadioButtonMenuItem("A radio button menu item"); rbMenuItem.setSelected(true); rbMenuItem.setMnemonic(KeyEvent.VK_R); group.add(rbMenuItem); rbMenuItem.addActionListener(this); menu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem("Another one"); rbMenuItem.setMnemonic(KeyEvent.VK_O); group.add(rbMenuItem); rbMenuItem.addActionListener(this); menu.add(rbMenuItem); //a group of check box menu items menu.addSeparator(); cbMenuItem = new JCheckBoxMenuItem("A check box menu item"); cbMenuItem.setMnemonic(KeyEvent.VK_C); cbMenuItem.addItemListener(this); menu.add(cbMenuItem); cbMenuItem = new JCheckBoxMenuItem("Another one"); cbMenuItem.setMnemonic(KeyEvent.VK_H); cbMenuItem.addItemListener(this); menu.add(cbMenuItem); //a submenu menu.addSeparator(); submenu = new JMenu("A submenu"); submenu.setMnemonic(KeyEvent.VK_S); menuItem = new JMenuItem("An item in the submenu"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, ActionEvent.ALT_MASK)); menuItem.addActionListener(this); submenu.add(menuItem); menuItem = new JMenuItem("Another item"); menuItem.addActionListener(this); submenu.add(menuItem); menu.add(submenu); //Build second menu in the menu bar. menu = new JMenu("Another Menu"); menu.setMnemonic(KeyEvent.VK_N); menu.getAccessibleContext().setAccessibleDescription("This menu does nothing"); menuBar.add(menu); Timer timer = new Timer(ONE_SECOND, new ActionListener() { public void actionPerformed(ActionEvent evt) { MenuElement[] path = MenuSelectionManager.defaultManager().getSelectedPath(); for (int i = 0; i < path.length; i++) { if (path[i].getComponent() instanceof javax.swing.JMenuItem) { JMenuItem mi = (JMenuItem) path[i].getComponent(); if ("".equals(mi.getText())) { output.append("ICON-ONLY MENU ITEM > "); } else { output.append(mi.getText() + " > "); } } } if (path.length > 0) output.append(newline); } }); timer.start(); return menuBar; }
From source file:ca.phon.app.session.editor.view.media_player.PlayCustomSegmentDialog.java
private void init() { final FormLayout layout = new FormLayout("10dlu, fill:pref:grow", "pref, pref, pref, pref, pref, pref, pref, pref, pref, pref"); final CellConstraints cc = new CellConstraints(); setLayout(layout);//from w w w . ja v a 2s . co m final SessionEditor editor = editorRef.get(); final Session session = editor.getSession(); btnGrp = new ButtonGroup(); currentSegmentBtn = new JRadioButton("Current segment"); currentSegmentBtn.addActionListener(radioListener); currentSegmentBtn.setSelected(true); btnGrp.add(currentSegmentBtn); contiguousSegmentBtn = new JRadioButton("Speaker turn"); contiguousSegmentBtn.addActionListener(radioListener); btnGrp.add(contiguousSegmentBtn); // periodBtn = new JRadioButton("Adjacency sequence"); // periodBtn.addActionListener(radioListener); // btnGrp.add(periodBtn); recordRangeBtn = new JRadioButton("Record range"); recordRangeBtn.addActionListener(radioListener); btnGrp.add(recordRangeBtn); rangeField = new JTextField(); rangeField.setText((editor.getCurrentRecordIndex() + 1) + ".." + (editor.getCurrentRecordIndex() + 1)); rangeField.setInputVerifier(new RangeVerifier()); rangeField.setEnabled(false); rangeField.getDocument().addDocumentListener(rangeListener); segmentTimeBtn = new JRadioButton("Time range"); segmentTimeBtn.addActionListener(radioListener); btnGrp.add(segmentTimeBtn); segmentField = new MediaSegmentField(); segmentField.setEnabled(false); updateSegmentTimes(); final DialogHeader header = new DialogHeader("Play Custom Segment", "Play a custom defined segment"); add(header, cc.xyw(1, 1, 2)); add(currentSegmentBtn, cc.xyw(1, 2, 2)); add(contiguousSegmentBtn, cc.xyw(1, 3, 2)); // add(periodBtn, cc.xyw(1, 4, 2)); add(recordRangeBtn, cc.xyw(1, 5, 2)); add(rangeField, cc.xy(2, 6)); add(segmentTimeBtn, cc.xyw(1, 7, 2)); add(segmentField, cc.xy(2, 8)); final ImageIcon playIcon = IconManager.getInstance().getIcon("actions/media-playback-start", IconSize.SMALL); final ImageIcon cancelIcon = IconManager.getInstance().getIcon("actions/button_cancel", IconSize.SMALL); final PhonUIAction playAct = new PhonUIAction(this, "onPlay"); playAct.putValue(PhonUIAction.NAME, "Play"); playAct.putValue(PhonUIAction.SHORT_DESCRIPTION, "Play segment"); playAct.putValue(PhonUIAction.SMALL_ICON, playIcon); playBtn = new JButton(playAct); final PhonUIAction cancelAct = new PhonUIAction(this, "onCancel"); cancelAct.putValue(PhonUIAction.NAME, "Close"); cancelAct.putValue(PhonUIAction.SMALL_ICON, cancelIcon); cancelBtn = new JButton(cancelAct); final JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); btnPanel.add(cancelBtn); btnPanel.add(playBtn); add(btnPanel, cc.xyw(1, 9, 2)); }
From source file:MenuDemo.java
public JMenuBar createMenuBar() { JMenuBar menuBar;/*from www .j ava2 s.c om*/ JMenu menu, submenu; JMenuItem menuItem; JRadioButtonMenuItem rbMenuItem; JCheckBoxMenuItem cbMenuItem; //Create the menu bar. menuBar = new JMenuBar(); //Build the first menu. menu = new JMenu("A Menu"); menu.setMnemonic(KeyEvent.VK_A); menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items"); menuBar.add(menu); //a group of JMenuItems menuItem = new JMenuItem("A text-only menu item", KeyEvent.VK_T); //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("This doesn't really do anything"); menuItem.addActionListener(this); menu.add(menuItem); ImageIcon icon = createImageIcon("images/1.gif"); menuItem = new JMenuItem("Both text and icon", icon); menuItem.setMnemonic(KeyEvent.VK_B); menuItem.addActionListener(this); menu.add(menuItem); menuItem = new JMenuItem(icon); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(this); menu.add(menuItem); //a group of radio button menu items menu.addSeparator(); ButtonGroup group = new ButtonGroup(); rbMenuItem = new JRadioButtonMenuItem("A radio button menu item"); rbMenuItem.setSelected(true); rbMenuItem.setMnemonic(KeyEvent.VK_R); group.add(rbMenuItem); rbMenuItem.addActionListener(this); menu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem("Another one"); rbMenuItem.setMnemonic(KeyEvent.VK_O); group.add(rbMenuItem); rbMenuItem.addActionListener(this); menu.add(rbMenuItem); //a group of check box menu items menu.addSeparator(); cbMenuItem = new JCheckBoxMenuItem("A check box menu item"); cbMenuItem.setMnemonic(KeyEvent.VK_C); cbMenuItem.addItemListener(this); menu.add(cbMenuItem); cbMenuItem = new JCheckBoxMenuItem("Another one"); cbMenuItem.setMnemonic(KeyEvent.VK_H); cbMenuItem.addItemListener(this); menu.add(cbMenuItem); //a submenu menu.addSeparator(); submenu = new JMenu("A submenu"); submenu.setMnemonic(KeyEvent.VK_S); menuItem = new JMenuItem("An item in the submenu"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, ActionEvent.ALT_MASK)); menuItem.addActionListener(this); submenu.add(menuItem); menuItem = new JMenuItem("Another item"); menuItem.addActionListener(this); submenu.add(menuItem); menu.add(submenu); //Build second menu in the menu bar. menu = new JMenu("Another Menu"); menu.setMnemonic(KeyEvent.VK_N); menu.getAccessibleContext().setAccessibleDescription("This menu does nothing"); menuBar.add(menu); return menuBar; }
From source file:algorithm.MetsSubmissionInformationPackage.java
private void createConfigurationPanel() { panel = new GUIPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0;/* w w w.ja v a2s.c o m*/ constraints.gridy = 0; constraints.anchor = GridBagConstraints.NORTHWEST; panel.add(new JLabel("<html><h2>Add information to mets file</h2></html>"), constraints); constraints.gridy++; panel.add(new JLabel("Add person: "), constraints); constraints.gridx++; ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(truePersonButton); panel.add(truePersonButton, constraints); constraints.gridx++; buttonGroup.add(falsePersonButton); falsePersonButton.setSelected(true); panel.add(falsePersonButton, constraints); constraints.gridy++; constraints.gridx = 0; panel.add(new JLabel("Name:"), constraints); constraints.gridx++; constraints.gridwidth = 2; panel.add(personField, constraints); constraints.gridwidth = 1; constraints.gridx = 0; constraints.gridy++; panel.add(new JLabel("Choose archiving technique:"), constraints); constraints.gridx++; ButtonGroup archivingGroup = new ButtonGroup(); archivingGroup.add(tarButton); archivingGroup.add(zipButton); zipButton.setSelected(true); panel.add(zipButton, constraints); constraints.gridy++; panel.add(tarButton, constraints); constraints.gridx = 0; constraints.gridy++; }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.generic.GenericDRInputController.java
@Override protected void initDRInputPanel() { dRInputPanel = new DRInputPanel(); conditionsList = new ArrayList<>(); // control opaque property of bottom table dRInputPanel.getSlopesTableScrollPane().getViewport().setBackground(Color.white); slopesTable = dRInputPanel.getSlopesTable(); slopesTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT)); slopesTable.getTableHeader().setReorderingAllowed(false); slopesTable.setFillsViewportHeight(true); slopesTable.setModel(new NonEditableTableModel()); //create a ButtonGroup for the radioButtons used for analysis ButtonGroup experimentTypeRadioButtonGroup = new ButtonGroup(); //adding buttons to a ButtonGroup automatically deselect one when another one gets selected experimentTypeRadioButtonGroup.add(dRInputPanel.getStimulationRadioButton()); experimentTypeRadioButtonGroup.add(dRInputPanel.getInhibitionRadioButton()); //select as default first button (Stimulation) dRInputPanel.getStimulationRadioButton().setSelected(true); /*//w ww .j a v a 2s. com * Action listeners for buttons */ dRInputPanel.getAddConditionButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //add selected condition to analysis addToDRAnalysis(); } }); dRInputPanel.getRemoveConditionButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // remove condition from analysis removeFromDRAnalysis(); } }); /** * Choosing stimulation or inhibition type experiment defines standard * hillslope parameter */ dRInputPanel.getStimulationRadioButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doseResponseController.setStandardHillslope(1); } }); dRInputPanel.getInhibitionRadioButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doseResponseController.setStandardHillslope(-1); } }); }