public PreferenceData.LogPreference logging() { if (acceptGroup.isSelected(loggingOkButton.getModel())) return PreferenceData.LogPreference.Normal; else if (acceptGroup.isSelected(noCodeLoggingButton.getModel())) return PreferenceData.LogPreference.NoCode; else return PreferenceData.LogPreference.NoLog; }
private void setControlsEnabled(ButtonModel selection) { boolean newModuleEnabled = selection == myRbCreateNewModule.getModel(); myTypesList.setEnabled(newModuleEnabled); myModuleDescriptionPane.setEnabled(newModuleEnabled); boolean importModuleEnabled = selection == myRbImportModule.getModel(); myModulePathFieldPanel.setEnabled(importModuleEnabled); }
public ToneMapper getSelectedToneMapper() { final ButtonModel model = toneMappingChoice.getSelection(); final double maxLum = ((Number) maxLumValue.getValue()).doubleValue(); if (model == wardTRButton.getModel()) { return new ImageUtil.WardTM(maxLum == 0 ? null : maxLum); } else if (model == reinhardTRButton.getModel()) { return new ImageUtil.ReinhardTM( ((Number) midpointValue.getValue()).doubleValue(), maxLum == 0 ? null : maxLum); } return ImageUtil.clampTM; }
public void setPurpose(LensPurposeType purpose) { switch (purpose) { case DEFAULT: buttonGroup.setSelected(defaultButton.getModel(), true); break; case LABEL: buttonGroup.setSelected(labelbutton.getModel(), true); break; case NOT_SPECIFIED: default: buttonGroup.setSelected(undefinedButton.getModel(), true); } }
/** kreiert das Menü oben */ private JToolBar createMenu() { JToolBar toolbar = new JToolBar(); toolbar.setOrientation(SwingConstants.HORIZONTAL); toolbar.setFloatable(false); toolbar.setMargin(new Insets(2, 35, 2, 0)); toolbar.setBackground(new Color(219, 255, 179)); zoomIn = FsmUtils.createButton(zoomInImg); zoomIn.setToolTipText("Vergr��ern"); zoomIn.addMouseListener(new ZoomInHandler(this)); zoomOut = FsmUtils.createButton(zoomOutImg); zoomOut.setToolTipText("Verkleinern"); zoomOut.addMouseListener(new ZoomOutHandler(this)); layout = FsmUtils.createButton(layoutImg); layout.setToolTipText("Automatisch layouten"); layout.addMouseListener(new LayoutHandler(this)); deterministic = new JRadioButton("deterministisch"); deterministic.setToolTipText("Der endliche Automat wird deterministisch"); deterministic.setBackground(new Color(219, 255, 179)); deterministic.addMouseListener(new TypeOfFsmHandler(this, false)); nondeterministic = new JRadioButton("nichtdeterministisch"); nondeterministic.setToolTipText("Der endliche Automat wird nichtdeterministisch"); nondeterministic.setBackground(new Color(219, 255, 179)); nondeterministic.addMouseListener(new TypeOfFsmHandler(this, true)); ButtonGroup group = new ButtonGroup(); group.add(deterministic); group.add(nondeterministic); if (this.getFsmProgram().isNondeterministic()) { group.setSelected(nondeterministic.getModel(), true); } else { group.setSelected(deterministic.getModel(), true); } toolbar.add(zoomIn); toolbar.add(Box.createHorizontalStrut(2)); toolbar.add(zoomOut); toolbar.add(Box.createHorizontalStrut(2)); toolbar.add(Box.createHorizontalStrut(2)); toolbar.add(layout); toolbar.addSeparator(); toolbar.add(deterministic); toolbar.add(nondeterministic); return toolbar; }
/** * Fonction appelée lorsque qu'une couleur est choisie. La couleur est modifiée et elle appelle le * gestionnaire de vue pour qu'il informe toutes les vues que le thème a changé et modifie leur * thème. * * @param e ChangeEvent permettant de récupérer la couleur choisie */ @Override public void stateChanged(ChangeEvent e) { ColorSelectionModel selection = (ColorSelectionModel) e.getSource(); if (options.isSelected(bordersColor.getModel())) { GridView.setBorderColor(selection.getSelectedColor()); } else if (options.isSelected(selectedCaseColor.getModel())) { GridView.setSelectionColor(selection.getSelectedColor()); } else if (options.isSelected(alreadyViewColor.getModel())) { GridView.setAlreadyViewColor(selection.getSelectedColor()); } else { GridView.setBackgroundColor(selection.getSelectedColor()); } ViewManager.updateTheme(); }
private void jButtonRequireSelectedStreamActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButtonRequireSelectedStreamActionPerformed try { int index = jComboBoxRemoteServices.getSelectedIndex(); if (index != -1) { final ServiceResponse service = availableServices.elementAt(index); final String stream = jComboBoxFileList.getSelectedItem().toString(); System.out.println( "StreamClientJFrame.jButtonRequireSelectedFileActionPerformed stream " + stream); JRadioButton jrbStreamProtocol = null; for (Enumeration<?> e = buttonGroupStreamProtocol.getElements(); e.hasMoreElements(); ) { JRadioButton b = (JRadioButton) e.nextElement(); if (b.getModel() == buttonGroupStreamProtocol.getSelection()) { jrbStreamProtocol = b; } } final String streamProtocol = jrbStreamProtocol.getText(); JRadioButton jrbRampProtocol = null; for (Enumeration<?> e = buttonGroupRampProtocol.getElements(); e.hasMoreElements(); ) { JRadioButton b = (JRadioButton) e.nextElement(); if (b.getModel() == buttonGroupRampProtocol.getSelection()) { jrbRampProtocol = b; } } final String rampProtocol = jrbRampProtocol.getText(); // sc.getStream(service, stream, streamProtocol, rampProtocol); Thread t = new Thread( new Runnable() { @Override public void run() { try { sc.getStream(service, stream, streamProtocol, rampProtocol); } catch (Exception ex) { ex.printStackTrace(); } } }); t.start(); } } catch (Exception e) { e.printStackTrace(); } } // GEN-LAST:event_jButtonRequireSelectedStreamActionPerformed
/** Creates new form CommunicationDialog */ public CommunicationDialog(java.awt.Frame parent, boolean modal, SimulatorConfig sc) { super(parent, modal); simConfig = sc; initComponents(); // Select current model for (Enumeration e = bGroup.getElements(); e.hasMoreElements(); ) { JRadioButton b = (JRadioButton) e.nextElement(); if (b.getModel().getMnemonic() - 48 == simConfig.getCommModel().ordinal()) { b.setSelected(true); } } // Let window X being clicked be handled by windowClosing method setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); // center on screen Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); int x = (dim.width - getSize().width) / 2; int y = (dim.height - getSize().height) / 2; setLocation(x, y); this.addWindowListener(windowListener); setVisible(true); }
private void jRadioButton5StateChanged( javax.swing.event.ChangeEvent evt) { // GEN-FIRST:event_jRadioButton5StateChanged JRadioButton rb = (JRadioButton) evt.getSource(); if (rb.getModel() == buttonGroup1.getSelection()) { this.isConsultaPorResponsavel = true; refreshButtons(); } } // GEN-LAST:event_jRadioButton5StateChanged
protected void setBrowsePanelVisable() { if (selectButtonGroup.getSelection() == fromRadioButton.getModel()) { dirLabel.setEnabled(true); dirTextField.setEnabled(true); browseButton.setEnabled(true); } else { dirLabel.setEnabled(false); dirTextField.setEnabled(false); browseButton.setEnabled(false); } }
@Override public void fillModel() { TimeRangeStepModel model = TimeRangeStepModel.getInstance(); // there is a own time range defined if (timeRangeGroup.getSelection() == miscTimeRange.getModel()) { model.setTimeRangeTyp(TimeRangeStepModel.MISC_TIME_RANGE); SimpleDateFormat df = new SimpleDateFormat("dd-mm-yyyy"); final GregorianCalendar fromDate = new GregorianCalendar(); final GregorianCalendar toDate = new GregorianCalendar(); try { fromDate.setTime(df.parse(fromDateTxt.getText())); toDate.setTime(df.parse(toDateTxt.getText())); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } model.setFromDate(fromDate); model.setToDate(toDate); } else { if (timeRangeGroup.getSelection() == easterbreak.getModel()) { model.setTimeRangeTyp(TimeRangeStepModel.EASTERBREAK_TIME_RANGE); } else if (timeRangeGroup.getSelection() == winterbreakBtn.getModel()) { model.setTimeRangeTyp(TimeRangeStepModel.WINTERBREAK_TIME_RANGE); } else if (timeRangeGroup.getSelection() == summerbreakBtn.getModel()) { model.setTimeRangeTyp(TimeRangeStepModel.SUMMERBREAK_TIME_RANGE); } else if (timeRangeGroup.getSelection() == autumbreakBtn.getModel()) { model.setTimeRangeTyp(TimeRangeStepModel.AUTUMNBREAK_TIME_RANGE); } SwingUtilities.invokeLater( new Runnable() { @Override public void run() { EventCollector collector = EventCollector.getInstance(); collector.setHolidayView(); } }); } }
/** * @param parent * @param title * @param choices * @return the index into choices which was selected */ public int showRadioChoiceDialog(Component parent, String title, String[] choices) { ButtonGroup group = new ButtonGroup(); Box panel = Box.createVerticalBox(); Map<ButtonModel, Integer> map = new HashMap<ButtonModel, Integer>(); for (int i = 0; i < choices.length; ++i) { JRadioButton button = new JRadioButton(choices[i], i == 0); group.add(button); panel.add(button); map.put(button.getModel(), i); } JOptionPane.showMessageDialog(parent, panel, title, JOptionPane.PLAIN_MESSAGE); Integer selection = map.get(group.getSelection()); if (selection == null) selection = -1; return selection; }
/** * Returns the currently selected stack trace level. The radio buttons store their stack trace * level as a client property so once we get the selected button, we know the level. This way, we * don't have to edit this if new levels are created. Unfortunately, Swing doesn't have an easy * way to get the actual button from the group. * * @return the selected stack trace level */ private ShowStacktrace getSelectedStackTraceLevel() { ButtonModel selectedButtonModel = stackTraceButtonGroup.getSelection(); if (selectedButtonModel != null) { Enumeration<AbstractButton> buttonEnumeration = stackTraceButtonGroup.getElements(); while (buttonEnumeration.hasMoreElements()) { JRadioButton radioButton = (JRadioButton) buttonEnumeration.nextElement(); if (radioButton.getModel() == selectedButtonModel) { ShowStacktrace level = (ShowStacktrace) radioButton.getClientProperty(STACK_TRACE_LEVEL_CLIENT_PROPERTY); return level; } } } return ShowStacktrace.INTERNAL_EXCEPTIONS; }
/** * Returns whether additional keywords are to be placed after the search string or before. * * @return <code>true</code> if additional keywords should be placed after the search string, * <code>false</code> if they are placed before the search string */ public boolean getAdditionalKeywordsAfterSearchString() { return bgAdditionalKeywordsPlacement.isSelected(rbAfterSearchString.getModel()); }
public LensPurposeType getPurpose() { if (buttonGroup.isSelected(labelbutton.getModel())) return LensPurposeType.LABEL; else if (buttonGroup.isSelected(defaultButton.getModel())) return LensPurposeType.DEFAULT; return LensPurposeType.NOT_SPECIFIED; }
public Terrain() { geometrySelection = new JPanel(new GridLayout(3, 1)); ButtonGroup terrainGeometrySelection = new ButtonGroup(); JRadioButton button = new JRadioButton(GeometryType.FLAT.getName()); geomNameToButton.put(GeometryType.FLAT.getName(), button); button .getModel() .addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setGeometryType(GeometryType.FLAT); } }); terrainGeometrySelection.add(button); geometrySelection.add(button); geometryButtons.put(GeometryType.FLAT, button.getModel()); button = new JRadioButton(GeometryType.NON_FLAT.getName()); geomNameToButton.put(GeometryType.NON_FLAT.getName(), button); button .getModel() .addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setGeometryType(GeometryType.NON_FLAT); } }); terrainGeometrySelection.add(button); geometrySelection.add(button); geometryButtons.put(GeometryType.NON_FLAT, button.getModel()); button = new JRadioButton(GeometryType.CUSTOM.getName()); geomNameToButton.put(GeometryType.CUSTOM.getName(), button); button .getModel() .addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setGeometryType(GeometryType.CUSTOM); } }); terrainGeometrySelection.add(button); geometrySelection.add(button); geometryButtons.put(GeometryType.CUSTOM, button.getModel()); ButtonGroup terrainTextureSelection = new ButtonGroup(); List<JRadioButton> buttons = new LinkedList<JRadioButton>(); for (String[] tex : defaultLandscapes) { final ImageData id = loadTexture(tex[1]); if (id == null) continue; imageMap.put(tex[0], id); button = new JRadioButton(tex[0]); texNameToButton.put(tex[0], button); button .getModel() .addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setTexture(id); } }); terrainTextureSelection.add(button); buttons.add(button); } int numRows = Math.round(.1f + (imageMap.size() + 2) * .5f); texureSelection = new JPanel(new GridLayout(numRows, 2)); for (JRadioButton b : buttons) { texureSelection.add(b); } button = new JRadioButton("none"); button .getModel() .addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setTexture(null); } }); terrainTextureSelection.add(button); texureSelection.add(button); texNameToButton.put("none", button); button = new JRadioButton("custom"); button .getModel() .addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setCustomTexture(); } }); terrainTextureSelection.add(button); texureSelection.add(button); texNameToButton.put("custom", button); }
public boolean isExistFile() { return selectButtonGroup.getSelection() == fromRadioButton.getModel(); }
public boolean isNewFile() { return selectButtonGroup.getSelection() == newRadioButton.getModel(); }
/** Create the panel. */ public MatchPanel(String matchName) { m_resultPanel = null; m_alliances = new Alliance[2]; m_allianceText = new JLabel[2][3]; m_matchName = matchName; m_redWin = true; m_twoGame = true; for (int i = 0; i < m_alliances.length; i++) { m_alliances[i] = new Alliance(-1); } setLayout( new MigLayout( "", "[35.00px][35.00px][35.00px][50.00px]", "[20.00][:20.00:20.00][:20.00:20.00]")); // Build Red alliance text for (int i = 0; i < 2; i++) { for (int j = 0; j < 3; j++) { JLabel label = new JLabel("9999"); label.setHorizontalAlignment(SwingConstants.CENTER); label.setBackground(i == 0 ? Color.RED : Color.BLUE); label.setForeground(i == 0 ? Color.BLACK : Color.WHITE); label.setOpaque(true); m_allianceText[i][j] = label; add(label, "cell " + j + " " + 2 * i + ",grow"); } } // JLabel label = new JLabel("9999"); // label.setHorizontalAlignment(SwingConstants.CENTER); // label.setBackground(Color.RED); // label.setOpaque(true); // add(label, "cell 0 0,grow"); // // JLabel label_1 = new JLabel("9999"); // label_1.setBackground(Color.RED); // add(label_1, "cell 1 0,alignx center"); // // JLabel label_2 = new JLabel("9999"); // label_2.setBackground(Color.RED); // add(label_2, "cell 2 0,alignx center"); JLabel lblQf = new JLabel(m_matchName); add(lblQf, "cell 0 1"); m_lengthGroup = new ButtonGroup(); JRadioButton twoGame = new JRadioButton("2"); twoGame.setActionCommand("twoGame"); twoGame.addActionListener(this); m_lengthGroup.add(twoGame); twoGame.setSelected(true); m_twoGameModel = twoGame.getModel(); add(twoGame, "cell 1 1"); JRadioButton threeGame = new JRadioButton("3"); threeGame.setActionCommand("threeGame"); threeGame.addActionListener(this); m_lengthGroup.add(threeGame); m_threeGameModel = threeGame.getModel(); add(threeGame, "cell 2 1"); // // JLabel label_3 = new JLabel("9999"); // add(label_3, "cell 0 2,alignx center"); // // JLabel label_4 = new JLabel("9999"); // add(label_4, "cell 1 2,alignx center"); // // JLabel label_5 = new JLabel("9999"); // add(label_5, "cell 2 2,alignx center"); m_winGroup = new ButtonGroup(); JRadioButton redWin = new JRadioButton("Win"); redWin.setActionCommand("redWin"); redWin.addActionListener(this); m_winGroup.add(redWin); redWin.setSelected(true); m_redWinModel = redWin.getModel(); add(redWin, "cell 3 0"); JRadioButton blueWin = new JRadioButton("Win"); blueWin.setActionCommand("blueWin"); blueWin.addActionListener(this); m_winGroup.add(blueWin); m_blueWinModel = blueWin.getModel(); add(blueWin, "cell 3 2"); redraw(); }
/** * 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. */ @SuppressWarnings("unchecked") private void initComponents() { jPanel1 = new JPanel(); jPanel3 = new JPanel(); jLabelForBrowseOPCItem = new JLabel(); jLabelForFilterCondition = new JLabel(); jTextFieldForFilterCondition = new JTextField(); jScrollPaneForBrowseOPCItem = new JScrollPane(); jTree1 = new JTree(); jScrollPaneForOPCItems = new JScrollPane(); opcItemsPanel = new JPanel(); jPanel2 = new JPanel(); jLabelForAccessPath = new JLabel(); jTextFieldForAccessPath = new JTextField(); jLabelForOPCItemName = new JLabel(); jTextFieldForOPCItemName = new JTextField(); confirmButton = new JButton(); cancelButton = new JButton(); jPanel4 = new JPanel(); jRadioButtonForNativeType = new JRadioButton(); jRadioButtonForBool = new JRadioButton(); jRadioButtonForString = new JRadioButton(); jRadioButtonForShort = new JRadioButton(); jRadioButtonForLong = new JRadioButton(); jRadioButtonForDouble = new JRadioButton(); varStyleButtonGroup = new ButtonGroup(); varStyleButtonGroup.add(jRadioButtonForNativeType); varStyleButtonGroup.add(jRadioButtonForBool); varStyleButtonGroup.add(jRadioButtonForString); varStyleButtonGroup.add(jRadioButtonForShort); varStyleButtonGroup.add(jRadioButtonForLong); varStyleButtonGroup.add(jRadioButtonForDouble); varStyleButtonGroup.setSelected(jRadioButtonForNativeType.getModel(), true); selectItemButtonGroup = new ButtonGroup(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); jLabelForBrowseOPCItem.setText(resourceMap.getString("jLabelForBrowseOPCItem.text")); jLabelForFilterCondition.setText(resourceMap.getString("jLabelForFilterCondition.text")); jTextFieldForFilterCondition.setColumns(12); jTextFieldForFilterCondition.setText( resourceMap.getString("jTextFieldForFilterCondition.text")); GroupLayout jPanel3Layout = new GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout .createParallelGroup(Alignment.LEADING) .addGroup( jPanel3Layout .createSequentialGroup() .addContainerGap() .addComponent(jLabelForBrowseOPCItem) .addGap(106, 106, 106) .addComponent(jLabelForFilterCondition) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent( jTextFieldForFilterCondition, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap(41, Short.MAX_VALUE))); jPanel3Layout.setVerticalGroup( jPanel3Layout .createParallelGroup(Alignment.LEADING) .addGroup( jPanel3Layout .createSequentialGroup() .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup( jPanel3Layout .createParallelGroup(Alignment.BASELINE) .addComponent(jLabelForBrowseOPCItem) .addComponent(jLabelForFilterCondition) .addComponent( jTextFieldForFilterCondition, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addContainerGap())); jScrollPaneForBrowseOPCItem.setName("jScrollPaneForBrowseOPCItem"); jScrollPaneForBrowseOPCItem.setViewportView(jTree1); opcItemsPanel.setBackground(resourceMap.getColor("opcItemsPanel.background")); jScrollPaneForOPCItems.setViewportView(opcItemsPanel); GroupLayout jPanel1Layout = new GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout .createParallelGroup(Alignment.LEADING) .addGroup( jPanel1Layout .createSequentialGroup() .addContainerGap() .addGroup( jPanel1Layout .createParallelGroup(Alignment.LEADING) .addGroup( jPanel1Layout .createSequentialGroup() .addComponent( jScrollPaneForBrowseOPCItem, GroupLayout.PREFERRED_SIZE, 170, GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent( jScrollPaneForOPCItems, GroupLayout.PREFERRED_SIZE, 150, GroupLayout.PREFERRED_SIZE)) .addComponent( jPanel3, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); jPanel1Layout.setVerticalGroup( jPanel1Layout .createParallelGroup(Alignment.LEADING) .addGroup( jPanel1Layout .createSequentialGroup() .addComponent( jPanel3, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup( jPanel1Layout .createParallelGroup(Alignment.LEADING) .addComponent( jScrollPaneForOPCItems, GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE) .addComponent( jScrollPaneForBrowseOPCItem, GroupLayout.PREFERRED_SIZE, 168, GroupLayout.PREFERRED_SIZE)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jLabelForAccessPath.setText(resourceMap.getString("jLabelForAccessPath.text")); jTextFieldForAccessPath.setColumns(25); jTextFieldForAccessPath.setText(resourceMap.getString("jTextFieldForAccessPath.text")); jLabelForOPCItemName.setText(resourceMap.getString("jLabelForOPCItemName.text")); jTextFieldForOPCItemName.setColumns(25); jTextFieldForOPCItemName.setText(resourceMap.getString("jTextFieldForOPCItemName.text")); confirmButton.setAction(actionMap.get("confirm")); cancelButton.setAction(actionMap.get("cancel")); GroupLayout jPanel2Layout = new GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout .createParallelGroup(Alignment.LEADING) .addGroup( jPanel2Layout .createSequentialGroup() .addGap(18, 18, 18) .addGroup( jPanel2Layout .createParallelGroup(Alignment.LEADING) .addComponent(jLabelForOPCItemName) .addComponent(jLabelForAccessPath)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup( jPanel2Layout .createParallelGroup(Alignment.LEADING) .addComponent( jTextFieldForAccessPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( jTextFieldForOPCItemName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED, 45, Short.MAX_VALUE) .addGroup( jPanel2Layout .createParallelGroup(Alignment.LEADING) .addComponent(cancelButton) .addComponent(confirmButton)) .addContainerGap())); jPanel2Layout.setVerticalGroup( jPanel2Layout .createParallelGroup(Alignment.LEADING) .addGroup( jPanel2Layout .createSequentialGroup() .addGap(22, 22, 22) .addGroup( jPanel2Layout .createParallelGroup(Alignment.BASELINE) .addComponent(jLabelForAccessPath) .addComponent( jTextFieldForAccessPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(confirmButton)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup( jPanel2Layout .createParallelGroup(Alignment.BASELINE) .addComponent(jLabelForOPCItemName) .addComponent( jTextFieldForOPCItemName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(cancelButton)) .addContainerGap(14, Short.MAX_VALUE))); jPanel4.setBorder( BorderFactory.createTitledBorder(resourceMap.getString("jPanel4.border.title"))); jRadioButtonForNativeType.setText(resourceMap.getString("jRadioButtonForNativeType.text")); jRadioButtonForNativeType.setName(TempOpcItemVariantType.VT_NATIVE); jRadioButtonForBool.setText(resourceMap.getString("jRadioButtonForBool.text")); jRadioButtonForBool.setName(TempOpcItemVariantType.VT_BOOL); jRadioButtonForString.setText(resourceMap.getString("jRadioButtonForString.text")); jRadioButtonForString.setName(TempOpcItemVariantType.VT_BSTR); jRadioButtonForShort.setText(resourceMap.getString("jRadioButtonForShort.text")); jRadioButtonForShort.setName(TempOpcItemVariantType.VT_I2); jRadioButtonForLong.setText(resourceMap.getString("jRadioButtonForLong.text")); jRadioButtonForLong.setName(TempOpcItemVariantType.VT_I4); jRadioButtonForDouble.setText(resourceMap.getString("jRadioButtonForDouble.text")); jRadioButtonForDouble.setName(TempOpcItemVariantType.VT_R8); GroupLayout jPanel4Layout = new GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup( jPanel4Layout .createParallelGroup(Alignment.LEADING) .addGroup( jPanel4Layout .createSequentialGroup() .addGap(22, 22, 22) .addGroup( jPanel4Layout .createParallelGroup(Alignment.LEADING) .addComponent(jRadioButtonForNativeType) .addComponent(jRadioButtonForBool) .addComponent(jRadioButtonForString)) .addGap(53, 53, 53) .addGroup( jPanel4Layout .createParallelGroup(Alignment.LEADING) .addComponent(jRadioButtonForLong) .addComponent(jRadioButtonForShort) .addComponent(jRadioButtonForDouble)) .addContainerGap(74, Short.MAX_VALUE))); jPanel4Layout.setVerticalGroup( jPanel4Layout .createParallelGroup(Alignment.LEADING) .addGroup( jPanel4Layout .createSequentialGroup() .addContainerGap() .addGroup( jPanel4Layout .createParallelGroup(Alignment.BASELINE) .addComponent(jRadioButtonForNativeType) .addComponent(jRadioButtonForShort)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup( jPanel4Layout .createParallelGroup(Alignment.BASELINE) .addComponent(jRadioButtonForBool) .addComponent(jRadioButtonForLong)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup( jPanel4Layout .createParallelGroup(Alignment.BASELINE) .addComponent(jRadioButtonForString) .addComponent(jRadioButtonForDouble)) .addContainerGap(19, Short.MAX_VALUE))); GroupLayout layout = new GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addGap(20, 20, 20) .addComponent( jPanel4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup( layout .createSequentialGroup() .addContainerGap() .addGroup( layout .createParallelGroup(Alignment.LEADING) .addComponent( jPanel1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( jPanel2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); layout.setVerticalGroup( layout .createParallelGroup(Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addComponent( jPanel2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent( jPanel1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent( jPanel4, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); setTitle(resourceMap.getString("view.title")); setResizable(false); pack(); }
CatenaSetting() { super(PeaFactory.getFrame()); setting = this; // setting.setUndecorated(true); setting.setAlwaysOnTop(true); this.setIconImage(MainView.getImage()); JPanel scryptPane = (JPanel) setting.getContentPane(); // new JPanel(); scryptPane.setBorder(new LineBorder(Color.GRAY, 2)); scryptPane.setLayout(new BoxLayout(scryptPane, BoxLayout.Y_AXIS)); JLabel scryptLabel = new JLabel("Settings for CATENA:"); scryptLabel.setPreferredSize(new Dimension(250, 30)); JLabel tipLabel1 = new JLabel("Settings for this session only"); tipLabel1.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); tipLabel1.setPreferredSize(new Dimension(250, 20)); scryptPane.add(scryptLabel); scryptPane.add(tipLabel1); JLabel instanceLabel = new JLabel("Select an instance of Catena:"); instanceLabel.setPreferredSize(new Dimension(250, 40)); scryptPane.add(instanceLabel); JLabel instanceRecommendedLabel = new JLabel("recommended: Dragonfly-Full"); instanceRecommendedLabel.setPreferredSize(new Dimension(250, 20)); instanceRecommendedLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); scryptPane.add(instanceRecommendedLabel); JRadioButton dragonflyFullButton = new JRadioButton("Dragonfly-Full"); dragonflyFullButton.setMnemonic(KeyEvent.VK_U); dragonflyFullButton.addActionListener(this); dragonflyFullButton.setActionCommand("Dragonfly-Full"); scryptPane.add(dragonflyFullButton); JRadioButton butterflyFullButton = new JRadioButton("Butterfly-Full"); butterflyFullButton.setMnemonic(KeyEvent.VK_U); butterflyFullButton.addActionListener(this); butterflyFullButton.setActionCommand("Butterfly-Full"); scryptPane.add(butterflyFullButton); JRadioButton dragonflyButton = new JRadioButton("Dragonfly"); dragonflyButton.setMnemonic(KeyEvent.VK_B); dragonflyButton.addActionListener(this); dragonflyButton.setActionCommand("Dragonfly"); scryptPane.add(dragonflyButton); JRadioButton butterflyButton = new JRadioButton("Butterfly"); butterflyButton.setMnemonic(KeyEvent.VK_B); butterflyButton.addActionListener(this); butterflyButton.setActionCommand("Butterfly"); scryptPane.add(butterflyButton); // Group the radio buttons. ButtonGroup group = new ButtonGroup(); group.add(dragonflyButton); group.add(dragonflyFullButton); group.add(butterflyButton); group.add(butterflyFullButton); group.setSelected(dragonflyFullButton.getModel(), true); scryptPane.add(Box.createVerticalStrut(20)); JLabel memoryLabel = new JLabel("Memory cost parameter GARLIC: "); memoryLabel.setPreferredSize(new Dimension(220, 40)); scryptPane.add(memoryLabel); memoryField = new JTextField() { private static final long serialVersionUID = 1L; public void processKeyEvent(KeyEvent ev) { char c = ev.getKeyChar(); try { // printable characters if (c > 31 && c < 65535 && c != 127) { Integer.parseInt(c + ""); // parse } super.processKeyEvent(ev); } catch (NumberFormatException nfe) { // if not a number: ignore } } }; memoryField.setText("18"); memoryField.setColumns(2); memoryField.setDragEnabled(true); memoryField .getDocument() .addDocumentListener( new DocumentListener() { public void changedUpdate(DocumentEvent e) { warn(); } public void removeUpdate(DocumentEvent e) { warn(); } public void insertUpdate(DocumentEvent e) { warn(); } public void warn() { int garlic = 0; try { garlic = Integer.parseInt(memoryField.getText()); } catch (Exception nfe) { errorLabel.setText("Invalid input"); return; } if (garlic == 0) { errorLabel.setText("Invalid value"); } else if (garlic < 14) { errorLabel.setText("Warning: Weak parameter"); } else if (garlic > 22 && garlic < 64) { errorLabel.setText("Warning: Long execution time"); } else if (garlic > 63) { errorLabel.setText("Invalid value: must be < 64"); } else { errorLabel.setText(""); } } }); memoryRecommendedLabel = new JLabel("recommended >= 18"); memoryRecommendedLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); JPanel memoryPanel = new JPanel(); memoryPanel.add(memoryField); memoryPanel.add(memoryRecommendedLabel); scryptPane.add(memoryPanel); scryptPane.add(Box.createVerticalStrut(10)); JLabel timeLabel = new JLabel("Time cost parameter LAMBDA: "); timeLabel.setPreferredSize(new Dimension(220, 40)); scryptPane.add(timeLabel); timeField = new JTextField() { private static final long serialVersionUID = 1L; public void processKeyEvent(KeyEvent ev) { char c = ev.getKeyChar(); try { // printable characters if (c > 31 && c < 65535 && c != 127) { Integer.parseInt(c + ""); // parse } super.processKeyEvent(ev); } catch (NumberFormatException nfe) { // if not a number: ignore } } }; timeField.setText("2"); timeField.setColumns(3); timeField.setDragEnabled(true); timeField .getDocument() .addDocumentListener( new DocumentListener() { public void changedUpdate(DocumentEvent e) { warn(); } public void removeUpdate(DocumentEvent e) { warn(); } public void insertUpdate(DocumentEvent e) { warn(); } public void warn() { int lambda = 0; try { lambda = Integer.parseInt(timeField.getText()); } catch (Exception nfe) { errorLabel.setText("Invalid input"); return; } if (lambda == 0) { errorLabel.setText("Invalid value"); } else if (lambda == 1) { errorLabel.setText("Warning: Weak parameter"); } else if (lambda > 4) { errorLabel.setText("Warning: Long execution time"); } else { errorLabel.setText(""); } } }); timeRecommendedLabel = new JLabel("recommended 2"); timeRecommendedLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); JPanel timePanel = new JPanel(); timePanel.add(timeField); timePanel.add(timeRecommendedLabel); scryptPane.add(timePanel); scryptPane.add(Box.createVerticalStrut(10)); errorLabel = new JLabel(""); errorLabel.setForeground(Color.RED); scryptPane.add(errorLabel); JButton scryptOkButton = new JButton("ok"); scryptOkButton.setActionCommand("newSetting"); scryptOkButton.addActionListener(this); scryptPane.add(scryptOkButton); setting.pack(); setting.setLocation(100, 100); setting.setVisible(true); }