List of usage examples for javax.swing ButtonGroup ButtonGroup
public ButtonGroup()
ButtonGroup
. From source file:org.mbs3.juniuploader.gui.pnlSettings.java
private void initGUI() { try {/*from ww w . j av a 2 s . c om*/ GridBagLayout thisLayout = new GridBagLayout(); thisLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; thisLayout.rowHeights = new int[] { 11, 20, 18, 22, 22, 23, 23, 20, 18, 23, 22, 24, 6, 26, 4, 30, 8 }; thisLayout.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 0.0, 0.1, 0.0 }; thisLayout.columnWidths = new int[] { 10, 106, 90, 20, 20, 7, 100, 20, 7 }; this.setLayout(thisLayout); this.setPreferredSize(new java.awt.Dimension(659, 349)); { { grpMain = new ButtonGroup(); } { grpGUI = new ButtonGroup(); } { grpObjects = new ButtonGroup(); } { grpHTTP = new ButtonGroup(); } { } { } lblGUI = new JLabel(); this.add(lblGUI, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblGUI.setText("Graphical Interface"); } { lblMain = new JLabel(); this.add(lblMain, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblMain.setText("Main Program"); } { lblObj = new JLabel(); this.add(lblObj, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblObj.setText("Object Messages"); } { lblLObj = new JLabel(); this.add(lblLObj, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblLObj.setText("HTTP Messages"); } { lblFatal = new JLabel(); this.add(lblFatal, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblFatal.setText("Fatal Messages"); } { lblError = new JLabel(); this.add(lblError, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblError.setText("Errors"); } { lblWarn = new JLabel(); this.add(lblWarn, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblWarn.setText("Warnings"); } { lblInfo = new JLabel(); this.add(lblInfo, new GridBagConstraints(5, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblInfo.setText("Info Messages"); } { lblDebug = new JLabel(); this.add(lblDebug, new GridBagConstraints(6, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblDebug.setText("Debug Messages"); } { lblTrace = new JLabel(); this.add(lblTrace, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblTrace.setText("Trace Execution"); } { btnMainFatal = new JRadioButton(); this.add(btnMainFatal, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } grpMain.add(btnMainFatal); btnMainFatal.setActionCommand("fatal"); btnMainFatal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); { btnMainError = new JRadioButton(); this.add(btnMainError, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpMain.add(btnMainError); btnMainError.setActionCommand("error"); btnMainError.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnMainWarn = new JRadioButton(); this.add(btnMainWarn, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpMain.add(btnMainWarn); btnMainWarn.setActionCommand("warn"); btnMainWarn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnMainInfo = new JRadioButton(); this.add(btnMainInfo, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpMain.add(btnMainInfo); btnMainInfo.setActionCommand("info"); btnMainInfo.setSelected(true); btnMainInfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnMainDebug = new JRadioButton(); this.add(btnMainDebug, new GridBagConstraints(6, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpMain.add(btnMainDebug); btnMainDebug.setActionCommand("debug"); btnMainDebug.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnMainTrace = new JRadioButton(); this.add(btnMainTrace, new GridBagConstraints(7, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpMain.add(btnMainTrace); btnMainTrace.setActionCommand("trace"); btnMainTrace.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnGUIFatal = new JRadioButton(); this.add(btnGUIFatal, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpGUI.add(btnGUIFatal); btnGUIFatal.setActionCommand("fatal"); btnGUIFatal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnGUIError = new JRadioButton(); this.add(btnGUIError, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpGUI.add(btnGUIError); btnGUIError.setActionCommand("error"); btnGUIError.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnGUIWarn = new JRadioButton(); this.add(btnGUIWarn, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpGUI.add(btnGUIWarn); btnGUIWarn.setActionCommand("warn"); btnGUIWarn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnGUIInfo = new JRadioButton(); this.add(btnGUIInfo, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpGUI.add(btnGUIInfo); btnGUIInfo.setActionCommand("info"); btnGUIInfo.setSelected(true); btnGUIInfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnGUIDebug = new JRadioButton(); this.add(btnGUIDebug, new GridBagConstraints(6, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpGUI.add(btnGUIDebug); btnGUIDebug.setActionCommand("debug"); btnGUIDebug.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnGUITrace = new JRadioButton(); this.add(btnGUITrace, new GridBagConstraints(7, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpGUI.add(btnGUITrace); btnGUITrace.setActionCommand("trace"); btnGUITrace.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnObjFatal = new JRadioButton(); this.add(btnObjFatal, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpObjects.add(btnObjFatal); btnObjFatal.setActionCommand("fatal"); btnObjFatal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnObjError = new JRadioButton(); this.add(btnObjError, new GridBagConstraints(3, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpObjects.add(btnObjError); btnObjError.setActionCommand("error"); btnObjError.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnObjWarn = new JRadioButton(); this.add(btnObjWarn, new GridBagConstraints(4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpObjects.add(btnObjWarn); btnObjWarn.setActionCommand("warn"); btnObjWarn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnObjInfo = new JRadioButton(); this.add(btnObjInfo, new GridBagConstraints(5, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpObjects.add(btnObjInfo); btnObjInfo.setActionCommand("info"); btnObjInfo.setSelected(true); btnObjInfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnObjDebug = new JRadioButton(); this.add(btnObjDebug, new GridBagConstraints(6, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpObjects.add(btnObjDebug); btnObjDebug.setActionCommand("debug"); btnObjDebug.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnObjTrace = new JRadioButton(); this.add(btnObjTrace, new GridBagConstraints(7, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpObjects.add(btnObjTrace); btnObjTrace.setActionCommand("trace"); btnObjTrace.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnHTTPFatal = new JRadioButton(); this.add(btnHTTPFatal, new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpHTTP.add(btnHTTPFatal); btnHTTPFatal.setActionCommand("fatal"); btnHTTPFatal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnHTTPError = new JRadioButton(); this.add(btnHTTPError, new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpHTTP.add(btnHTTPError); btnHTTPError.setActionCommand("error"); btnHTTPError.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnHTTPWarn = new JRadioButton(); this.add(btnHTTPWarn, new GridBagConstraints(4, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpHTTP.add(btnHTTPWarn); btnHTTPWarn.setActionCommand("warn"); btnHTTPWarn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnHTTPInfo = new JRadioButton(); this.add(btnHTTPInfo, new GridBagConstraints(5, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpHTTP.add(btnHTTPInfo); btnHTTPInfo.setActionCommand("info"); btnHTTPInfo.setSelected(true); btnHTTPInfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnHTTPDebug = new JRadioButton(); this.add(btnHTTPDebug, new GridBagConstraints(6, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpHTTP.add(btnHTTPDebug); btnHTTPDebug.setActionCommand("debug"); btnHTTPDebug.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnHTTPTrace = new JRadioButton(); this.add(btnHTTPTrace, new GridBagConstraints(7, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpHTTP.add(btnHTTPTrace); btnHTTPTrace.setActionCommand("trace"); btnHTTPTrace.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { lblLogLevel = new JLabel(); this.add(lblLogLevel, new GridBagConstraints(1, 1, 7, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblLogLevel.setText("Set the level of logging for different parts of this application:"); } { lblDeLF = new JLabel(); this.add(lblDeLF, new GridBagConstraints(1, 8, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblDeLF.setText("Set the look and feel for the GUI of this application:"); } { LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels(); LookAndFeel lf = UIManager.getLookAndFeel(); DefaultComboBoxModel cmbLFModel = new DefaultComboBoxModel(); for (int i = 0; i < lfs.length; i++) { String n = lfs[i].getName(); cmbLFModel.addElement(n); if (lf.getName().equals(lfs[i].getName())) cmbLFModel.setSelectedItem(n); } cmbLF = new JComboBox(); this.add(cmbLF, new GridBagConstraints(1, 9, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbLF.setModel(cmbLFModel); cmbLF.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent evt) { cmbLFItemStateChanged(evt); } }); } { tfUserAgent = new JTextField(Util.getUserAgent()); this.add(tfUserAgent, new GridBagConstraints(1, 11, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); tfUserAgent.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent evt) { tfUserAgentKeyReleased(evt); } }); } { lblUserAgent = new JLabel(); this.add(lblUserAgent, new GridBagConstraints(1, 10, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblUserAgent.setText("User Agent"); } { btnExport = new JToggleButton(); this.add(btnExport, new GridBagConstraints(1, 15, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); btnExport.setText("Export All Settings and Data to File"); btnExport.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { btnExportActionPerformed(evt); } }); } { txtWarn = new JTextPane(); this.add(txtWarn, new GridBagConstraints(4, 15, 4, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtWarn.setText( "Note: This includes rules, form variables, sites, and ANYTHING else this program can remember from run to run."); txtWarn.setEditable(false); txtWarn.setBackground(new java.awt.Color(255, 255, 255)); txtWarn.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 0))); } } catch (Exception e) { e.printStackTrace(); } }
From source file:org.monome.pages.MIDITriggersPage.java
/** * @return The rows/columns radio button group *//* w w w. j a v a 2 s . c o m*/ private ButtonGroup getRowColBG() { if (rowColBG == null) { rowColBG = new ButtonGroup(); } return rowColBG; }
From source file:org.multibit.viewsystem.swing.view.panels.ShowPreferencesPanel.java
private JPanel createLanguagePanel(int stentWidth) { // Language radios. MultiBitTitledPanel languagePanel = new MultiBitTitledPanel( controller.getLocaliser().getString("showPreferencesPanel.languageTitle"), ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 0;/* w ww . j a v a 2 s .c om*/ constraints.gridy = 3; constraints.weightx = 0.1; constraints.weighty = 0.05; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.LINE_START; JPanel indent = MultiBitTitledPanel.getIndentPanel(1); languagePanel.add(indent, constraints); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 1; constraints.gridy = 3; constraints.weightx = 0.3; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; JPanel stent = MultiBitTitledPanel.createStent(stentWidth); languagePanel.add(stent, constraints); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 2; constraints.gridy = 3; constraints.weightx = 0.05; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.CENTER; languagePanel.add(MultiBitTitledPanel.createStent(MultiBitTitledPanel.SEPARATION_BETWEEN_NAME_VALUE_PAIRS), constraints); ButtonGroup languageUsageGroup = new ButtonGroup(); useDefaultLocale = new JRadioButton(controller.getLocaliser().getString("showPreferencesPanel.useDefault")); useDefaultLocale.setOpaque(false); useDefaultLocale.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); JRadioButton useSpecific = new JRadioButton( controller.getLocaliser().getString("showPreferencesPanel.useSpecific")); useSpecific.setOpaque(false); useSpecific.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); ItemListener itemListener = new ChangeLanguageUsageListener(); useDefaultLocale.addItemListener(itemListener); useSpecific.addItemListener(itemListener); languageUsageGroup.add(useDefaultLocale); languageUsageGroup.add(useSpecific); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 4; constraints.weightx = 0.2; constraints.weighty = 0.3; constraints.gridwidth = 3; constraints.anchor = GridBagConstraints.LINE_START; languagePanel.add(useDefaultLocale, constraints); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 5; constraints.weightx = 0.2; constraints.weighty = 0.3; constraints.gridwidth = 3; constraints.anchor = GridBagConstraints.LINE_START; languagePanel.add(useSpecific, constraints); // Language combo box. int numberOfLanguages = Integer .parseInt(controller.getLocaliser().getString("showPreferencesPanel.numberOfLanguages")); // Languages are added to the combo box in alphabetic order. languageDataSet = new TreeSet<LanguageData>(); for (int i = 0; i < numberOfLanguages; i++) { String languageCode = controller.getLocaliser() .getString("showPreferencesPanel.languageCode." + (i + 1)); String language = controller.getLocaliser().getString("showPreferencesPanel.language." + (i + 1)); LanguageData languageData = new LanguageData(); languageData.languageCode = languageCode; languageData.language = language; languageData.image = createImageIcon(languageCode); languageData.image.setDescription(language); languageDataSet.add(languageData); } Integer[] indexArray = new Integer[languageDataSet.size()]; int index = 0; for (@SuppressWarnings("unused") LanguageData languageData : languageDataSet) { indexArray[index] = index; index++; } languageComboBox = new JComboBox(indexArray); languageComboBox.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); languageComboBox.setOpaque(false); LanguageComboBoxRenderer renderer = new LanguageComboBoxRenderer(); FontMetrics fontMetrics = getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont()); Dimension preferredSize = new Dimension(fontMetrics.stringWidth(A_LONG_LANGUAGE_NAME) + LANGUAGE_COMBO_WIDTH_DELTA + LANGUAGE_CODE_IMAGE_WIDTH, fontMetrics.getHeight() + COMBO_HEIGHT_DELTA); renderer.setPreferredSize(preferredSize); languageComboBox.setRenderer(renderer); // Get the languageCode value stored in the model. String userLanguageCode = controller.getModel().getUserPreference(CoreModel.USER_LANGUAGE_CODE); if (userLanguageCode == null || CoreModel.USER_LANGUAGE_IS_DEFAULT.equals(userLanguageCode)) { useDefaultLocale.setSelected(true); languageComboBox.setEnabled(false); } else { useSpecific.setSelected(true); int startingIndex = 0; Integer languageCodeIndex = 0; for (LanguageData languageData : languageDataSet) { if (languageData.languageCode.equals(userLanguageCode)) { languageCodeIndex = startingIndex; break; } startingIndex++; } if (languageCodeIndex != 0) { languageComboBox.setSelectedItem(languageCodeIndex); languageComboBox.setEnabled(true); } } // Store original value for use by submit action. originalUserLanguageCode = userLanguageCode; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 3; constraints.gridy = 6; constraints.weightx = 0.8; constraints.weighty = 0.6; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; languagePanel.add(languageComboBox, constraints); JPanel fill1 = new JPanel(); fill1.setOpaque(false); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 4; constraints.gridy = 6; constraints.weightx = 20; constraints.weighty = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_END; languagePanel.add(fill1, constraints); return languagePanel; }
From source file:org.multibit.viewsystem.swing.view.panels.ShowPreferencesPanel.java
private JPanel createBrowserIntegrationPanel(int stentWidth) { MultiBitTitledPanel browserIntegrationPanel = new MultiBitTitledPanel( controller.getLocaliser().getString("showPreferencesPanel.browserIntegrationTitle"), ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())); GridBagConstraints constraints = new GridBagConstraints(); MultiBitTitledPanel.addLeftJustifiedTextAtIndent( controller.getLocaliser().getString("showPreferencesPanel.browserIntegration.messageText"), 3, browserIntegrationPanel);// w ww.j a v a2 s. c o m ButtonGroup browserIntegrationGroup = new ButtonGroup(); ignoreAll = new JRadioButton(controller.getLocaliser().getString("showPreferencesPanel.ignoreAll")); ignoreAll.setOpaque(false); ignoreAll.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); fillAutomatically = new JRadioButton( controller.getLocaliser().getString("showPreferencesPanel.fillAutomatically")); fillAutomatically.setOpaque(false); fillAutomatically.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); askEveryTime = new JRadioButton(controller.getLocaliser().getString("showPreferencesPanel.askEveryTime")); askEveryTime.setOpaque(false); askEveryTime.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); browserIntegrationGroup.add(ignoreAll); browserIntegrationGroup.add(fillAutomatically); browserIntegrationGroup.add(askEveryTime); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 5; constraints.weightx = 0.2; constraints.weighty = 0.3; constraints.gridwidth = 3; constraints.anchor = GridBagConstraints.LINE_START; browserIntegrationPanel.add(ignoreAll, constraints); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 6; constraints.weightx = 0.2; constraints.weighty = 0.3; constraints.anchor = GridBagConstraints.LINE_START; browserIntegrationPanel.add(fillAutomatically, constraints); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 7; constraints.weightx = 0.2; constraints.weighty = 0.3; constraints.anchor = GridBagConstraints.LINE_START; browserIntegrationPanel.add(askEveryTime, constraints); return browserIntegrationPanel; }
From source file:org.notebook.gui.widget.LookAndFeelSelector.java
protected JMenu createMenu() { JMenu toolMenu = new JMenu(MenuToolbar.i18n("Views")); ButtonGroup group = new ButtonGroup(); JRadioButtonMenuItem item = null; for (String n : getListOfSkins()) { item = new JRadioButtonMenuItem(new LafMenuAction(n)); if (n.equals(DEFAULT_SKIN)) { item.setSelected(true);//from w w w .j a v a 2s . c om } group.add(item); toolMenu.add(item); } return toolMenu; }
From source file:org.nuclos.client.ui.collect.component.AbstractCollectableComponent.java
/** * @return//w ww .j a va 2 s .c o m * @precondition hasComparisonOperator() */ public JPopupMenu newComparisonOperatorPopupMenu() { if (!hasComparisonOperator()) { throw new IllegalStateException(); } final JPopupMenu result = new JPopupMenu( getSpringLocaleDelegate().getMessage("AbstractCollectableComponent.16", "Vergleichsoperator")); // 1. comparison operators: final ButtonGroup btngrpComparisonOperators = new ButtonGroup(); final ItemListener itemlistener = new ItemListener() { @Override public void itemStateChanged(ItemEvent ev) { if (ev.getStateChange() == ItemEvent.SELECTED) { final String sOperatorName = ((AbstractButton) ev.getItem()).getActionCommand(); setComparisonOperator(ComparisonOperator.getInstance(sOperatorName)); runLocked(new Runnable() { @Override public void run() { updateSearchConditionInModel(); } }); } } }; ComparisonOperator[] supportedComparisonOperators = getSupportedComparisonOperators(); if (supportedComparisonOperators == null) return null; for (ComparisonOperator compop : supportedComparisonOperators) { JMenuItem mi = new JRadioButtonMenuItem( getSpringLocaleDelegate().getMessage(compop.getResourceIdForLabel(), null)); mi.setActionCommand(compop.name()); mi.setToolTipText(getSpringLocaleDelegate().getMessage(compop.getResourceIdForDescription(), null)); result.add(mi); btngrpComparisonOperators.add(mi); mi.addItemListener(itemlistener); } result.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent ev) { for (int i = 0, n = result.getComponentCount(); i < n; i++) { Component c = result.getComponent(i); if (c instanceof JMenuItem && StringUtils.emptyIfNull(((JMenuItem) c).getActionCommand()) .equals(getComparisonOperator().name())) ((JMenuItem) c).setSelected(true); } } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent ev) { } @Override public void popupMenuCanceled(PopupMenuEvent ev) { } }); // 2. right operand (value or other field): if (canDisplayComparisonWithOtherField()) { addRightOperandToPopupMenu(result, this); } return result; }
From source file:org.nuclos.client.ui.collect.component.AbstractCollectableComponent.java
/** * @param result/*from w w w. j ava 2 s .c om*/ * @param clctcomp */ private static void addRightOperandToPopupMenu(JPopupMenu result, final AbstractCollectableComponent clctcomp) { result.addSeparator(); final ButtonGroup btngrpCompareWith = new ButtonGroup(); final SpringLocaleDelegate localeDelegate = SpringLocaleDelegate.getInstance(); final JRadioButtonMenuItem miValue = new JRadioButtonMenuItem( localeDelegate.getMessage("AbstractCollectableComponent.17", "Wertvergleich")); miValue.setToolTipText(localeDelegate.getMessage("AbstractCollectableComponent.10", "Dieses Feld mit einem festen Wert vergleichen")); result.add(miValue); btngrpCompareWith.add(miValue); miValue.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { clctcomp.resetWithComparison(); clctcomp.runLocked(new Runnable() { @Override public void run() { clctcomp.updateSearchConditionInModel(); } }); } }); final JRadioButtonMenuItem miOtherField = new JRadioButtonMenuItem( localeDelegate.getMessage("AbstractCollectableComponent.12", "Feldvergleich...")); miOtherField.setToolTipText(localeDelegate.getMessage("AbstractCollectableComponent.9", "Dieses Feld mit dem Inhalt eines anderen Felds vergleichen")); result.add(miOtherField); btngrpCompareWith.add(miOtherField); miOtherField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { assert clctcomp.clcte != null; // select entity field with the same data type: final List<CollectableEntityField> lstclctefFiltered = CollectionUtils.select( CollectableUtils.getCollectableEntityFields(clctcomp.clcte), new Predicate<CollectableEntityField>() { @Override public boolean evaluate(CollectableEntityField clctef) { return clctef.getJavaClass() == clctcomp.clctef.getJavaClass(); } }); // and sort by label: final List<CollectableEntityField> lstclctefSorted = CollectionUtils.sorted(lstclctefFiltered, new CollectableEntityField.LabelComparator()); final JComboBox cmbbx = new JComboBox(lstclctefSorted.toArray()); cmbbx.setSelectedItem(clctcomp.getComparisonOtherField()); final int iBtn = JOptionPane .showConfirmDialog(clctcomp.getJComponent(), new Object[] { localeDelegate.getMessage("AbstractCollectableComponent.6", "Anderes Feld: "), cmbbx }, localeDelegate.getMessage("AbstractCollectableComponent.15", "Vergleich mit anderem Feld"), JOptionPane.OK_CANCEL_OPTION); if (iBtn == JOptionPane.OK_OPTION) { clctcomp.setWithComparison((CollectableEntityField) cmbbx.getSelectedItem()); if (clctcomp.getComparisonOtherField() != null) { // clear the view: clctcomp.updateView(CollectableUtils.getNullField(clctcomp.getEntityField())); if (clctcomp.compop.getOperandCount() < 2) { // If the user selects "other field" and forgot to set the operator, we assume "EQUAL": clctcomp.compop = ComparisonOperator.EQUAL; } } clctcomp.runLocked(new Runnable() { @Override public void run() { clctcomp.updateSearchConditionInModel(); } }); } } }); final List<ComparisonParameter> compatibleParameters = ComparisonParameter .getCompatibleParameters(clctcomp.getEntityField()); final JRadioButtonMenuItem miParameterField = new JRadioButtonMenuItem( localeDelegate.getMessage("AbstractCollectableComponent.18", null)); miParameterField.setToolTipText(localeDelegate.getMessage("AbstractCollectableComponent.19", null)); btngrpCompareWith.add(miParameterField); if (compatibleParameters.size() > 0) { result.add(miParameterField); miParameterField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { ResourceIdMapper<ComparisonParameter> mapper = new ResourceIdMapper<ComparisonParameter>( compatibleParameters); JComboBox cmbbx = new JComboBox(CollectionUtils.sorted(compatibleParameters, mapper).toArray()); cmbbx.setRenderer(new DefaultListRenderer(mapper)); cmbbx.setSelectedItem(clctcomp.getComparisonParameter()); final int opt = JOptionPane.showConfirmDialog(clctcomp.getJComponent(), new Object[] { localeDelegate.getMessage("AbstractCollectableComponent.20", null), cmbbx }, localeDelegate.getMessage("AbstractCollectableComponent.19", null), JOptionPane.OK_CANCEL_OPTION); if (opt == JOptionPane.OK_OPTION) { clctcomp.setWithComparison((ComparisonParameter) cmbbx.getSelectedItem()); if (clctcomp.getComparisonParameter() != null) { clctcomp.updateView(CollectableUtils.getNullField(clctcomp.getEntityField())); if (clctcomp.compop.getOperandCount() < 2) { clctcomp.compop = ComparisonOperator.EQUAL; } } clctcomp.runLocked(new Runnable() { @Override public void run() { clctcomp.updateSearchConditionInModel(); } }); } } }); } result.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent ev) { if (clctcomp.getComparisonParameter() != null) { miParameterField.setSelected(true); } else if (clctcomp.getComparisonOtherField() == null || clctcomp.getComparisonOperator().getOperandCount() < 2) { miValue.setSelected(true); } else { miOtherField.setSelected(true); } } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent ev) { } @Override public void popupMenuCanceled(PopupMenuEvent ev) { } }); }
From source file:org.nuclos.client.ui.DateTimeSeries.java
/** * - creates the panels// www . j a va 2 s . c om * - set properties and actionlisteners to all controls * - add all controls to the panels */ private synchronized void setupControl() { this.setLayout(new BorderLayout()); final double[] columns = new double[] { 2.0, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, 2.0 }; final double[] rows = new double[] { 4.0, 28.0, 28.0, 28.0, 28.0, 28.0, 4.0 }; tfTimeH.setInputVerifier(new TextFieldNumberVerifier(0, 23)); tfTimeH.setColumns(2); tfTimeM.setInputVerifier(new TextFieldNumberVerifier(0, 59)); tfTimeM.setColumns(2); final JPanel pnlHolder = new JPanel(); pnlHolder.setLayout(new TableLayout(columns, rows)); pnlHolder.setBorder(tfSeries.getBorder()); radioDaily.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setMode(DAILY_MODE); } }); radioWeekly.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setMode(WEEKLY_MODE); } }); radioMonthly.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setMode(MONTHLY_MODE); } }); radioYearly.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setMode(YEARLY_MODE); } }); radioNoMode.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setMode(NO_MODE); } }); bgMainModus.add(radioDaily); bgMainModus.add(radioWeekly); bgMainModus.add(radioMonthly); bgMainModus.add(radioYearly); bgMainModus.add(radioNoMode); pnlHolder.add(radioDaily, getConstraints(1, 1, 1, 1)); pnlHolder.add(radioWeekly, getConstraints(1, 1, 2, 2)); pnlHolder.add(radioMonthly, getConstraints(1, 1, 3, 3)); pnlHolder.add(radioYearly, getConstraints(1, 1, 4, 4)); if (isNoModeAvaiable) { pnlHolder.add(radioNoMode, getConstraints(1, 1, 5, 5)); } pnlHolder.add(new JSeparator(SwingConstants.VERTICAL), getConstraints(2, 2, 1, 5, TableLayoutConstants.CENTER, TableLayoutConstants.FULL)); final JLabel labStartTime = new JLabel("Uhrzeit "); constraintsPnlTime = getConstraints(1, 4, 1, 1); pnlTime = new JPanel(new TableLayout( new double[] { 2.0, TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED, 2.0 }, new double[] { 4.0, 21.0, 4.0 })); pnlTime.add(labStartTime, getConstraints(1, 1, 1, 1)); pnlTime.add(tfTimeH, getConstraints(2, 2, 1, 1)); pnlTime.add(new JLabel(" : "), getConstraints(3, 3, 1, 1)); pnlTime.add(tfTimeM, getConstraints(4, 4, 1, 1)); final TableLayoutConstraints constraintsRight = getConstraints(3, 3, 1, 5, TableLayoutConstants.FULL, TableLayoutConstants.FULL); pnlEmpty = new JPanel(new TableLayout()); pnlHolder.add(pnlEmpty, constraintsRight); /** * DAILY MODE */ pnlDailyMode = new JPanel(new TableLayout( new double[] { 4.0, TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED, 4.0 }, new double[] { 4.0, TableLayoutConstants.PREFERRED, // for start time panel 21.0, 21.0, 4.0 })); tfDailyDays.setColumns(4); tfDailyDays.setInputVerifier(new TextFieldNumberVerifier(1, 366)); radioDailyAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { tfDailyDays.setEnabled(true); } }); radioDailyWorking.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { tfDailyDays.setEnabled(false); } }); final ButtonGroup bgDailyMode = new ButtonGroup(); bgDailyMode.add(this.radioDailyAll); bgDailyMode.add(this.radioDailyWorking); radioDailyAll.addActionListener(this); radioDailyWorking.addActionListener(this); pnlDailyMode.add(radioDailyAll, getConstraints(1, 1, 2, 2)); pnlDailyMode.add(radioDailyWorking, getConstraints(1, 3, 3, 3)); pnlDailyMode.add(tfDailyDays, getConstraints(2, 2, 2, 2)); pnlDailyMode.add(new JLabel(" Tag(e)"), getConstraints(3, 3, 2, 2)); pnlHolder.add(pnlDailyMode, constraintsRight); /** * WEEKLY MODE */ pnlWeeklyMode = new JPanel(new TableLayout( new double[] { 4.0, TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED, 4.0 }, new double[] { 4.0, TableLayoutConstants.PREFERRED, // for start time panel 21.0, 21.0, 21.0, 21.0, 21.0, 4.0 })); tfWeeklyWeeks.setColumns(3); tfWeeklyWeeks.setInputVerifier(new TextFieldNumberVerifier(1, 53)); pnlWeeklyMode.add(new JLabel("Jede/Alle "), getConstraints(1, 1, 2, 2)); pnlWeeklyMode.add(tfWeeklyWeeks, getConstraints(2, 2, 2, 2)); pnlWeeklyMode.add(new JLabel(" Woche(n) am"), getConstraints(3, 3, 2, 2)); pnlWeeklyMode.add(checkMonday, getConstraints(1, 2, 3, 3)); pnlWeeklyMode.add(checkTuesday, getConstraints(1, 2, 4, 4)); pnlWeeklyMode.add(checkWednesday, getConstraints(1, 2, 5, 5)); pnlWeeklyMode.add(checkThursday, getConstraints(1, 2, 6, 6)); pnlWeeklyMode.add(checkFriday, getConstraints(3, 3, 3, 3)); pnlWeeklyMode.add(checkSaturday, getConstraints(3, 3, 4, 4)); pnlWeeklyMode.add(checkSunday, getConstraints(3, 3, 5, 5)); checkMonday.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!isAtLeastOneWeekdaySelected()) checkMonday.setSelected(true); } }); checkMonday.addActionListener(this); checkTuesday.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!isAtLeastOneWeekdaySelected()) checkTuesday.setSelected(true); } }); checkTuesday.addActionListener(this); checkWednesday.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!isAtLeastOneWeekdaySelected()) checkWednesday.setSelected(true); } }); checkWednesday.addActionListener(this); checkThursday.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!isAtLeastOneWeekdaySelected()) checkThursday.setSelected(true); } }); checkThursday.addActionListener(this); checkFriday.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!isAtLeastOneWeekdaySelected()) checkFriday.setSelected(true); } }); checkFriday.addActionListener(this); checkSaturday.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!isAtLeastOneWeekdaySelected()) checkSaturday.setSelected(true); } }); checkSaturday.addActionListener(this); checkSunday.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!isAtLeastOneWeekdaySelected()) checkSunday.setSelected(true); } }); checkSunday.addActionListener(this); pnlHolder.add(pnlWeeklyMode, constraintsRight); /** * MONTHLY MODE */ pnlMonthlyMode = new JPanel(new TableLayout( new double[] { 4.0, TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED, 4.0 }, new double[] { 4.0, TableLayoutConstants.PREFERRED, // for start time panel 21.0, 21.0, 26.0, 21.0, 4.0 })); final ButtonGroup bgMonthlyMode = new ButtonGroup(); radioMonthly1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { tfMonthly1Day.setEnabled(true); tfMonthly1Month.setEnabled(true); comboMonthly2Number.setEnabled(false); comboMonthly2Weekday.setEnabled(false); tfMonthly2Month.setEnabled(false); } }); radioMonthly1.addActionListener(this); radioMonthly2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { tfMonthly1Day.setEnabled(false); tfMonthly1Month.setEnabled(false); comboMonthly2Number.setEnabled(true); comboMonthly2Weekday.setEnabled(true); tfMonthly2Month.setEnabled(true); } }); radioMonthly2.addActionListener(this); bgMonthlyMode.add(radioMonthly1); bgMonthlyMode.add(radioMonthly2); tfMonthly1Day.setColumns(3); tfMonthly1Day.setInputVerifier(new TextFieldNumberVerifier(1, 31)); tfMonthly1Month.setColumns(3); tfMonthly1Month.setInputVerifier(new TextFieldNumberVerifier(1, 12)); tfMonthly2Month.setColumns(3); tfMonthly2Month.setInputVerifier(new TextFieldNumberVerifier(1, 12)); comboMonthly2Number.addActionListener(this); for (SeriesListItem sli : SeriesUtils.getNumberItems()) { comboMonthly2Number.addItem(sli); } comboMonthly2Weekday.addActionListener(this); for (SeriesListItem sli : SeriesUtils.getWeekdayItems()) { comboMonthly2Weekday.addItem(sli); } pnlMonthlyMode.add(radioMonthly1, getConstraints(1, 1, 2, 2)); pnlMonthlyMode.add(radioMonthly2, getConstraints(1, 1, 4, 4, TableLayoutConstants.LEFT, TableLayoutConstants.BOTTOM)); pnlMonthlyMode.add(tfMonthly1Day, getConstraints(2, 2, 2, 2)); pnlMonthlyMode.add(new JLabel(" . Tag"), getConstraints(3, 3, 2, 2)); pnlMonthlyMode.add(new JLabel("jedes "), getConstraints(2, 2, 3, 3)); pnlMonthlyMode.add(tfMonthly1Month, getConstraints(3, 3, 3, 3)); pnlMonthlyMode.add(new JLabel(" . Monats"), getConstraints(4, 4, 3, 3)); pnlMonthlyMode.add(comboMonthly2Number, getConstraints(2, 3, 4, 4, TableLayoutConstants.LEFT, TableLayoutConstants.BOTTOM)); pnlMonthlyMode.add(comboMonthly2Weekday, getConstraints(4, 5, 4, 4, TableLayoutConstants.LEFT, TableLayoutConstants.BOTTOM)); pnlMonthlyMode.add(new JLabel("jedes "), getConstraints(2, 2, 5, 5)); pnlMonthlyMode.add(tfMonthly2Month, getConstraints(3, 3, 5, 5)); pnlMonthlyMode.add(new JLabel(" . Monats"), getConstraints(4, 4, 5, 5)); pnlHolder.add(pnlMonthlyMode, constraintsRight); /** * YEARLY MODE */ pnlYearlyMode = new JPanel(new TableLayout( new double[] { 4.0, TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED, 4.0 }, new double[] { 4.0, TableLayoutConstants.PREFERRED, // for start time panel 21.0, 26.0, 21.0, 4.0 })); final ButtonGroup bgYearlyMode = new ButtonGroup(); radioYearly1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { tfYearly1Day.setEnabled(true); comboYearly1Month.setEnabled(true); comboYearly2Number.setEnabled(false); comboYearly2Weekday.setEnabled(false); comboYearly2Month.setEnabled(false); } }); radioYearly1.addActionListener(this); radioYearly2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { tfYearly1Day.setEnabled(false); comboYearly1Month.setEnabled(false); comboYearly2Number.setEnabled(true); comboYearly2Weekday.setEnabled(true); comboYearly2Month.setEnabled(true); } }); radioYearly2.addActionListener(this); bgYearlyMode.add(radioYearly1); bgYearlyMode.add(radioYearly2); tfYearly1Day.setColumns(3); tfYearly1Day.setInputVerifier(new TextFieldNumberVerifier(1, 31)); comboYearly1Month.addActionListener(this); for (SeriesListItem sli : SeriesUtils.getMonthItems()) { comboYearly1Month.addItem(sli); } comboYearly2Number.addActionListener(this); for (SeriesListItem sli : SeriesUtils.getNumberItems()) { comboYearly2Number.addItem(sli); } comboYearly2Weekday.addActionListener(this); for (SeriesListItem sli : SeriesUtils.getWeekdayItems()) { comboYearly2Weekday.addItem(sli); } comboYearly2Month.addActionListener(this); for (SeriesListItem sli : SeriesUtils.getMonthItems()) { comboYearly2Month.addItem(sli); } pnlYearlyMode.add(radioYearly1, getConstraints(1, 1, 2, 2)); pnlYearlyMode.add(radioYearly2, getConstraints(1, 1, 3, 3, TableLayoutConstants.LEFT, TableLayoutConstants.BOTTOM)); pnlYearlyMode.add(tfYearly1Day, getConstraints(2, 2, 2, 2)); pnlYearlyMode.add(new JLabel(" . "), getConstraints(3, 3, 2, 2)); pnlYearlyMode.add(comboYearly1Month, getConstraints(4, 5, 2, 2)); pnlYearlyMode.add(comboYearly2Number, getConstraints(2, 3, 3, 3, TableLayoutConstants.LEFT, TableLayoutConstants.BOTTOM)); pnlYearlyMode.add(comboYearly2Weekday, getConstraints(4, 5, 3, 3, TableLayoutConstants.LEFT, TableLayoutConstants.BOTTOM)); pnlYearlyMode.add(new JLabel("im "), getConstraints(2, 2, 4, 4)); pnlYearlyMode.add(comboYearly2Month, getConstraints(3, 5, 4, 4)); pnlHolder.add(pnlYearlyMode, constraintsRight); resetAllInputFieldsToDefault(); /* * add "Main" Panel */ this.add(pnlHolder, BorderLayout.CENTER); }
From source file:org.nyu.edu.dlts.dbCopyFrame.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner non-commercial license dialogPane = new JPanel(); contentPanel = new JPanel(); apiLabel = new JLabel(); panel4 = new JPanel(); label9 = new JLabel(); beanShellRadioButton = new JRadioButton(); jrubyRadioButton = new JRadioButton(); pythonRadioButton = new JRadioButton(); javascriptRadioButton = new JRadioButton(); loadExcelFileButton = new JButton(); excelTextField = new JTextField(); loadMapperScriptButton = new JButton(); mapperScriptTextField = new JTextField(); editScriptButton = new JButton(); separator2 = new JSeparator(); panel5 = new JPanel(); createRepositoryCheckBox = new JCheckBox(); repoShortNameTextField = new JTextField(); repoNameTextField = new JTextField(); repoCodeTextField = new JTextField(); repoURLTextField = new JTextField(); panel2 = new JPanel(); label1 = new JLabel(); label3 = new JLabel(); label10 = new JLabel(); locationsTextField = new JTextField(); locationsLabel = new JLabel(); label5 = new JLabel(); subjectsTextField = new JTextField(); subjectsLabel = new JLabel(); label4 = new JLabel(); namesTextField = new JTextField(); namesLabel = new JLabel(); label6 = new JLabel(); accessionsTextField = new JTextField(); accessionsLabel = new JLabel(); label7 = new JLabel(); digitalObjectsTextField = new JTextField(); digitalObjectLabel = new JLabel(); label8 = new JLabel(); resourcesTextField = new JTextField(); resourcesLabel = new JLabel(); separator1 = new JSeparator(); copyToASpaceButton = new JButton(); hostLabel = new JLabel(); hostTextField = new JTextField(); simulateCheckBox = new JCheckBox(); adminLabel = new JLabel(); adminTextField = new JTextField(); adminPasswordLabel = new JLabel(); adminPasswordTextField = new JTextField(); label2 = new JLabel(); repositoryURITextField = new JTextField(); developerModeCheckBox = new JCheckBox(); outputConsoleLabel = new JLabel(); copyProgressBar = new JProgressBar(); scrollPane1 = new JScrollPane(); consoleTextArea = new JTextArea(); recordURIComboBox = new JComboBox(); panel1 = new JPanel(); paramsLabel = new JLabel(); paramsTextField = new JTextField(); viewRecordButton = new JButton(); buttonBar = new JPanel(); errorLogButton = new JButton(); saveErrorsLabel = new JLabel(); errorCountLabel = new JLabel(); stopButton = new JButton(); utillitiesButton = new JButton(); okButton = new JButton(); CellConstraints cc = new CellConstraints(); //======== this ======== setTitle("Archives Space Excel Data Migrator"); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); //======== dialogPane ======== {//from w w w.ja v a2 s . c o m dialogPane.setBorder(Borders.DIALOG_BORDER); dialogPane.setLayout(new BorderLayout()); //======== contentPanel ======== { contentPanel.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, new RowSpec(RowSpec.TOP, Sizes.DEFAULT, FormSpec.NO_GROW), FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC })); //---- apiLabel ---- apiLabel.setText(" Archives Space Version: v1.1.0"); apiLabel.setHorizontalTextPosition(SwingConstants.CENTER); apiLabel.setFont(new Font("Lucida Grande", Font.BOLD, 14)); contentPanel.add(apiLabel, cc.xy(1, 1)); //======== panel4 ======== { panel4.setLayout(new FormLayout( new ColumnSpec[] { new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW) }, RowSpec.decodeSpecs("default"))); //---- label9 ---- label9.setText("Select Script Type"); panel4.add(label9, cc.xy(1, 1)); //---- beanShellRadioButton ---- beanShellRadioButton.setText("Beanshell"); beanShellRadioButton.setSelected(true); beanShellRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { clearMapperScript(); } }); panel4.add(beanShellRadioButton, cc.xy(3, 1)); //---- jrubyRadioButton ---- jrubyRadioButton.setText("JRuby"); jrubyRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { clearMapperScript(); } }); panel4.add(jrubyRadioButton, cc.xy(5, 1)); //---- pythonRadioButton ---- pythonRadioButton.setText("Jython"); pythonRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { clearMapperScript(); } }); panel4.add(pythonRadioButton, cc.xy(7, 1)); //---- javascriptRadioButton ---- javascriptRadioButton.setText("Javascript"); javascriptRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { clearMapperScript(); } }); panel4.add(javascriptRadioButton, cc.xy(9, 1)); } contentPanel.add(panel4, cc.xywh(3, 1, 7, 1)); //---- loadExcelFileButton ---- loadExcelFileButton.setText("Load Excel File"); loadExcelFileButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { loadExcelFileButtonActionPerformed(); } }); contentPanel.add(loadExcelFileButton, cc.xy(1, 3)); contentPanel.add(excelTextField, cc.xywh(3, 3, 5, 1)); //---- loadMapperScriptButton ---- loadMapperScriptButton.setText("Load Mapper Script"); loadMapperScriptButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { loadMapperScriptButtonActionPerformed(); } }); contentPanel.add(loadMapperScriptButton, cc.xy(1, 5)); //---- mapperScriptTextField ---- mapperScriptTextField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { loadMapperScript(); } }); contentPanel.add(mapperScriptTextField, cc.xywh(3, 5, 5, 1)); //---- editScriptButton ---- editScriptButton.setText("Edit"); editScriptButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { editScriptButtonActionPerformed(); } }); contentPanel.add(editScriptButton, cc.xy(9, 5)); contentPanel.add(separator2, cc.xywh(1, 7, 9, 1)); //======== panel5 ======== { panel5.setLayout(new FormLayout(ColumnSpec.decodeSpecs("default:grow"), new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC })); //---- createRepositoryCheckBox ---- createRepositoryCheckBox.setText("Create Repository"); createRepositoryCheckBox.setSelected(true); panel5.add(createRepositoryCheckBox, cc.xy(1, 1)); //---- repoShortNameTextField ---- repoShortNameTextField.setText("Repo Short Name 1"); panel5.add(repoShortNameTextField, cc.xy(1, 3)); //---- repoNameTextField ---- repoNameTextField.setText("Repo Name 1"); panel5.add(repoNameTextField, cc.xy(1, 5)); //---- repoCodeTextField ---- repoCodeTextField.setText("Organization Code 1"); panel5.add(repoCodeTextField, cc.xy(1, 7)); //---- repoURLTextField ---- repoURLTextField.setText("http://repository.url.org"); panel5.add(repoURLTextField, cc.xy(1, 9)); } contentPanel.add(panel5, cc.xy(1, 9)); //======== panel2 ======== { panel2.setLayout(new FormLayout("default, default:grow, right:default", "default, default, default, fill:default:grow, fill:default:grow, default, fill:default:grow")); //---- label1 ---- label1.setText("Record Type"); panel2.add(label1, cc.xy(1, 1)); //---- label3 ---- label3.setText("Spreadsheet Number (starting at 1)"); panel2.add(label3, cc.xy(2, 1)); //---- label10 ---- label10.setText("Locations"); panel2.add(label10, cc.xy(1, 2)); //---- locationsTextField ---- locationsTextField.setText("1"); panel2.add(locationsTextField, cc.xy(2, 2)); //---- locationsLabel ---- locationsLabel.setText("not supported"); panel2.add(locationsLabel, cc.xy(3, 2)); //---- label5 ---- label5.setText("Subjects"); panel2.add(label5, cc.xy(1, 3)); //---- subjectsTextField ---- subjectsTextField.setColumns(2); subjectsTextField.setText("2"); panel2.add(subjectsTextField, cc.xy(2, 3)); //---- subjectsLabel ---- subjectsLabel.setText("not supported"); panel2.add(subjectsLabel, cc.xy(3, 3)); //---- label4 ---- label4.setText("Names"); panel2.add(label4, cc.xy(1, 4)); //---- namesTextField ---- namesTextField.setColumns(12); namesTextField.setText("3"); panel2.add(namesTextField, cc.xy(2, 4)); //---- namesLabel ---- namesLabel.setText("not supported"); panel2.add(namesLabel, cc.xy(3, 4)); //---- label6 ---- label6.setText("Accessions"); panel2.add(label6, cc.xy(1, 5)); //---- accessionsTextField ---- accessionsTextField.setColumns(2); accessionsTextField.setText("4"); panel2.add(accessionsTextField, cc.xy(2, 5)); //---- accessionsLabel ---- accessionsLabel.setText("not supported"); panel2.add(accessionsLabel, cc.xy(3, 5)); //---- label7 ---- label7.setText("Digital Objects"); panel2.add(label7, cc.xy(1, 6)); //---- digitalObjectsTextField ---- digitalObjectsTextField.setColumns(2); digitalObjectsTextField.setText("5"); panel2.add(digitalObjectsTextField, cc.xy(2, 6)); //---- digitalObjectLabel ---- digitalObjectLabel.setText("not supported"); panel2.add(digitalObjectLabel, cc.xy(3, 6)); //---- label8 ---- label8.setText("Resources"); panel2.add(label8, cc.xy(1, 7)); //---- resourcesTextField ---- resourcesTextField.setText("6, 7"); resourcesTextField.setColumns(2); panel2.add(resourcesTextField, cc.xy(2, 7)); //---- resourcesLabel ---- resourcesLabel.setText("not supported"); panel2.add(resourcesLabel, cc.xy(3, 7)); } contentPanel.add(panel2, cc.xywh(3, 9, 7, 1)); contentPanel.add(separator1, cc.xywh(1, 11, 9, 1)); //---- copyToASpaceButton ---- copyToASpaceButton.setText("Copy To Archives Space"); copyToASpaceButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { CopyToASpaceButtonActionPerformed(); } }); contentPanel.add(copyToASpaceButton, cc.xy(1, 13)); //---- hostLabel ---- hostLabel.setText("Archives Space Host"); contentPanel.add(hostLabel, cc.xywh(3, 13, 2, 1)); //---- hostTextField ---- hostTextField.setText("http://localhost:8089"); contentPanel.add(hostTextField, cc.xywh(5, 13, 5, 1)); //---- simulateCheckBox ---- simulateCheckBox.setText("Simulate REST Calls"); simulateCheckBox.setSelected(true); contentPanel.add(simulateCheckBox, cc.xy(1, 15)); //---- adminLabel ---- adminLabel.setText("Administrator User ID"); contentPanel.add(adminLabel, cc.xy(3, 15)); //---- adminTextField ---- adminTextField.setText("admin"); contentPanel.add(adminTextField, cc.xywh(5, 15, 2, 1)); //---- adminPasswordLabel ---- adminPasswordLabel.setText("Password"); contentPanel.add(adminPasswordLabel, cc.xy(7, 15)); //---- adminPasswordTextField ---- adminPasswordTextField.setText("admin"); contentPanel.add(adminPasswordTextField, cc.xy(9, 15)); //---- label2 ---- label2.setText("Target Repository URI"); contentPanel.add(label2, cc.xy(3, 17)); contentPanel.add(repositoryURITextField, cc.xywh(5, 17, 5, 1)); //---- developerModeCheckBox ---- developerModeCheckBox.setText( "Developer Mode (Locations/Names/Subjects are copied once and random IDs are used other records)"); contentPanel.add(developerModeCheckBox, cc.xywh(1, 19, 9, 1)); //---- outputConsoleLabel ---- outputConsoleLabel.setText("Output Console:"); contentPanel.add(outputConsoleLabel, cc.xy(1, 21)); contentPanel.add(copyProgressBar, cc.xywh(3, 21, 7, 1)); //======== scrollPane1 ======== { //---- consoleTextArea ---- consoleTextArea.setRows(12); scrollPane1.setViewportView(consoleTextArea); } contentPanel.add(scrollPane1, cc.xywh(1, 23, 9, 1)); //---- recordURIComboBox ---- recordURIComboBox.setModel(new DefaultComboBoxModel(new String[] { "/repositories", "/users", "/subjects", "/agents/families/1", "/agents/people/1", "/agents/corporate_entities/1", "/repositories/2/accessions/1", "/repositories/2/resources/1", "/repositories/2/archival_objects/1", "/config/enumerations" })); recordURIComboBox.setEditable(true); contentPanel.add(recordURIComboBox, cc.xy(1, 25)); //======== panel1 ======== { panel1.setLayout(new FlowLayout(FlowLayout.LEFT)); //---- paramsLabel ---- paramsLabel.setText("Params"); panel1.add(paramsLabel); //---- paramsTextField ---- paramsTextField.setColumns(20); panel1.add(paramsTextField); } contentPanel.add(panel1, cc.xywh(3, 25, 3, 1)); //---- viewRecordButton ---- viewRecordButton.setText("View"); viewRecordButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { viewRecordButtonActionPerformed(); } }); contentPanel.add(viewRecordButton, cc.xywh(7, 25, 3, 1)); } dialogPane.add(contentPanel, BorderLayout.CENTER); //======== buttonBar ======== { buttonBar.setBorder(Borders.BUTTON_BAR_GAP_BORDER); buttonBar.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.GLUE_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.BUTTON_COLSPEC }, RowSpec.decodeSpecs("pref"))); //---- errorLogButton ---- errorLogButton.setText("View Error Log"); errorLogButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { errorLogButtonActionPerformed(); } }); buttonBar.add(errorLogButton, cc.xy(2, 1)); //---- saveErrorsLabel ---- saveErrorsLabel.setText(" Errors: "); buttonBar.add(saveErrorsLabel, cc.xy(4, 1)); //---- errorCountLabel ---- errorCountLabel.setText("N/A "); errorCountLabel.setForeground(Color.red); errorCountLabel.setFont(new Font("Lucida Grande", Font.BOLD, 13)); buttonBar.add(errorCountLabel, cc.xy(6, 1)); //---- stopButton ---- stopButton.setText("Cancel Copy"); stopButton.setEnabled(false); stopButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { stopButtonActionPerformed(); stopButtonActionPerformed(); } }); buttonBar.add(stopButton, cc.xy(9, 1)); //---- utillitiesButton ---- utillitiesButton.setText("Utilities"); buttonBar.add(utillitiesButton, cc.xy(11, 1)); //---- okButton ---- okButton.setText("Close"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { okButtonActionPerformed(); } }); buttonBar.add(okButton, cc.xy(14, 1)); } dialogPane.add(buttonBar, BorderLayout.SOUTH); } contentPane.add(dialogPane, BorderLayout.CENTER); pack(); setLocationRelativeTo(getOwner()); //---- buttonGroup1 ---- ButtonGroup buttonGroup1 = new ButtonGroup(); buttonGroup1.add(beanShellRadioButton); buttonGroup1.add(jrubyRadioButton); buttonGroup1.add(pythonRadioButton); buttonGroup1.add(javascriptRadioButton); // JFormDesigner - End of component initialization //GEN-END:initComponents }
From source file:org.omegat.gui.properties.SegmentPropertiesArea.java
@Override public void populatePaneMenu(JPopupMenu contextMenu) { JMenuItem tableModeItem = new JCheckBoxMenuItem(OStrings.getString("SEGPROP_CONTEXTMENU_TABLE_MODE")); tableModeItem.setSelected(viewImpl.getClass().equals(SegmentPropertiesTableView.class)); tableModeItem.addActionListener(new ActionListener() { @Override/*w w w . j av a 2 s .co m*/ public void actionPerformed(ActionEvent e) { toggleMode(SegmentPropertiesTableView.class); } }); JMenuItem listModeItem = new JCheckBoxMenuItem(OStrings.getString("SEGPROP_CONTEXTMENU_LIST_MODE")); listModeItem.setSelected(viewImpl.getClass().equals(SegmentPropertiesListView.class)); listModeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { toggleMode(SegmentPropertiesListView.class); } }); ButtonGroup group = new ButtonGroup(); group.add(tableModeItem); group.add(listModeItem); contextMenu.add(tableModeItem); contextMenu.add(listModeItem); contextMenu.addSeparator(); final JMenuItem toggleKeyTranslationItem = new JCheckBoxMenuItem( OStrings.getString("SEGPROP_CONTEXTMENU_RAW_KEYS")); toggleKeyTranslationItem.setSelected(Preferences.isPreference(Preferences.SEGPROPS_SHOW_RAW_KEYS)); toggleKeyTranslationItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Preferences.setPreference(Preferences.SEGPROPS_SHOW_RAW_KEYS, toggleKeyTranslationItem.isSelected()); viewImpl.update(); } }); contextMenu.add(toggleKeyTranslationItem); }