List of usage examples for javax.swing JRadioButton JRadioButton
public JRadioButton(String text)
From source file:lab4.YouQuiz.java
private void updateAnswerForm() { contentPanel.answerPanel.removeAll(); final Question question = questionsArray.get(questionIndex); switch (question.type) { case Question.QUESTION_TYPE_MULTIPLE_CHOICE: case Question.QUESTION_TYPE_TRUE_FALSE: JRadioButton radioButton; final ButtonGroup radioGroup = new ButtonGroup(); for (int i = 0; i < ((MultipleChoiceQuestion) question).getChoices().size(); ++i) { radioButton = new JRadioButton(((MultipleChoiceQuestion) question).getChoices().get(i)); radioButton.setFont(new Font("Consolas", Font.PLAIN, 20)); radioGroup.add(radioButton); radioButton.setFocusable(false); contentPanel.answerPanel.add(radioButton); }/*from ww w . j a v a 2 s . c om*/ for (ActionListener al : contentPanel.checkButton.getActionListeners()) { contentPanel.checkButton.removeActionListener(al); } contentPanel.checkButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (question.checkAnswer(getSelectedButtonText(radioGroup))) { JOptionPane.showMessageDialog(null, "Thats Great, Correct Answer", "Excellent", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Oops! Wrong Answer. Its '" + question.getAnswer().get(0) + "'", "Sorry", JOptionPane.ERROR_MESSAGE); } } }); break; case Question.QUESTION_TYPE_SHORT_ANSWER: final JTextField answerText = new JTextField(25); answerText.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 20)); contentPanel.answerPanel.add(answerText); for (ActionListener al : contentPanel.checkButton.getActionListeners()) { contentPanel.checkButton.removeActionListener(al); } contentPanel.checkButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (question.checkAnswer(answerText.getText())) { JOptionPane.showMessageDialog(null, "Thats Great, Correct Answer", "Excellent", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Oops! Wrong Answer. Its '" + question.getAnswer().get(0) + "'", "Sorry", JOptionPane.ERROR_MESSAGE); } } }); break; } contentPanel.answerPanel.invalidate(); }
From source file:carolina.pegaLatLong.LatLong.java
private void btnGerarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGerarActionPerformed // TODO add your handling code here: List<JRadioButton> radios = new ArrayList<>(); JPanel painel = new JPanel(); JRadioButton btnEncontrados = new JRadioButton("Encontrados \n"); JRadioButton btnNaoEncontrados = new JRadioButton("No encontrados"); JRadioButton btnEncontradosMais = new JRadioButton("Mais de um encontrados"); JRadioButton btnTudo = new JRadioButton("Tudo"); ButtonGroup btnGroup = new ButtonGroup(); btnGroup.add(btnTudo);/*from www. j a v a 2 s.c o m*/ btnGroup.add(btnEncontrados); btnGroup.add(btnNaoEncontrados); btnGroup.add(btnEncontradosMais); //painel.add(btnTudo); painel.add(btnEncontrados); painel.add(btnNaoEncontrados); painel.add(btnEncontradosMais); JOptionPane.showMessageDialog(null, painel, "Escolha uma opo:", JOptionPane.QUESTION_MESSAGE); if (btnTudo.isSelected()) { System.err.println("Tudo selecionado!"); } else if (btnNaoEncontrados.isSelected()) { System.err.println("No encontrados!"); } else if (btnEncontrados.isSelected()) { try { geraCsv(listaResultado); } catch (IOException ex) { Logger.getLogger(LatLong.class.getName()).log(Level.SEVERE, null, ex); } } else if (btnEncontradosMais.isSelected()) { System.err.println("Encontrados mais"); } }
From source file:DialogDemo.java
private JPanel createIconDialogBox() { JButton showItButton = null;//ww w . ja v a 2 s . c o m final int numButtons = 6; JRadioButton[] radioButtons = new JRadioButton[numButtons]; final ButtonGroup group = new ButtonGroup(); final String plainCommand = "plain"; final String infoCommand = "info"; final String questionCommand = "question"; final String errorCommand = "error"; final String warningCommand = "warning"; final String customCommand = "custom"; radioButtons[0] = new JRadioButton("Plain (no icon)"); radioButtons[0].setActionCommand(plainCommand); radioButtons[1] = new JRadioButton("Information icon"); radioButtons[1].setActionCommand(infoCommand); radioButtons[2] = new JRadioButton("Question icon"); radioButtons[2].setActionCommand(questionCommand); radioButtons[3] = new JRadioButton("Error icon"); radioButtons[3].setActionCommand(errorCommand); radioButtons[4] = new JRadioButton("Warning icon"); radioButtons[4].setActionCommand(warningCommand); radioButtons[5] = new JRadioButton("Custom icon"); radioButtons[5].setActionCommand(customCommand); for (int i = 0; i < numButtons; i++) { group.add(radioButtons[i]); } radioButtons[0].setSelected(true); showItButton = new JButton("Show it!"); showItButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String command = group.getSelection().getActionCommand(); // no icon if (command == plainCommand) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "A plain message", JOptionPane.PLAIN_MESSAGE); // information icon } else if (command == infoCommand) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane informational dialog", JOptionPane.INFORMATION_MESSAGE); // XXX: It doesn't make sense to make a question with // XXX: only one button. // XXX: See "Yes/No (but not in those words)" for a better solution. // question icon } else if (command == questionCommand) { JOptionPane.showMessageDialog(frame, "You shouldn't use a message dialog " + "(like this)\n" + "for a question, OK?", "Inane question", JOptionPane.QUESTION_MESSAGE); // error icon } else if (command == errorCommand) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane error", JOptionPane.ERROR_MESSAGE); // warning icon } else if (command == warningCommand) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane warning", JOptionPane.WARNING_MESSAGE); // custom icon } else if (command == customCommand) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane custom dialog", JOptionPane.INFORMATION_MESSAGE, icon); } } }); return create2ColPane(iconDesc + ":", radioButtons, showItButton); }
From source file:com.att.aro.ui.view.menu.datacollector.DeviceDialogOptions.java
private void loadRadioGroupVideo() { txtLREZ = ResourceBundleHelper.getMessageString("dlog.collector.option.video.orig"); txtHDEF = ResourceBundleHelper.getMessageString("dlog.collector.option.video.hdef"); txtSDEF = ResourceBundleHelper.getMessageString("dlog.collector.option.video.sdef"); txtNONE = ResourceBundleHelper.getMessageString("dlog.collector.option.video.none"); btn_lrez = new JRadioButton(txtLREZ); btn_hdef = new JRadioButton(txtHDEF); btn_sdef = new JRadioButton(txtSDEF); btn_none = new JRadioButton(txtNONE); btn_lrez.addActionListener(this); btn_hdef.addActionListener(this); btn_sdef.addActionListener(this); btn_none.addActionListener(this); ButtonGroup radioBtnVideo = new ButtonGroup(); radioBtnVideo.add(btn_lrez);/*ww w . java2s . c o m*/ radioBtnVideo.add(btn_hdef); radioBtnVideo.add(btn_sdef); radioBtnVideo.add(btn_none); }
From source file:eu.apenet.dpt.standalone.gui.APETabbedPane.java
private JComponent makeCheckboxes() { xsltPanel.setLayout(new BoxLayout(xsltPanel, BoxLayout.PAGE_AXIS)); xsltPanel.add(stylesheetLabel);// ww w .jav a2s.c o m JRadioButton radioButton; for (File xsltFile : Utilities.getXsltFiles()) { radioButton = new JRadioButton(xsltFile.getName()); if (xsltFile.getName().equals(retrieveFromDb.retrieveDefaultXsl())) radioButton.setSelected(true); radioButton.addActionListener(new XsltSelectorListener(dataPreparationToolGUI)); dataPreparationToolGUI.getGroupXslt().add(radioButton); xsltPanel.add(radioButton); xsltPanel.add(Box.createRigidArea(new Dimension(0, 10))); } return xsltPanel; }
From source file:edu.ucla.stat.SOCR.applications.demo.PortfolioApplication2.java
public void addRadioButton2Left(String text, String toolTipText, String[] bValues, int defaultIndex, ActionListener l) {/*from ww w. j a v a 2 s . c om*/ JPanel in = new JPanel(); in.add(Box.createVerticalGlue()); in.add(new JLabel(text)); ButtonGroup group = new ButtonGroup(); rButtons = new JRadioButton[bValues.length]; for (int i = 0; i < bValues.length; i++) { rButtons[i] = new JRadioButton(bValues[i]); rButtons[i].setName(bValues[i]); rButtons[i].addActionListener(l); rButtons[i].setActionCommand(bValues[i]); in.add(rButtons[i]); group.add(rButtons[i]); if (defaultIndex == i) rButtons[i].setSelected(true); } leftControl.add(in); }
From source file:com.google.code.facebook.graph.sna.applet.FacebookGraphApplet.java
/** * create an instance of a simple graph with controls to * demo the zoom features./* www .jav a 2s . c o m*/ * */ @Override public void init() { super.init(); // create a simple graph for the demo fetchUserGraph(); final Collection<? extends Entity<FieldEnum, ConnectionEnum>> vertices = graph.getVertices(); // a Map for the labels Map<Entity<FieldEnum, ConnectionEnum>, String> map = new HashMap<Entity<FieldEnum, ConnectionEnum>, String>(); Iterator<? extends Entity<FieldEnum, ConnectionEnum>> iterator = vertices.iterator(); while (iterator.hasNext()) { Entity<FieldEnum, ConnectionEnum> entity = iterator.next(); map.put(entity, entity.getLabel()); } FRLayout<Entity<FieldEnum, ConnectionEnum>, EdgeAdapter<ConnectionEnum>> layout = new FRLayout<Entity<FieldEnum, ConnectionEnum>, EdgeAdapter<ConnectionEnum>>( (Graph<Entity<FieldEnum, ConnectionEnum>, EdgeAdapter<ConnectionEnum>>) graph); layout.setMaxIterations(100); vv = new VisualizationViewer<Entity<FieldEnum, ConnectionEnum>, EdgeAdapter<ConnectionEnum>>(layout, new Dimension(2000, 2000)); Transformer<Entity<FieldEnum, ConnectionEnum>, Paint> vpf = new PickableVertexPaintTransformer<Entity<FieldEnum, ConnectionEnum>>( vv.getPickedVertexState(), Color.white, Color.yellow); vv.getRenderContext().setVertexFillPaintTransformer(vpf); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<EdgeAdapter<ConnectionEnum>>(vv.getPickedEdgeState(), Color.black, Color.cyan)); vv.setBackground(Color.white); // a Map for the Icons final Map<Entity<FieldEnum, ConnectionEnum>, Icon> iconMap = new HashMap<Entity<FieldEnum, ConnectionEnum>, Icon>(); new Thread(new Runnable() { public void run() { Iterator<? extends Entity<FieldEnum, ConnectionEnum>> iterator = vertices.iterator(); while (iterator.hasNext()) { try { Entity<FieldEnum, ConnectionEnum> entity = iterator.next(); // Icon icon = // new LayeredIcon(new ImageIcon("http://facebookgraph.appspot.com/proxy?url=" + entity.getPicture(PictureType.SQUARE), "Profile Picture").getImage()); // iconMap.put(entity, icon); Image image = getImageFromEntity(entity); if (image != null && image.getWidth(null) > 0 && image.getHeight(null) > 0) { Icon icon = new LayeredIcon(image); iconMap.put(entity, icon); if ((iconMap.size() % 5) == 0) { vv.repaint(); } } } catch (Exception ex) { ex.printStackTrace(); } } vv.repaint(); } }).start(); final Transformer<Entity<FieldEnum, ConnectionEnum>, String> vertexStringerImpl = new VertexStringerImpl<Entity<FieldEnum, ConnectionEnum>>( map); Transformer<EdgeAdapter<ConnectionEnum>, String> edgeStringerImpl = new Transformer<EdgeAdapter<ConnectionEnum>, String>() { public String transform(EdgeAdapter<ConnectionEnum> edge) { return edge.toString(); } }; vv.getRenderContext().setEdgeLabelTransformer(edgeStringerImpl); vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl); vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan)); vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan)); // features on and off. For a real application, use VertexIconAndShapeFunction instead. final VertexIconShapeTransformer<Entity<FieldEnum, ConnectionEnum>> vertexImageShapeFunction = new VertexIconShapeTransformer<Entity<FieldEnum, ConnectionEnum>>( new EllipseVertexShapeTransformer<Entity<FieldEnum, ConnectionEnum>>()); final DefaultVertexIconTransformer<Entity<FieldEnum, ConnectionEnum>> vertexIconFunction = new DefaultVertexIconTransformer<Entity<FieldEnum, ConnectionEnum>>(); vertexImageShapeFunction.setIconMap(iconMap); vertexIconFunction.setIconMap(iconMap); vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction); vv.getRenderContext().setVertexIconTransformer(vertexIconFunction); // Get the pickedState and add a listener that will decorate the // Vertex images with a checkmark icon when they are picked PickedState<Entity<FieldEnum, ConnectionEnum>> ps = vv.getPickedVertexState(); ps.addItemListener(new PickWithIconListener(vertexIconFunction)); // add a listener for ToolTips vv.setVertexToolTipTransformer(new Transformer<Entity<FieldEnum, ConnectionEnum>, String>() { @Override public String transform(Entity<FieldEnum, ConnectionEnum> entity) { return entity.getDescription(); } }); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JComboBox modeBox = graphMouse.getModeComboBox(); JPanel modePanel = new JPanel(); modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(scaleGrid); controls.add(modePanel); content.add(controls, BorderLayout.SOUTH); this.viewSupport = new MagnifyImageLensSupport<Entity<FieldEnum, ConnectionEnum>, EdgeAdapter<ConnectionEnum>>( vv); // new ViewLensSupport<Number,Number>(vv, new HyperbolicShapeTransformer(vv, // vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), // new ModalLensGraphMouse()); this.modelSupport = new LayoutLensSupport<Entity<FieldEnum, ConnectionEnum>, EdgeAdapter<ConnectionEnum>>( vv); graphMouse.addItemListener(modelSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(viewSupport.getGraphMouse().getModeListener()); ButtonGroup radio = new ButtonGroup(); JRadioButton none = new JRadioButton("None"); none.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (viewSupport != null) { viewSupport.deactivate(); } if (modelSupport != null) { modelSupport.deactivate(); } } }); none.setSelected(true); JRadioButton hyperView = new JRadioButton("View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JRadioButton hyperModel = new JRadioButton("Layout"); hyperModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { modelSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); radio.add(none); radio.add(hyperView); radio.add(hyperModel); JMenuBar menubar = new JMenuBar(); JMenu modeMenu = graphMouse.getModeMenu(); menubar.add(modeMenu); JPanel lensPanel = new JPanel(new GridLayout(2, 0)); lensPanel.setBorder(BorderFactory.createTitledBorder("Lens")); lensPanel.add(none); lensPanel.add(hyperView); lensPanel.add(hyperModel); controls.add(lensPanel); }
From source file:eu.apenet.dpt.standalone.gui.APETabbedPane.java
private JComponent makeCheckboxesXsd() { xsdPanel.setLayout(new BoxLayout(xsdPanel, BoxLayout.PAGE_AXIS)); xsdPanel.add(schemaLabel);/*from ww w. j a v a 2 s .c o m*/ JRadioButton radioButton; for (Xsd_enum xsdEnum : Xsd_enum.values()) { radioButton = new JRadioButton(xsdEnum.getReadableName()); if (xsdEnum.getReadableName().equals(retrieveFromDb.retrieveDefaultXsd())) radioButton.setSelected(true); radioButton.addActionListener(new XsdSelectorListener(dataPreparationToolGUI)); dataPreparationToolGUI.getGroupXsd().add(radioButton); xsdPanel.add(radioButton); xsdPanel.add(Box.createRigidArea(new Dimension(0, 10))); } for (XsdObject additionalXsd : retrieveFromDb.retrieveAdditionalXsds()) { radioButton = new JRadioButton(additionalXsd.getName()); radioButton.addActionListener(new XsdSelectorListener(dataPreparationToolGUI)); dataPreparationToolGUI.getGroupXsd().add(radioButton); xsdPanel.add(radioButton); xsdPanel.add(Box.createRigidArea(new Dimension(0, 10))); } return xsdPanel; }
From source file:com.att.aro.ui.view.menu.datacollector.DeviceDialogOptions.java
private void loadRadioGroupVideoOrient() { txtPortrait = ResourceBundleHelper.getMessageString("dlog.collector.option.video.orient.portrait"); txtLandscape = ResourceBundleHelper.getMessageString("dlog.collector.option.video.orient.landscape"); btn_portrait = new JRadioButton(txtPortrait); btn_landscape = new JRadioButton(txtLandscape); btn_portrait.addActionListener(this); btn_landscape.addActionListener(this); ButtonGroup radioBtnVideoOrient = new ButtonGroup(); radioBtnVideoOrient.add(btn_portrait); radioBtnVideoOrient.add(btn_landscape); }
From source file:edu.ku.brc.af.auth.UserAndMasterPasswordMgr.java
/** * Displays a dialog used for editing the Master Username and Password. * @param isLocal whether u/p is stored locally or not * @param usrName/*w w w . j av a 2 s . c o m*/ * @param dbName * @param masterPath the path to the password * @return whether to ask for the information because it wasn't found */ protected boolean askForInfo(final Boolean isLocal, final String usrName, final String dbName, final String masterPath) { loadAndPushResourceBundle("masterusrpwd"); FormLayout layout = new FormLayout("p, 2px, f:p:g, 4px, p, 4px, p, 4px, p", "p,2px,p,2px,p,2dlu,p,2dlu,p"); PanelBuilder pb = new PanelBuilder(layout); pb.setDefaultDialogBorder(); ButtonGroup group = new ButtonGroup(); final JRadioButton isNetworkRB = new JRadioButton(getResourceString("IS_NET_BASED")); final JRadioButton isPrefBasedRB = new JRadioButton(getResourceString("IS_ENCRYPTED_KEY")); isPrefBasedRB.setSelected(true); group.add(isNetworkRB); group.add(isPrefBasedRB); final JTextField keyTxt = createTextField(35); final JTextField urlTxt = createTextField(35); final JLabel keyLbl = createI18NFormLabel("ENCRYPTED_USRPWD"); final JLabel urlLbl = createI18NFormLabel("URL"); final JButton createBtn = createI18NButton("CREATE_KEY"); final JButton copyCBBtn = createIconBtn("ClipboardCopy", IconManager.IconSize.Std24, "CPY_TO_CB_TT", null); final JButton pasteCBBtn = createIconBtn("ClipboardPaste", IconManager.IconSize.Std24, "CPY_FROM_CB_TT", null); // retrieves the encrypted key for the current settings in the dialog String dbNameFromForm = AppPreferences.getLocalPrefs().get("login.databases_selected", null); if (isNotEmpty(dbNameFromForm) && isNotEmpty(usersUserName)) { String masterKey = getMasterPrefPath(usersUserName, dbNameFromForm, true); if (isNotEmpty(masterKey)) { String encryptedKey = AppPreferences.getLocalPrefs().get(masterKey, null); if (isNotEmpty(encryptedKey) && !encryptedKey.startsWith("http")) { keyTxt.setText(encryptedKey); } } } CellConstraints cc = new CellConstraints(); int y = 1; pb.add(createI18NFormLabel("MASTER_LOC"), cc.xywh(1, y, 1, 3)); pb.add(isPrefBasedRB, cc.xy(3, y)); y += 2; pb.add(isNetworkRB, cc.xy(3, y)); y += 2; pb.addSeparator("", cc.xyw(1, y, 9)); y += 2; pb.add(keyLbl, cc.xy(1, y)); pb.add(keyTxt, cc.xy(3, y)); pb.add(createBtn, cc.xy(5, y)); pb.add(copyCBBtn, cc.xy(7, y)); pb.add(pasteCBBtn, cc.xy(9, y)); y += 2; pb.add(urlLbl, cc.xy(1, y)); pb.add(urlTxt, cc.xy(3, y)); y += 2; boolean isEditMode = isLocal != null && isNotEmpty(masterPath); if (isEditMode) { isPrefBasedRB.setSelected(isLocal); if (isLocal) { keyTxt.setText(masterPath); } else { urlTxt.setText(masterPath); } } copyCBBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // Copy to Clipboard UIHelper.setTextToClipboard(keyTxt.getText()); } }); pasteCBBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { keyTxt.setText(UIHelper.getTextFromClipboard()); } }); final CustomDialog dlg = new CustomDialog((Frame) null, getResourceString("MASTER_TITLE"), true, CustomDialog.OKCANCELHELP, pb.getPanel()); if (!isEditMode) { dlg.setOkLabel(getResourceString("CONT")); dlg.setCancelLabel(getResourceString("BACK")); } dlg.setHelpContext("MASTERPWD_MAIN"); dlg.createUI(); dlg.getOkBtn().setEnabled(false); urlLbl.setEnabled(false); urlTxt.setEnabled(false); copyCBBtn.setEnabled(true); pasteCBBtn.setEnabled(true); DocumentListener dl = new DocumentAdaptor() { @Override protected void changed(DocumentEvent e) { dlg.getOkBtn().setEnabled((isPrefBasedRB.isSelected() && !keyTxt.getText().isEmpty()) || (isNetworkRB.isSelected() && !urlTxt.getText().isEmpty())); } }; keyTxt.getDocument().addDocumentListener(dl); urlTxt.getDocument().addDocumentListener(dl); ChangeListener chgListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { boolean isNet = isNetworkRB.isSelected(); keyLbl.setEnabled(!isNet); keyTxt.setEnabled(!isNet); createBtn.setEnabled(!isNet); copyCBBtn.setEnabled(!isNet); pasteCBBtn.setEnabled(!isNet); urlLbl.setEnabled(isNet); urlTxt.setEnabled(isNet); dlg.getOkBtn().setEnabled((isPrefBasedRB.isSelected() && !keyTxt.getText().isEmpty()) || (isNetworkRB.isSelected() && !urlTxt.getText().isEmpty())); } }; isNetworkRB.addChangeListener(chgListener); isPrefBasedRB.addChangeListener(chgListener); boolean isPref = AppPreferences.getLocalPrefs().getBoolean(getIsLocalPrefPath(usrName, dbName, true), true); isNetworkRB.setSelected(!isPref); isPrefBasedRB.setSelected(isPref); createBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String[] keys = getUserNamePasswordKey(); if (keys != null && keys.length == 4) { String encryptedStr = encrypt(keys[0], keys[1], keys[3]); if (encryptedStr != null) { keyTxt.setText(encryptedStr); dlg.getOkBtn().setEnabled(true); usersUserName = keys[2]; } } } }); popResourceBundle(); dlg.setVisible(true); if (!dlg.isCancelled()) { String value; if (isNetworkRB.isSelected()) { value = StringEscapeUtils.escapeHtml(urlTxt.getText()); } else { value = keyTxt.getText(); } AppPreferences.getLocalPrefs().putBoolean(getIsLocalPrefPath(usrName, dbName, true), !isNetworkRB.isSelected()); AppPreferences.getLocalPrefs().put(getMasterPrefPath(usrName, dbName, true), value); return true; } return false; }