List of usage examples for javax.swing JRadioButton JRadioButton
public JRadioButton(String text)
From source file:org.languagetool.gui.ConfigurationDialog.java
@NotNull private JPanel getMotherTonguePanel(GridBagConstraints cons) { JPanel motherTonguePanel = new JPanel(); if (insideOffice) { motherTonguePanel.setLayout(new GridBagLayout()); GridBagConstraints cons1 = new GridBagConstraints(); cons1.insets = new Insets(0, 0, 0, 0); cons1.gridx = 0;/*from w ww. j a v a 2 s .c om*/ cons1.gridy = 0; cons1.anchor = GridBagConstraints.WEST; cons1.fill = GridBagConstraints.NONE; cons1.weightx = 0.0f; JRadioButton[] radioButtons = new JRadioButton[2]; ButtonGroup numParaGroup = new ButtonGroup(); radioButtons[0] = new JRadioButton(Tools.getLabel(messages.getString("guiUseDocumentLanguage"))); radioButtons[0].setActionCommand("DocLang"); radioButtons[0].setSelected(true); radioButtons[1] = new JRadioButton(Tools.getLabel(messages.getString("guiSetLanguageTo"))); radioButtons[1].setActionCommand("SelectLang"); JComboBox<String> motherTongueBox = new JComboBox<>(getPossibleMotherTongues()); if (config.getMotherTongue() != null) { motherTongueBox.setSelectedItem(config.getMotherTongue().getTranslatedName(messages)); } motherTongueBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { Language motherTongue; if (motherTongueBox.getSelectedItem() instanceof String) { motherTongue = getLanguageForLocalizedName( motherTongueBox.getSelectedItem().toString()); } else { motherTongue = (Language) motherTongueBox.getSelectedItem(); } config.setMotherTongue(motherTongue); config.setUseDocLanguage(false); radioButtons[1].setSelected(true); } } }); for (int i = 0; i < 2; i++) { numParaGroup.add(radioButtons[i]); } if (config.getUseDocLanguage()) { radioButtons[0].setSelected(true); } else { radioButtons[1].setSelected(true); } radioButtons[0].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { config.setUseDocLanguage(true); } }); radioButtons[1].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { config.setUseDocLanguage(false); Language motherTongue; if (motherTongueBox.getSelectedItem() instanceof String) { motherTongue = getLanguageForLocalizedName(motherTongueBox.getSelectedItem().toString()); } else { motherTongue = (Language) motherTongueBox.getSelectedItem(); } config.setMotherTongue(motherTongue); } }); motherTonguePanel.add(radioButtons[0], cons1); cons1.gridy++; motherTonguePanel.add(radioButtons[1], cons1); cons1.gridx = 1; motherTonguePanel.add(motherTongueBox, cons1); } else { motherTonguePanel.add(new JLabel(messages.getString("guiMotherTongue")), cons); JComboBox<String> motherTongueBox = new JComboBox<>(getPossibleMotherTongues()); if (config.getMotherTongue() != null) { motherTongueBox.setSelectedItem(config.getMotherTongue().getTranslatedName(messages)); } motherTongueBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { Language motherTongue; if (motherTongueBox.getSelectedItem() instanceof String) { motherTongue = getLanguageForLocalizedName( motherTongueBox.getSelectedItem().toString()); } else { motherTongue = (Language) motherTongueBox.getSelectedItem(); } config.setMotherTongue(motherTongue); } } }); motherTonguePanel.add(motherTongueBox, cons); } return motherTonguePanel; }
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;//from www . j a v a 2s . c o m 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);//from www . j a va2s .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.nuclos.client.ui.OptionGroup.java
private void addRadioButton(String sLabel, String sMnemonic, String sValue) { final JRadioButton radiobtn = new JRadioButton(sLabel); if (sMnemonic != null && sMnemonic.length() > 0) { radiobtn.setMnemonic(sMnemonic.charAt(0)); }/*from w w w. j a v a2s . c om*/ radiobtn.getModel().setActionCommand(sValue); radiobtn.getModel().setGroup(bg); radiobtn.addActionListener(actionListener); radiobtn.setEnabled(this.isEnabled()); MouseListener[] mls = getMouseListeners(); for (int i = 0; i < mls.length; i++) { radiobtn.addMouseListener(mls[i]); } bg.add(radiobtn); this.add(radiobtn); }
From source file:org.openconcerto.erp.core.humanresources.payroll.element.VariablePayeSQLElement.java
public SQLComponent createComponent() { return new BaseSQLComponent(this) { private ValidState validVarName; private JRadioButton radioVal = new JRadioButton("Valeur"); private JRadioButton radioFormule = new JRadioButton("Formule"); private final JTextField textValeur = new JTextField(); // private final ITextArea textFormule = new ITextArea(); private final VariableTree treeVariable = new VariableTree(); private final JTextField textNom = new JTextField(); private final JLabel labelWarningBadVar = new JLabelWarning(); private ElementComboBox comboSelSal; private EditFrame edit = null; private final SQLJavaEditor textFormule = new SQLJavaEditor(getMapTree()); public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); this.validVarName = null; this.textFormule.setEditable(false); // Arbre des variables JScrollPane sc = new JScrollPane(this.treeVariable); sc.setPreferredSize(new Dimension(150, sc.getPreferredSize().height)); this.treeVariable.addMouseListener(new MouseAdapter() { public void mousePressed(final MouseEvent mE) { if (mE.getButton() == MouseEvent.BUTTON3) { JPopupMenu menuDroit = new JPopupMenu(); TreePath path = treeVariable.getClosestPathForLocation(mE.getPoint().x, mE.getPoint().y); final Object obj = path.getLastPathComponent(); if ((obj == null) || !(obj instanceof VariableRowTreeNode)) { return; }//from w ww . ja va2s . c om menuDroit.add(new AbstractAction("Editer") { public void actionPerformed(ActionEvent e) { if (edit == null) { edit = new EditFrame(getElement(), EditFrame.MODIFICATION); } System.err.println("Action performed"); if (obj != null) { System.err.println("Object not null --> " + obj.toString()); if (obj instanceof VariableRowTreeNode) { System.err.println("Object VariableRowTreeNode"); VariableRowTreeNode varNode = (VariableRowTreeNode) obj; edit.selectionId(varNode.getID(), 1); edit.setVisible(true); } } } }); menuDroit.show((Component) mE.getSource(), mE.getPoint().x, mE.getPoint().y); } else { if (mE.getClickCount() == 2) { TreePath path = treeVariable.getClosestPathForLocation(mE.getPoint().x, mE.getPoint().y); Object obj = path.getLastPathComponent(); if (obj != null) { if (obj instanceof FormuleTreeNode) { final FormuleTreeNode n = (FormuleTreeNode) obj; int start = textFormule.getSelectionStart(); String tmp = textFormule.getText(); textFormule.setText(tmp.substring(0, start) + n.getTextValue() + tmp.substring(start, tmp.length())); } } } } } }); JPanel panelDroite = new JPanel(); panelDroite.setLayout(new GridBagLayout()); // Categorie JTextField textCategorie = new JTextField(); c.fill = GridBagConstraints.HORIZONTAL; c.gridheight = 1; c.gridx = 1; c.gridy = 0; JLabel labelCategorie = new JLabel("Catgorie"); panelDroite.add(labelCategorie, c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; panelDroite.add(textCategorie, c); c.gridwidth = 1; // Nom c.fill = GridBagConstraints.HORIZONTAL; c.gridheight = 1; c.gridx = 1; c.gridy++; JLabel labelNom = new JLabel("Nom"); panelDroite.add(labelNom, c); c.gridx++; c.weightx = 1; panelDroite.add(this.textNom, c); this.textNom.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent e) { updateValidVarName(); } }); c.gridx++; c.weightx = 0; panelDroite.add(this.labelWarningBadVar, c); // Description JLabel labelInfos = new JLabel(getLabelFor("INFOS")); ITextArea textInfos = new ITextArea(); c.gridy++; c.gridx = 1; c.gridwidth = 1; c.weightx = 0; panelDroite.add(labelInfos, c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; c.weighty = 0; panelDroite.add(textInfos, c); // Valeur c.gridx = 1; c.gridy++; c.gridwidth = 1; c.weightx = 0; panelDroite.add(this.radioVal, c); c.gridx++; c.weightx = 1; c.gridwidth = GridBagConstraints.REMAINDER; panelDroite.add(this.textValeur, c); c.gridwidth = 1; c.gridx = 1; c.gridy++; panelDroite.add(this.radioFormule, c); c.gridx++; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; panelDroite.add(this.textFormule, c); c.gridwidth = 1; ButtonGroup group = new ButtonGroup(); group.add(this.radioVal); group.add(this.radioFormule); this.radioVal.setSelected(true); setFormuleEnabled(false); this.radioVal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setFormuleEnabled(false); } }); this.radioFormule.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setFormuleEnabled(true); } }); c.gridy++; c.gridx = 1; c.weighty = 0; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.comboSelSal = new ElementComboBox(false); this.comboSelSal.init(getDirectory().getElement(SalarieSQLElement.class)); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 0; panelDroite.add(this.comboSelSal, c); c.gridwidth = 1; JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sc, panelDroite); c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = 0; c.weightx = 1; c.weighty = 1; this.add(split, c); this.addRequiredSQLObject(this.textNom, "NOM"); this.addSQLObject(this.textValeur, "VALEUR"); this.addSQLObject(this.textFormule, "FORMULE"); this.addSQLObject(textCategorie, "CATEGORIE"); this.addSQLObject(textInfos, "INFOS"); this.comboSelSal.addValueListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { // TODO Auto-generated method stub textFormule.setSalarieID(comboSelSal.getSelectedId()); } }); } @Override public synchronized ValidState getValidState() { return super.getValidState().and(this.validVarName); } private void setFormuleEnabled(boolean b) { if (b) { this.textValeur.setText(""); } else { this.textFormule.setText(""); } this.textValeur.setEditable(!b); this.textValeur.setEnabled(!b); this.textFormule.setEditable(b); this.textFormule.setEnabled(b); this.treeVariable.setEnabled(b); this.treeVariable.setEditable(b); } private void setValidVarName(ValidState s) { if (!s.equals(this.validVarName)) { this.validVarName = s; final boolean warningVisible = !s.isValid(); if (warningVisible) this.labelWarningBadVar.setText(s.getValidationText()); this.labelWarningBadVar.setVisible(warningVisible); this.fireValidChange(); } } private void updateValidVarName() { this.setValidVarName(this.computeValidVarName()); } private ValidState computeValidVarName() { // on vrifie si la syntaxe de la variable est correct (chiffre lettre et _) final String varName = this.textNom.getText().trim(); System.err.println("Verification de la validit du nom de la variable."); if (varName.length() == 0) { return VAR_NO_NAME; } // ne contient que des chiffre lettre et _ et ne commence pas par un chiffre if (!isJavaVar(varName)) { return VAR_NAME_NOT_CORRECT; } // on vrifie que la variable n'existe pas dja SQLSelect selAllVarName = new SQLSelect(getTable().getBase()); selAllVarName.addSelect(VariablePayeSQLElement.this.getTable().getField("ID")); Where w = new Where(VariablePayeSQLElement.this.getTable().getField("NOM"), "=", varName); w = w.and(new Where(VariablePayeSQLElement.this.getTable().getKey(), "!=", getSelectedID())); selAllVarName.setWhere(w); String reqAllVarName = selAllVarName.asString();// + " AND '" + varName.trim() + "' // REGEXP VARIABLE_PAYE.NOM"; Object[] objKeysRowName = ((List) getTable().getBase().getDataSource().execute(reqAllVarName, new ArrayListHandler())).toArray(); if (objKeysRowName.length > 0) { return VAR_ALREADY_EXIST; } else { // Impossible de crer une variable du meme nom qu'un champ du salarie if (isForbidden(varName)) return VAR_ALREADY_EXIST; this.textFormule.setVarAssign(varName); return ValidState.getTrueInstance(); } } private boolean isJavaVar(String s) { if ((s.charAt(0) >= '0') && ((s.charAt(0) <= '9'))) { System.err.println("Erreur la variable commence par un chiffre!!"); return false; } else { for (int i = 0; i < s.length(); i++) { if (!(((s.charAt(i) >= '0') && (s.charAt(i) <= '9')) || (s.charAt(i) >= 'a') && (s.charAt(i) <= 'z') || (s.charAt(i) >= 'A') && (s.charAt(i) <= 'Z') || (s.charAt(i) == '_'))) { System.err.println("Erreur la variable contient un caractere incorrect!!"); return false; } } return (!CTokenMarker.getKeywords().isExisting(s)); } } @Override public void select(SQLRowAccessor r) { super.select(r); // System.err.println("Select RowAccess -------> " + r.getID() + " For Object " + // this.hashCode()); if (r != null) { if (r.getString("FORMULE").trim().length() == 0) { this.radioVal.setSelected(true); setFormuleEnabled(false); } else { this.radioFormule.setSelected(true); setFormuleEnabled(true); } this.textFormule.setVarAssign(r.getString("NOM")); } this.updateValidVarName(); } }; }
From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.ImportDialog.java
/** * Initializes the components composing the display. * /* ww w .j a va 2s .com*/ * @param filters The filters to handle. * @param importerAction The cancel-all-imports action. */ private void initComponents(FileFilter[] filters, ImporterAction importerAction) { canvas = new QuotaCanvas(); sizeImportLabel = new JLabel(); diskSpacePane = new JPanel(); diskSpacePane.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); diskSpacePane.add(UIUtilities.setTextFont(TEXT_FREE_SPACE)); diskSpacePane.add(canvas); showThumbnails = new JCheckBox(TEXT_SHOW_THUMBNAILS); showThumbnails.setVisible(false); Registry registry = ImporterAgent.getRegistry(); Boolean loadThumbnails = (Boolean) registry.lookup(LOAD_THUMBNAIL); if (loadThumbnails != null) { if (loadThumbnails.booleanValue()) { showThumbnails.setVisible(true); showThumbnails.setSelected(loadThumbnails.booleanValue()); } } if (!isFastConnection()) // slow connection showThumbnails.setSelected(false); long groupId = -1; if (model.getSelectedGroup() != null) groupId = model.getSelectedGroup().getGroupId(); if (groupId < 0) groupId = ImporterAgent.getUserDetails().getGroupId(); locationDialog = new LocationDialog(owner, selectedContainer, type, objects, model, groupId, true); locationDialog.addPropertyChangeListener(this); int plugin = ImporterAgent.runAsPlugin(); if (plugin == LookupNames.IMAGE_J_IMPORT || plugin == LookupNames.IMAGE_J) { detachedDialog = new LocationDialog(owner, selectedContainer, type, objects, model, groupId, false); detachedDialog.addPropertyChangeListener(this); } tagSelectionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { Object src = e.getSource(); if (src instanceof JButton) { TagAnnotationData tag = tagsMap.get(src); if (tag != null) { tagsMap.remove(src); handleTagsSelection(tagsMap.values()); } } } }; tabbedPane = new JTabbedPane(); numberOfFolders = new NumericalTextField(); numberOfFolders.setMinimum(0); numberOfFolders.setText("0"); numberOfFolders.setColumns(3); numberOfFolders.addPropertyChangeListener(this); tagsMap = new LinkedHashMap<JButton, TagAnnotationData>(); IconManager icons = IconManager.getInstance(); refreshFilesButton = new JButton(TEXT_REFRESH_FILES); refreshFilesButton.setBackground(UIUtilities.BACKGROUND); refreshFilesButton.setToolTipText(TOOLTIP_REFRESH_FILES); refreshFilesButton.setActionCommand("" + CMD_REFRESH_FILES); refreshFilesButton.addActionListener(this); tagButton = new JButton(icons.getIcon(IconManager.PLUS_12)); UIUtilities.unifiedButtonLookAndFeel(tagButton); tagButton.addActionListener(this); tagButton.setActionCommand("" + CMD_TAG); tagButton.setToolTipText(TOOLTIP_ADD_TAGS); tagsPane = new JPanel(); tagsPane.setLayout(new BoxLayout(tagsPane, BoxLayout.Y_AXIS)); overrideName = new JCheckBox(TEXT_OVERRIDE_FILE_NAMING); overrideName.setToolTipText(UIUtilities.formatToolTipText(WARNING)); overrideName.setSelected(true); ButtonGroup group = new ButtonGroup(); fullName = new JRadioButton(TEXT_NAMING_FULL_PATH); group.add(fullName); partialName = new JRadioButton(); partialName.setText(TEXT_NAMING_PARTIAL_PATH); partialName.setSelected(true); group.add(partialName); table = new FileSelectionTable(this); table.addPropertyChangeListener(this); chooser = new GenericFileChooser(); JList list = (JList) UIUtilities.findComponent(chooser, JList.class); KeyAdapter ka = new KeyAdapter() { /** * Adds the files to the import queue. * * @see KeyListener#keyPressed(KeyEvent) */ public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { handleEnterKeyPressed(e.getSource()); } } }; if (list != null) list.addKeyListener(ka); if (list == null) { JTable t = (JTable) UIUtilities.findComponent(chooser, JTable.class); if (t != null) t.addKeyListener(ka); } try { File f = UIUtilities.getDefaultFolder(); if (f != null) chooser.setCurrentDirectory(f); } catch (Exception e) { // Ignore: could not set the default container } chooser.addPropertyChangeListener(this); chooser.setMultiSelectionEnabled(true); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); chooser.setControlButtonsAreShown(false); chooser.setApproveButtonText(TEXT_IMPORT); chooser.setApproveButtonToolTipText(TOOLTIP_IMPORT); bioFormatsFileFilters = new ArrayList<FileFilter>(); if (filters != null) { chooser.setAcceptAllFileFilterUsed(false); for (FileFilter fileFilter : filters) { if (fileFilter instanceof ComboFileFilter) { bioFormatsFileFiltersCombined = fileFilter; ComboFileFilter comboFilter = (ComboFileFilter) fileFilter; FileFilter[] extensionFilters = comboFilter.getFilters(); for (FileFilter combinedFilter : extensionFilters) { bioFormatsFileFilters.add(combinedFilter); } break; } } chooser.addChoosableFileFilter(bioFormatsFileFiltersCombined); for (FileFilter fileFilter : bioFormatsFileFilters) { chooser.addChoosableFileFilter(fileFilter); } chooser.setFileFilter(bioFormatsFileFiltersCombined); } else { chooser.setAcceptAllFileFilterUsed(true); } closeButton = new JButton(TEXT_CLOSE); closeButton.setToolTipText(TOOLTIP_CLOSE); closeButton.setActionCommand("" + CMD_CLOSE); closeButton.addActionListener(this); cancelImportButton = new JButton(importerAction); importerAction.setEnabled(false); importButton = new JButton(TEXT_IMPORT); importButton.setToolTipText(TOOLTIP_IMPORT); importButton.setActionCommand("" + CMD_IMPORT); importButton.addActionListener(this); importButton.setEnabled(false); pixelsSize = new ArrayList<NumericalTextField>(); NumericalTextField field; for (int i = 0; i < 3; i++) { field = new NumericalTextField(); field.setNumberType(Double.class); field.setColumns(2); pixelsSize.add(field); } List<Component> boxes = UIUtilities.findComponents(chooser, JComboBox.class); if (boxes != null) { JComboBox box; JComboBox filterBox = null; Iterator<Component> i = boxes.iterator(); while (i.hasNext()) { box = (JComboBox) i.next(); Object o = box.getItemAt(0); if (o instanceof FileFilter) { filterBox = box; break; } } if (filterBox != null) { filterBox.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { String value = KeyEvent.getKeyText(e.getKeyCode()); JComboBox box = (JComboBox) e.getSource(); int n = box.getItemCount(); FileFilter filter; FileFilter selectedFilter = null; String d; for (int j = 0; j < n; j++) { filter = (FileFilter) box.getItemAt(j); d = filter.getDescription(); if (d.startsWith(value)) { selectedFilter = filter; break; } } if (selectedFilter != null) box.setSelectedItem(selectedFilter); } }); } } }
From source file:org.openmicroscopy.shoola.agents.treeviewer.util.SaveResultsDialog.java
/** * Builds and lays out the elements indicating what to save. * * @return See above.//from www .j a v a 2 s .c o m */ private JPanel buildContents() { JPanel buttons = new JPanel(); buttons.add(UIUtilities.setTextFont("Save results for")); buttons.setLayout(new BoxLayout(buttons, BoxLayout.Y_AXIS)); ButtonGroup group = new ButtonGroup(); JRadioButton b = new JRadioButton("Image from current window"); b.setSelected(activeWindow); buttons.add(b); group.add(b); b.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { activeWindow = (e.getStateChange() == ItemEvent.SELECTED); } }); b = new JRadioButton("Images from all image windows"); b.setSelected(activeWindow); buttons.add(b); group.add(b); buttons.add(Box.createRigidArea(UIUtilities.H_SPACER_SIZE)); buttons.add(UIUtilities.setTextFont("Save")); buttons.add(roi); buttons.add(table); JPanel row = new JPanel(); row.setLayout(new FlowLayout(FlowLayout.LEFT)); JLabel l = new JLabel(); l.setText("Measurements File Name: "); row.add(l); row.add(nameField); JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.add(UIUtilities.buildComponentPanel(buttons)); p.add(row); return p; }
From source file:org.pentaho.reporting.engine.classic.core.modules.gui.pdf.PdfExportDialog.java
private void initializeComponents() { setTitle(getResources().getString("pdfsavedialog.dialogtitle")); //$NON-NLS-1$ txAuthor = new JTextField(); txAuthor.setColumns(40);/*from w w w . ja va 2s . co m*/ txTitle = new JTextField(); txTitle.setColumns(40); txKeywords = new JTextField(); txKeywords.setColumns(40); txDescription = new JTextField(); txDescription.setColumns(40); rbSecurityNone = new JRadioButton(getResources().getString("pdfsavedialog.securityNone")); //$NON-NLS-1$ rbSecurity40Bit = new JRadioButton(getResources().getString("pdfsavedialog.security40bit")); //$NON-NLS-1$ rbSecurity128Bit = new JRadioButton(getResources().getString("pdfsavedialog.security128bit")); //$NON-NLS-1$ final Action securitySelectAction = new ActionSecuritySelection(); rbSecurityNone.addActionListener(securitySelectAction); rbSecurity40Bit.addActionListener(securitySelectAction); rbSecurity128Bit.addActionListener(securitySelectAction); rbSecurity128Bit.setSelected(true); txUserPassword = new JPasswordField(); txConfUserPassword = new JPasswordField(); txOwnerPassword = new JPasswordField(); txConfOwnerPassword = new JPasswordField(); cxAllowCopy = new JCheckBox(getResources().getString("pdfsavedialog.allowCopy")); //$NON-NLS-1$ cbAllowPrinting = new JComboBox(getPrintingComboBoxModel()); cxAllowScreenReaders = new JCheckBox(getResources().getString("pdfsavedialog.allowScreenreader")); //$NON-NLS-1$ cxAllowAssembly = new JCheckBox(getResources().getString("pdfsavedialog.allowAssembly")); //$NON-NLS-1$ cxAllowModifyContents = new JCheckBox(getResources().getString("pdfsavedialog.allowModifyContents")); //$NON-NLS-1$ cxAllowModifyAnnotations = new JCheckBox(getResources().getString("pdfsavedialog.allowModifyAnnotations")); //$NON-NLS-1$ cxAllowFillIn = new JCheckBox(getResources().getString("pdfsavedialog.allowFillIn")); //$NON-NLS-1$ txFilename = new JTextField(); txFilename.setColumns(40); statusBar = new JStatusBar(); encodingModel = EncodingComboBoxModel.createDefaultModel(Locale.getDefault()); encodingModel.sort(); cbEncoding = new JComboBox(encodingModel); cxEmbedded = new JCheckBox(getResources().getString("pdfsavedialog.embedfonts")); getFormValidator().registerTextField(txFilename); getFormValidator().registerTextField(txConfOwnerPassword); getFormValidator().registerTextField(txConfUserPassword); getFormValidator().registerTextField(txUserPassword); getFormValidator().registerTextField(txOwnerPassword); final JPanel exportPane = createExportPanel(); final Configuration config = ClassicEngineBoot.getInstance().getGlobalConfig(); final boolean advancedSettingsTabAvail = "true".equals(config.getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.gui.pdf.AdvancedSettingsAvailable")); final boolean metaDataSettingsTabAvail = "true".equals(config.getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.gui.pdf.MetaDataSettingsAvailable")); final JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.add(getResources().getString("pdfsavedialog.export-settings"), exportPane); //$NON-NLS-1$ tabbedPane.add(getResources().getString("pdfsavedialog.parameters"), getParametersPanel()); if (metaDataSettingsTabAvail) { tabbedPane.add(getResources().getString("pdfsavedialog.metadata-settings"), createMetaDataPanel()); //$NON-NLS-1$ } if (advancedSettingsTabAvail) { tabbedPane.add(getResources().getString("pdfsavedialog.advanced-settings"), createAdvancedPanel()); //$NON-NLS-1$ } setContentPane(createContentPane(tabbedPane)); }
From source file:org.pentaho.reporting.tools.configeditor.ConfigDescriptionEditor.java
/** * Creates the type selection panel containing some radio buttons to define the detail editor type. * * @return the type selection panel./* ww w . j a v a2s . com*/ */ private JPanel createTypeSelectionPane() { final JPanel panel = new JPanel(); panel.setLayout(new GridLayout(3, 1)); rbText = new JRadioButton(new SelectTypeAction(resources.getString("config-description-editor.type-text"), ConfigDescriptionEditor.TYPE_TEXT)); //$NON-NLS-1$ rbClass = new JRadioButton(new SelectTypeAction(resources.getString("config-description-editor.type-class"), ConfigDescriptionEditor.TYPE_CLASS)); //$NON-NLS-1$ rbEnum = new JRadioButton(new SelectTypeAction(resources.getString("config-description-editor.type-enum"), ConfigDescriptionEditor.TYPE_ENUM)); //$NON-NLS-1$ final ButtonGroup bg = new ButtonGroup(); bg.add(rbText); bg.add(rbClass); bg.add(rbEnum); panel.add(rbText); panel.add(rbClass); panel.add(rbEnum); return panel; }
From source file:org.tellervo.desktop.tridasv2.ui.ComponentViewer.java
private void initComponents() { setLayout(new BorderLayout()); // create button panel JPanel topPanel = new JPanel(); btnTreeView = new JRadioButton("Tree"); btnTreeView.putClientProperty("cv.cardName", TREEPANEL); btnTableView = new JRadioButton("Table"); btnTableView.putClientProperty("cv.cardName", TABLEPANEL); ActionListener btnListener = new ActionListener() { public void actionPerformed(ActionEvent e) { // show the right layout panel String v = (String) ((AbstractButton) e.getSource()).getClientProperty("cv.cardName"); if (v != null) ((CardLayout) contentPanel.getLayout()).show(contentPanel, v); }/*from w w w . j a v a 2 s .com*/ }; btnTableView.addActionListener(btnListener); btnTreeView.addActionListener(btnListener); // connect buttons ButtonGroup group = new ButtonGroup(); group.add(btnTreeView); group.add(btnTableView); topPanel.setLayout(new MigLayout("", "[64px][55px][62px][grow]", "[][23px]")); lblViewAllThe = new JLabel( "<html>View all the component series that combine to create the current series. Series can be viewed as:"); topPanel.add(lblViewAllThe, "cell 0 0 4 1"); JRadioButton btnTree2View = new JRadioButton("Flow chart"); btnTree2View.putClientProperty("cv.cardName", TREE2PANEL); btnTree2View.addActionListener(btnListener); group.add(btnTree2View); topPanel.add(btnTree2View, "cell 0 1,alignx left,aligny center"); topPanel.add(btnTreeView, "cell 1 1,alignx left,aligny center"); topPanel.add(btnTableView, "cell 2 1,alignx left,aligny center"); topPanel.setBorder(BorderFactory.createEmptyBorder(2, 8, 8, 8)); add(topPanel, BorderLayout.NORTH); // create status bar JPanel status = new JPanel(); status.setLayout(new BoxLayout(status, BoxLayout.X_AXIS)); txtStatus = new JLabel(""); pbStatus = new JProgressBar(); pbStatus.setVisible(false); status.add(txtStatus); status.add(Box.createHorizontalStrut(8)); status.add(pbStatus); status.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); add(status, BorderLayout.SOUTH); contentPanel = new JPanel(new CardLayout()); add(contentPanel, BorderLayout.CENTER); tablePanel = new JPanel(new BorderLayout()); setupTable(); tablePanel.add(new JScrollPane(table), BorderLayout.CENTER); treePanel = new JPanel(new BorderLayout()); setupTree(); treePanel.add(new JScrollPane(tree), BorderLayout.CENTER); tree2Panel = new JPanel(new BorderLayout()); setupTreeGUI(); contentPanel.add(tablePanel, TABLEPANEL); contentPanel.add(treePanel, TREEPANEL); contentPanel.add(tree2Panel, TREE2PANEL); }