List of usage examples for javax.swing ButtonGroup add
public void add(AbstractButton b)
From source file:ScrollDemo2.java
public void init() { JRadioButton form[][] = new JRadioButton[12][5]; String counts[] = { "", "0-1", "2-5", "6-10", "11-100", "101+" }; String categories[] = { "Household", "Office", "Extended Family", "Company (US)", "Company (World)", "Team", "Will", "Birthday Card List", "High School", "Country", "Continent", "Planet" }; JPanel p = new JPanel(); p.setSize(600, 400);//from ww w. ja v a 2 s .co m p.setLayout(new GridLayout(13, 6, 10, 0)); for (int row = 0; row < 13; row++) { ButtonGroup bg = new ButtonGroup(); for (int col = 0; col < 6; col++) { if (row == 0) { p.add(new JLabel(counts[col])); } else { if (col == 0) { p.add(new JLabel(categories[row - 1])); } else { form[row - 1][col - 1] = new JRadioButton(); bg.add(form[row - 1][col - 1]); p.add(form[row - 1][col - 1]); } } } } scrollpane = new JScrollPane(p); // Add in some JViewports for the column and row headers JViewport jv1 = new JViewport(); jv1.setView(new JLabel(new ImageIcon("columnlabel.gif"))); scrollpane.setColumnHeader(jv1); JViewport jv2 = new JViewport(); jv2.setView(new JLabel(new ImageIcon("rowlabel.gif"))); scrollpane.setRowHeader(jv2); // And throw in an information button JButton jb1 = new JButton(new ImageIcon("question.gif")); jb1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { JOptionPane.showMessageDialog(null, "This is an Active Corner!", "Information", JOptionPane.INFORMATION_MESSAGE); } }); scrollpane.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, jb1); getContentPane().add(scrollpane, BorderLayout.CENTER); }
From source file:GenealogyExample.java
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);/*from w w w. java2 s .co m*/ 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); }
From source file:components.MenuSelectionManagerDemo.java
public JMenuBar createMenuBar() { JMenuBar menuBar;/* ww w .j a v a 2 s. co 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:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.GlobalViewConditionController.java
/** * Initialize plot options panel.// www.j ava 2 s .co m */ private void initPlotOptionsPanel() { // make new view plotOptionsPanel = new PlotOptionsPanel(); // add radiobuttons to a button group ButtonGroup scaleAxesButtonGroup = new ButtonGroup(); scaleAxesButtonGroup.add(plotOptionsPanel.getDoNotScaleAxesRadioButton()); scaleAxesButtonGroup.add(plotOptionsPanel.getScaleAxesRadioButton()); plotOptionsPanel.getDoNotScaleAxesRadioButton().setSelected(true); // another button group for the shifted/unshifted coordinates ButtonGroup shiftedCoordinatesButtonGroup = new ButtonGroup(); shiftedCoordinatesButtonGroup.add(plotOptionsPanel.getShiftedCoordinatesRadioButton()); shiftedCoordinatesButtonGroup.add(plotOptionsPanel.getUnshiftedCoordinatesRadioButton()); plotOptionsPanel.getUnshiftedCoordinatesRadioButton().setSelected(true); /** * Action listeners */ // do not scale axes plotOptionsPanel.getDoNotScaleAxesRadioButton().addActionListener((ActionEvent e) -> { int nCols = Integer.parseInt((String) plotOptionsPanel.getnColsComboBox().getSelectedItem()); boolean useRawData = plotOptionsPanel.getUnshiftedCoordinatesRadioButton().isSelected(); resetPlotLogic(); generateTrackDataHolders(trackCoordinatesController.getCurrentCondition()); generateDataForPlots(useRawData); // use the data to set the charts setChartsWithCollections(nCols); }); // scale axes to the experiment range plotOptionsPanel.getScaleAxesRadioButton().addActionListener((ActionEvent e) -> { boolean useRawData = plotOptionsPanel.getUnshiftedCoordinatesRadioButton().isSelected(); coordinatesChartPanels.stream().forEach((chartPanel) -> { trackCoordinatesController.scaleAxesToExperiment(chartPanel.getChart(), useRawData); }); }); // shift the all coordinates to the origin plotOptionsPanel.getShiftedCoordinatesRadioButton().addActionListener((ActionEvent e) -> { int nCols = Integer.parseInt((String) plotOptionsPanel.getnColsComboBox().getSelectedItem()); resetPlotLogic(); generateTrackDataHolders(trackCoordinatesController.getCurrentCondition()); generateDataForPlots(false); // use the data to set the charts setChartsWithCollections(nCols); }); // replot the unshifted coordinates plotOptionsPanel.getUnshiftedCoordinatesRadioButton().addActionListener((ActionEvent e) -> { int nCols = Integer.parseInt((String) plotOptionsPanel.getnColsComboBox().getSelectedItem()); resetPlotLogic(); generateTrackDataHolders(trackCoordinatesController.getCurrentCondition()); generateDataForPlots(true); // use the data to set the charts setChartsWithCollections(nCols); }); // replot with a different number of columns plotOptionsPanel.getnColsComboBox().addActionListener((ActionEvent e) -> { int nCols = Integer.parseInt((String) plotOptionsPanel.getnColsComboBox().getSelectedItem()); boolean useRawData = plotOptionsPanel.getUnshiftedCoordinatesRadioButton().isSelected(); resetPlotLogic(); generateTrackDataHolders(trackCoordinatesController.getCurrentCondition()); generateDataForPlots(useRawData); // use the data to set the charts setChartsWithCollections(nCols); }); plotOptionsPanel.getPlotSettingsPanel().add(plotSettingsMenuBar, BorderLayout.CENTER); // add view to parent component trackCoordinatesController.getTrackCoordinatesPanel().getOptionsConditionParentPanel().add(plotOptionsPanel, gridBagConstraints); }
From source file:ca.phon.app.query.SaveQueryDialog.java
private void init() { // final PathExpander pe = new PathExpander(); nameField = new JTextField(); nameField.getDocument().addDocumentListener(new DocumentListener() { @Override//from www.java2 s. c o m public void insertUpdate(DocumentEvent de) { updateLocationFields(); } @Override public void removeUpdate(DocumentEvent de) { updateLocationFields(); } @Override public void changedUpdate(DocumentEvent de) { updateLocationFields(); } }); includeFormOptionsBox = new JCheckBox("Include current form settings"); includeFormOptionsBox.setSelected(true); ButtonGroup btnGrp = new ButtonGroup(); saveInProjectBtn = new JRadioButton("Save in project resources"); btnGrp.add(saveInProjectBtn); saveInUserDirBtn = new JRadioButton("Save in user library"); btnGrp.add(saveInUserDirBtn); saveOtherBtn = new JRadioButton("Save in another location..."); btnGrp.add(saveOtherBtn); saveInUserDirBtn.setSelected(true); projSaveLocField = new JLabel(); // projSaveLocField.setFont(projSaveLocField.getFont().deriveFont(10.0f)); libSaveLocField = new JLabel(); // libSaveLocField.setFont(libSaveLocField.getFont().deriveFont(10.0f)); updateLocationFields(); saveBtn = new JButton("Save"); saveBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { save(); } }); super.getRootPane().setDefaultButton(saveBtn); cancelBtn = new JButton("Cancel"); cancelBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { setVisible(false); } }); final DialogHeader header = new DialogHeader("Save Query", ""); JComponent btnBar = ButtonBarBuilder.buildOkCancelBar(saveBtn, cancelBtn); final FormLayout formLayout = new FormLayout("3dlu, 12dlu, fill:pref:grow, 3dlu", "pref, pref, pref, pref, pref, pref, pref, pref, pref, pref"); final CellConstraints cc = new CellConstraints(); setLayout(formLayout); add(header, cc.xyw(2, 1, 2)); add(new JLabel("Name: (without extension)"), cc.xyw(2, 2, 2)); add(nameField, cc.xy(3, 3)); add(includeFormOptionsBox, cc.xy(3, 4)); add(saveInUserDirBtn, cc.xyw(2, 5, 2)); // add(libSaveLocField, cc.xy(3, 6)); add(saveInProjectBtn, cc.xyw(2, 7, 2)); // add(projSaveLocField, cc.xy(3, 8)); add(saveOtherBtn, cc.xyw(2, 9, 2)); add(btnBar, cc.xyw(2, 10, 2)); }
From source file:RenderQualityTest.java
/** * Makes a set of buttons for a rendering hint key and values * //from w w w. j a va 2 s. c o m * @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:carolina.pegaLatLong.LatLong.java
private void btnGerarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGerarActionPerformed // TODO add your handling code here: List<JRadioButton> radios = new ArrayList<>(); JPanel painel = new JPanel(); JRadioButton btnEncontrados = new JRadioButton("Encontrados \n"); JRadioButton btnNaoEncontrados = new JRadioButton("No encontrados"); JRadioButton btnEncontradosMais = new JRadioButton("Mais de um encontrados"); JRadioButton btnTudo = new JRadioButton("Tudo"); ButtonGroup btnGroup = new ButtonGroup(); btnGroup.add(btnTudo); btnGroup.add(btnEncontrados);/* ww w .ja v a2s.co m*/ btnGroup.add(btnNaoEncontrados); btnGroup.add(btnEncontradosMais); //painel.add(btnTudo); painel.add(btnEncontrados); painel.add(btnNaoEncontrados); painel.add(btnEncontradosMais); JOptionPane.showMessageDialog(null, painel, "Escolha uma opo:", JOptionPane.QUESTION_MESSAGE); if (btnTudo.isSelected()) { System.err.println("Tudo selecionado!"); } else if (btnNaoEncontrados.isSelected()) { System.err.println("No encontrados!"); } else if (btnEncontrados.isSelected()) { try { geraCsv(listaResultado); } catch (IOException ex) { Logger.getLogger(LatLong.class.getName()).log(Level.SEVERE, null, ex); } } else if (btnEncontradosMais.isSelected()) { System.err.println("Encontrados mais"); } }
From source file:MenuSelectionManagerDemo.java
public JMenuBar createMenuBar() { JMenuBar menuBar;/*from www. jav a 2s . 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("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); 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:au.org.ala.delta.intkey.ui.FindInTaxaDialog.java
public FindInTaxaDialog(Intkey intkeyApp) { super(intkeyApp.getMainFrame(), false); setResizable(false);//from ww w. ja v a 2s . com ResourceMap resourceMap = Application.getInstance().getContext().getResourceMap(FindInTaxaDialog.class); resourceMap.injectFields(this); ActionMap actionMap = Application.getInstance().getContext().getActionMap(this); _intkeyApp = intkeyApp; _numMatchedTaxa = 0; _currentMatchedTaxon = -1; _findAction = actionMap.get("findTaxa"); _nextAction = actionMap.get("nextFoundTaxon"); this.setTitle(windowTitle); getContentPane().setLayout(new BorderLayout(0, 0)); _pnlMain = new JPanel(); _pnlMain.setBorder(new EmptyBorder(20, 20, 20, 20)); getContentPane().add(_pnlMain, BorderLayout.CENTER); _pnlMain.setLayout(new BorderLayout(0, 0)); _pnlMainTop = new JPanel(); _pnlMain.add(_pnlMainTop, BorderLayout.NORTH); _pnlMainTop.setLayout(new BoxLayout(_pnlMainTop, BoxLayout.Y_AXIS)); _lblEnterSearchString = new JLabel(enterSearchStringCaption); _lblEnterSearchString.setBorder(new EmptyBorder(0, 0, 5, 0)); _lblEnterSearchString.setHorizontalAlignment(SwingConstants.LEFT); _lblEnterSearchString.setVerticalAlignment(SwingConstants.TOP); _lblEnterSearchString.setAlignmentY(Component.TOP_ALIGNMENT); _pnlMainTop.add(_lblEnterSearchString); _textField = new JTextField(); _textField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { reset(); } @Override public void insertUpdate(DocumentEvent e) { reset(); } @Override public void changedUpdate(DocumentEvent e) { reset(); } }); _pnlMainTop.add(_textField); _textField.setColumns(10); _pnlMainMiddle = new JPanel(); _pnlMainMiddle.setBorder(new EmptyBorder(10, 0, 0, 0)); _pnlMain.add(_pnlMainMiddle, BorderLayout.CENTER); _pnlMainMiddle.setLayout(new BoxLayout(_pnlMainMiddle, BoxLayout.Y_AXIS)); _rdbtnSelectOne = new JRadioButton(selectOneCaption); _rdbtnSelectOne.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); _pnlMainMiddle.add(_rdbtnSelectOne); _rdbtnSelectAll = new JRadioButton(selectAllCaption); _rdbtnSelectAll.setSelected(true); _rdbtnSelectAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); _pnlMainMiddle.add(_rdbtnSelectAll); ButtonGroup radioButtonGroup = new ButtonGroup(); radioButtonGroup.add(_rdbtnSelectOne); radioButtonGroup.add(_rdbtnSelectAll); _pnlMainBottom = new JPanel(); _pnlMain.add(_pnlMainBottom, BorderLayout.SOUTH); _pnlMainBottom.setLayout(new BoxLayout(_pnlMainBottom, BoxLayout.Y_AXIS)); _chckbxSearchSynonyms = new JCheckBox(searchSynonymsCaption); _chckbxSearchSynonyms.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); _pnlMainBottom.add(_chckbxSearchSynonyms); _chckbxSearchEliminatedTaxa = new JCheckBox(searchEliminatedTaxaCaption); _chckbxSearchEliminatedTaxa.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); _pnlMainBottom.add(_chckbxSearchEliminatedTaxa); _pnlButtons = new JPanel(); _pnlButtons.setBorder(new EmptyBorder(20, 0, 0, 10)); getContentPane().add(_pnlButtons, BorderLayout.EAST); _pnlButtons.setLayout(new BorderLayout(0, 0)); _pnlInnerButtons = new JPanel(); _pnlButtons.add(_pnlInnerButtons, BorderLayout.NORTH); GridBagLayout gbl_pnlInnerButtons = new GridBagLayout(); gbl_pnlInnerButtons.columnWidths = new int[] { 0, 0 }; gbl_pnlInnerButtons.rowHeights = new int[] { 0, 0, 0, 0 }; gbl_pnlInnerButtons.columnWeights = new double[] { 0.0, Double.MIN_VALUE }; gbl_pnlInnerButtons.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; _pnlInnerButtons.setLayout(gbl_pnlInnerButtons); _btnFindNext = new JButton(); _btnFindNext.setAction(_findAction); GridBagConstraints gbc_btnFind = new GridBagConstraints(); gbc_btnFind.fill = GridBagConstraints.HORIZONTAL; gbc_btnFind.insets = new Insets(0, 0, 5, 0); gbc_btnFind.gridx = 0; gbc_btnFind.gridy = 0; _pnlInnerButtons.add(_btnFindNext, gbc_btnFind); _btnPrevious = new JButton(); _btnPrevious.setAction(actionMap.get("previousFoundTaxon")); _btnPrevious.setEnabled(false); GridBagConstraints gbc_btnPrevious = new GridBagConstraints(); gbc_btnPrevious.insets = new Insets(0, 0, 5, 0); gbc_btnPrevious.gridx = 0; gbc_btnPrevious.gridy = 1; _pnlInnerButtons.add(_btnPrevious, gbc_btnPrevious); _btnDone = new JButton(); _btnDone.setAction(actionMap.get("findTaxaDone")); GridBagConstraints gbc_btnDone = new GridBagConstraints(); gbc_btnDone.fill = GridBagConstraints.HORIZONTAL; gbc_btnDone.gridx = 0; gbc_btnDone.gridy = 2; _pnlInnerButtons.add(_btnDone, gbc_btnDone); this.pack(); this.setLocationRelativeTo(_intkeyApp.getMainFrame()); }
From source file:edu.ku.brc.specify.config.init.DBLocationPanel.java
/** * Creates a dialog for entering database name and selecting the appropriate driver. *///from ww w. jav a 2 s.c o m public DBLocationPanel(final JButton nextBtn) { super("Storage", null, nextBtn, null); localDirOK = true; File currentPath = new File(UIRegistry.getAppDataDir() + File.separator + "specify_tmp.tmp"); try { FileUtils.touch(currentPath); currentPath.delete(); } catch (IOException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(DBLocationPanel.class, ex); localDirOK = false; } //localDirOK = false ; // XXX TESTING ButtonGroup grp = new ButtonGroup(); useHomeRB = new JRadioButton( "<html>Use your home directory: <b>" + UIRegistry.getUserHomeAppDir() + "</b></html>"); grp.add(useHomeRB); useHomeRB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (browse != null) { browse.setEnabled(false); } updateBtnUI(); } }); int numRows = 3; StringBuilder header = new StringBuilder( "<html>This step requires you to select a storage for the database."); //localDirOK = false; // DEBUG if (localDirOK) { header.append("There are three options:</html>"); useCurrentRB = new JRadioButton( "<html>Use your current directory: <b>" + UIRegistry.getDefaultWorkingPath() + "</b></html>"); grp.add(useCurrentRB); useCurrentRB.setSelected(true); numRows++; } else { header.append( "<br>The database cannot be stored on the media you are currently running Workbench from, "); header.append( "so you can allow it to default to your '<i>home</i>' directory. Or choose a different storage.</html>"); useHomeRB.setSelected(true); } useUserDefinedRB = new JRadioButton("Use other storage:"); grp.add(useUserDefinedRB); useUserDefinedRB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { browse.setEnabled(true); updateBtnUI(); } }); filePath = new JTextField(30); filePath.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { updateBtnUI(); } public void removeUpdate(DocumentEvent e) { updateBtnUI(); } public void changedUpdate(DocumentEvent e) { updateBtnUI(); } }); browse = new BrowseBtnPanel(filePath, true, true); browse.setEnabled(false); CellConstraints cc = new CellConstraints(); JLabel lbl = new JLabel(header.toString()); PanelBuilder cmtBldr = new PanelBuilder(new FormLayout("f:min(300px;p):g", "f:p:g")); cmtBldr.add(lbl, cc.xy(1, 1)); PanelBuilder builder = new PanelBuilder(new FormLayout("p,2px,p:g", "p:g,2px," + UIHelper.createDuplicateJGoodiesDef("p", "2px", numRows) + ",f:p:g"), this); int row = 1; builder.add(cmtBldr.getPanel(), cc.xywh(1, row, 3, 1)); row += 2; builder.add(useHomeRB, cc.xy(1, row)); row += 2; if (useCurrentRB != null) { builder.add(useCurrentRB, cc.xy(1, row)); row += 2; } builder.add(useUserDefinedRB, cc.xy(1, row)); row += 2; builder.add(browse, cc.xy(1, row)); row += 2; }