{ GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); fontSet = ge.getAllFonts(); for (int i = 0; i < fontSet.length; i++) { fontCombo.addItem(fontSet[i].getFontName()); } final int FONT_SIZE_NUM = 31; fontSizeSet = new int[FONT_SIZE_NUM]; for (int i = 0; i < FONT_SIZE_NUM; i++) { fontSizeSet[i] = 100 + (i * 10); } for (int n : fontSizeSet) { fontSizeCombo.addItem(n); } for (Color color : ColorNameConverter.getColorSet()) { fontColorCombo.addItem(color); } for (Color color : ColorNameConverter.getColorSet()) { backgroundColorCombo.addItem(color); } fontColorCombo.setEditable(false); backgroundColorCombo.setEditable(false); ItemWithColorTip item = new ItemWithColorTip(); fontColorCombo.setRenderer(item); backgroundColorCombo.setRenderer(item); }
private void initComponents() { setTitle("Print Preview"); sheetBox.setRenderer( new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value != null) { setToolTipText(value.toString()); } return this; } }); sheetBox.setActionCommand(SHEET_COMMAND); sheetBox.addActionListener(this); pageBox.addItem("0 of 0"); pageBox.setActionCommand(PAGE_COMMAND); pageBox.addActionListener(this); zoomBox.addItem(0.25); zoomBox.addItem(0.50); zoomBox.addItem(0.75); zoomBox.addItem(1.00); zoomBox.setSelectedItem(0.75); zoomBox.setRenderer( new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { NumberFormat format = NumberFormat.getPercentInstance(); value = format.format(value); return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } }); zoomBox.setEditable(true); zoomBox.setEditor(new PercentEditor(zoomBox)); zoomBox.setActionCommand(ZOOM_COMMAND); zoomBox.addActionListener(this); zoomInButton.setIcon(Icons.ZoomIn16.getImageIcon()); zoomInButton.setActionCommand(ZOOM_IN_COMMAND); zoomInButton.addActionListener(this); zoomOutButton.setIcon(Icons.ZoomOut16.getImageIcon()); zoomOutButton.setActionCommand(ZOOM_OUT_COMMAND); zoomOutButton.addActionListener(this); printButton.setText("Print"); printButton.setActionCommand(PRINT_COMMAND); printButton.addActionListener(this); cancelButton.setText("Cancel"); cancelButton.setActionCommand(CANCEL_COMMAND); cancelButton.addActionListener(this); enableEditGroup(false); Utility.installEscapeCloseOperation(this); }
/** The constructor. */ public StylePanelFig() { super("Fig Appearance"); initChoices(); Document bboxDoc = bboxField.getDocument(); bboxDoc.addDocumentListener(this); bboxField.addKeyListener(this); bboxField.addFocusListener(this); fillField.addItemListener(this); lineField.addItemListener(this); fillField.setRenderer(new ColorRenderer()); lineField.setRenderer(new ColorRenderer()); bboxLabel.setLabelFor(bboxField); add(bboxLabel); add(bboxField); fillLabel.setLabelFor(fillField); add(fillLabel); add(fillField); lineLabel.setLabelFor(lineField); add(lineLabel); add(lineField); }
public AnchorPointClassificationPanel( Object displacement, String title, List<QualifiedName> properties) { this.title = title; fixed = new JRadioButton(); property = new JRadioButton(); ButtonGroup bg = new ButtonGroup(); bg.add(fixed); bg.add(property); propertyCBx = new JComboBox(); propertyCBx.setRenderer(new PropertyNameRenderer()); for (QualifiedName qn : properties) { propertyCBx.addItem(new PropertyName(qn)); } propertyCBy = new JComboBox(); propertyCBy.setRenderer(new PropertyNameRenderer()); for (QualifiedName qn : properties) { propertyCBy.addItem(new PropertyName(qn)); } anchorEditor = new AnchorEditor(); if (displacement instanceof Pair<?, ?>) { property.setSelected(true); propertyCBx.setSelectedItem(((Pair<?, ?>) displacement).first); propertyCBy.setSelectedItem(((Pair<?, ?>) displacement).second); } else if (displacement instanceof Point2d) { fixed.setSelected(true); anchorEditor.setValue(((Point2d) displacement).x, ((Point2d) displacement).y); } else { fixed.setSelected(true); } if (properties == null || properties.isEmpty()) { propertyCBx.setEnabled(false); propertyCBy.setEnabled(false); property.setEnabled(false); } FormLayout fl = new FormLayout( "$rgap, 15dlu, left:default:grow(1.0)", "$sepheight, center:[20dlu,default], $ug, $sepheight, bottom:10dlu, center:$cpheight, bottom:10dlu,center:$cpheight"); DefaultFormBuilder builder = new DefaultFormBuilder(fl); CellConstraints cc = new CellConstraints(); builder.addSeparator(get("$MD11713"), cc.xyw(1, 1, 3)); builder.add(fixed, cc.xy(2, 2)); builder.add(anchorEditor, cc.xy(3, 2)); builder.addSeparator(get("$MD11714"), cc.xyw(1, 4, 3)); builder.add(property, cc.xywh(2, 5, 1, 4)); builder.addLabel(get("$MD10835"), cc.xy(3, 5)); builder.add(propertyCBx, cc.xy(3, 6)); builder.addLabel(get("$MD10836"), cc.xy(3, 7)); builder.add(propertyCBy, cc.xy(3, 8)); add(builder.getPanel()); }
@Override protected void initComponents() { for (Agregation agregation : Agregation.values()) { jcb_agregation.addItem(agregation); map_agregation.put( agregation, new ImageIcon(getClass().getResource("/img/" + agregation.name() + ".png"))); } for (SortOrder order : SortOrder.values()) { jcb_order.addItem(order); map_order.put(order, new ImageIcon(getClass().getResource("/img/" + order.name() + ".png"))); } jcb_agregation.addActionListener(this); jcb_order.addActionListener(this); jcb_agregation.setRenderer(new IconListRenderer(map_agregation)); jcb_order.setRenderer(new IconListRenderer(map_order)); jtable = new JTable(table_request); jtable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jtable.setRowHeight(18); jtable.getColumn("Supprimer").setCellRenderer(new DeleteRender()); jtable.getColumn("Supprimer").setCellEditor(new DeleteEditor(new JCheckBox())); jtable.getColumn("Supprimer").setMaxWidth(16); jtable.getColumn("Monter").setCellRenderer(new UpRender()); jtable.getColumn("Monter").setCellEditor(new UpEditor(new JCheckBox())); jtable.getColumn("Monter").setMaxWidth(16); jtable.getColumn("Descendre").setCellRenderer(new DownRender()); jtable.getColumn("Descendre").setCellEditor(new DownEditor(new JCheckBox())); jtable.getColumn("Descendre").setMaxWidth(16); jtable.getColumn("Alias").setCellEditor(new AliasEditor(new JCheckBox())); setUpFonctionColumn(jtable, jtable.getColumnModel().getColumn(6)); setUpOrderColumn(jtable, jtable.getColumnModel().getColumn(7)); jtable.addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.getClickCount() == 1) { controller.setActiveSelection(jtable.getSelectedRow()); } } }); }
private JComboBox<CyLayoutAlgorithm> getPrefAlgorithmCmb() { if (prefAlgorithmCmb == null) { prefAlgorithmCmb = new JComboBox<CyLayoutAlgorithm>(); prefAlgorithmCmb.setModel(new DefaultComboBoxModel<CyLayoutAlgorithm>()); prefAlgorithmCmb.setRenderer( new LayoutAlgorithmListCellRenderer("-- Select preferred algorithm --")); prefAlgorithmCmb.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (initializing) return; final CyLayoutAlgorithmManager layoutAlgorithmMgr = serviceRegistrar.getService(CyLayoutAlgorithmManager.class); final CyLayoutAlgorithm layout = (CyLayoutAlgorithm) prefAlgorithmCmb.getSelectedItem(); if (layout != null && !layout.equals(layoutAlgorithmMgr.getDefaultLayout())) layoutAlgorithmMgr.setDefaultLayout(layout); } }); } return prefAlgorithmCmb; }
/** * Prompts the user with a list of WMS layers which can be adjusted * * @param adjustableLayers the list of adjustable layers * @return the selected layer; null, if no layer was selected */ protected Layer askAdjustLayer(List<? extends Layer> adjustableLayers) { if (adjustableLayers.size() == 0) return null; if (adjustableLayers.size() == 1) return adjustableLayers.get(0); JComboBox<Layer> layerList = new JComboBox<>(); layerList.setRenderer(new LayerListCellRenderer()); layerList.setModel(new DefaultComboBoxModel<>(adjustableLayers.toArray(new Layer[0]))); layerList.setSelectedIndex(0); JPanel pnl = new JPanel(); pnl.setLayout(new GridBagLayout()); pnl.add(new JLabel(tr("Please select the imagery layer to adjust.")), GBC.eol()); pnl.add(layerList, GBC.eol()); ExtendedDialog diag = new ExtendedDialog( Main.parent, tr("Select imagery layer"), new String[] {tr("Start adjusting"), tr("Cancel")}); diag.setContent(pnl); diag.setButtonIcons(new String[] {"mapmode/adjustimg", "cancel"}); diag.showDialog(); int decision = diag.getValue(); if (decision != 1) return null; Layer adjustLayer = (Layer) layerList.getSelectedItem(); return adjustLayer; }
/** * Creates the language combo box, attempts to guess an appropriate *available* locale to select, * and sets the application locale to that match. */ private JComboBox createLanguageDropDown(Font normalFont) { final JComboBox languageDropDown = new JComboBox(); Locale[] locales = LanguageUtils.getLocales(normalFont); languageDropDown.setRenderer(new LocaleRenderer()); languageDropDown.setFont(smallFont); languageDropDown.setModel(new DefaultComboBoxModel(locales)); // Attempt to guess the default locale and set accordingly languageDropDown.setSelectedItem(LanguageUtils.guessBestAvailableLocale(locales)); // Make sure the drop down and the set locale match. This may cause the default OS // language to be overridden to English in the case of a bad guess. This has always been // a problem but in this case at least it will be obvious that the users language is being // overridden. LanguageUtils.setLocale((Locale) languageDropDown.getSelectedItem()); languageDropDown.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { Locale locale = (Locale) languageDropDown.getSelectedItem(); LanguageUtils.setLocale(locale); setTextContents(); } } }); return languageDropDown; }
@Override protected JComponent createNorthPanel() { JBLabel descriptionLabel = new JBLabel("<html>" + makeDescription() + "</html>"); final JComboBox repositorySelector = new JComboBox(ArrayUtil.toObjectArray(myRepositories, GitRepository.class)); repositorySelector.setRenderer(new GitRepositoryComboboxListCellRenderer(repositorySelector)); repositorySelector.setSelectedItem(myInitialRepository); repositorySelector.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { List<GitCommit> commits = myCommits.get((GitRepository) repositorySelector.getSelectedItem()); myCommitListWithDiffPanel.setCommits(new ArrayList<GitCommit>(commits)); } }); JPanel repoSelectorPanel = new JPanel(new BorderLayout()); JBLabel label = new JBLabel("Repository: "); label.setLabelFor(repoSelectorPanel); repoSelectorPanel.add(label, BorderLayout.WEST); repoSelectorPanel.add(repositorySelector); if (myRepositories.size() < 2) { repoSelectorPanel.setVisible(false); } JPanel northPanel = new JPanel(new BorderLayout()); northPanel.add(descriptionLabel); northPanel.add(repoSelectorPanel, BorderLayout.SOUTH); return northPanel; }
public EditorOptionsPanel() { if (SystemInfo.isMac) { myCbEnableWheelFontChange.setText( ApplicationBundle.message("checkbox.enable.ctrl.mousewheel.changes.font.size.macos")); } myStripTrailingSpacesCombo.addItem(STRIP_CHANGED); myStripTrailingSpacesCombo.addItem(STRIP_ALL); myStripTrailingSpacesCombo.addItem(STRIP_NONE); myHighlightSettingsPanel.setLayout(new BorderLayout()); myHighlightSettingsPanel.add(myErrorHighlightingPanel.getPanel(), BorderLayout.CENTER); myRichCopyColorSchemeComboBox.setRenderer( new ListCellRendererWrapper<String>() { @Override public void customize( JList list, String value, int index, boolean selected, boolean hasFocus) { final String textToUse; if (RichCopySettings.ACTIVE_GLOBAL_SCHEME_MARKER.equals(value)) { textToUse = ACTIVE_COLOR_SCHEME; } else { textToUse = value; } setText(textToUse); } }); myConfigurable = new MyConfigurable(); initQuickDocProcessing(); initSoftWrapsSettingsProcessing(); }
private JComboBox getLinksComboBox() { if (linksComboBox == null) { linksComboBox = new JComboBox(); linksComboBox.setRenderer(new LinkListCellRenderer()); linksComboBox.setModel( new SearchableComboBoxModel<ILink>( new LinkComparator(), new ObjectToStringConverter<ILink>() { public String convert(ILink object) { return LinkUtilities.formatAsString(object); } })); linksComboBox.setToolTipText("Links in Knowledgebase"); linksComboBox.addItemListener( new ItemListener() { public void itemStateChanged(final ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { setLink((ILink) e.getItem()); } } }); } return linksComboBox; }
private void createCopiesPanel(JPanel pnMainPanel) { pnCopies = new JPanel(); pnMainPanel.add(pnCopies, BorderLayout.CENTER); pnCopies.setLayout(new BorderLayout(0, 0)); JPanel pnCopiesOverview = new JPanel(); pnCopies.add(pnCopiesOverview, BorderLayout.CENTER); pnCopiesOverview.setLayout(new BorderLayout(0, 0)); listCopies = new JList<Copy>(); listCopies.setModel(listModelCopies); listCopies.setCellRenderer(new CopiesListCellRenderer()); pnCopiesOverview.add(new JScrollPane(listCopies)); JPanel pnCopiesAction = new JPanel(); pnCopiesAction.setLayout(new FlowLayout(FlowLayout.RIGHT)); Condition[] options = new Condition[Condition.values().length + 1]; options[0] = null; for (int i = 1; i <= options.length - 1; i++) { options[i] = Condition.values()[i - 1]; } options[1] = Condition.LOST; comboCondition = new JComboBox<Condition>(new ConditionComboBoxModel()); comboCondition.setRenderer(new ConditionListCellRenderer()); comboCondition.setEnabled(false); pnCopiesAction.add(comboCondition); btnSetCondition = new JButton(); btnSetCondition.setEnabled(false); btnSetCondition.setMnemonic('t'); pnCopiesAction.add(btnSetCondition); pnCopies.add(pnCopiesAction, BorderLayout.SOUTH); }
/** Creates the combobox holding the channel list. */ private void createComboBox() { Object[][] channelCols = new Object[channelName.size()][2]; List<ChannelData> metadata = model.getMetadata(); Iterator<ChannelData> i = metadata.iterator(); ChannelData channelData; int channel; int index = 0; while (i.hasNext()) { channelData = i.next(); channel = channelData.getIndex(); if (channelName.containsKey(channel)) { channelCols[index] = new Object[] {channelColour.get(channel), channelName.get(channel)}; index++; } } // if (channelCols.length == 0) // return; channelSelection.setModel(new DefaultComboBoxModel(channelCols)); channelSelection.setRenderer(new ColorListRenderer()); if (selectedChannelName != null) if (nameMap.containsKey(selectedChannelName)) selectedChannel = nameMap.get(selectedChannelName); else selectedChannel = 0; else selectedChannel = 0; if (selectedChannel >= channelSelection.getItemCount() || selectedChannel < 0) return; channelSelection.setSelectedIndex(selectedChannel); channelSelection.setEnabled(true); }
private JComboBox<SolverFamily> createAlgorithmsCombo( final CardLayout cardLayout, final JPanel cardLayoutPanel) { JComboBox<SolverFamily> combo = new JComboBox<SolverFamily>(); combo.setPrototypeDisplayValue(SolverFamily.CENTRAL); final ListCellRenderer<? super SolverFamily> renderer = combo.getRenderer(); combo.setRenderer( new ListCellRenderer<SolverFamily>() { @Override public Component getListCellRendererComponent( JList<? extends SolverFamily> list, SolverFamily value, int index, boolean isSelected, boolean cellHasFocus) { Component c = renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (c instanceof JLabel && value instanceof SolverFamily) { SolverFamily model = (SolverFamily) value; ((JLabel) c).setText(model.getKey()); } return c; } }); combo.setEnabled(false); for (SolverFamily solver : solverPanelMap.keySet()) { cardLayoutPanel.add(solverPanelMap.get(solver).getPanel(), solver.getKey()); } combo.setSelectedIndex(-1); return combo; }
public void init( final Project project, final boolean suggestSearchInLibs, final boolean prevSearchWholeFiles, final String preselect) { mySuggestSearchInLibs = suggestSearchInLibs; myPrevSearchFiles = prevSearchWholeFiles; myProject = project; myScopeListener = new NamedScopesHolder.ScopeListener() { @Override public void scopesChanged() { final SearchScope selectedScope = getSelectedScope(); rebuildModel(); if (selectedScope != null) { selectScope(selectedScope.getDisplayName()); } } }; myNamedScopeManager = NamedScopeManager.getInstance(project); myNamedScopeManager.addScopeListener(myScopeListener); myValidationManager = DependencyValidationManager.getInstance(project); myValidationManager.addScopeListener(myScopeListener); addActionListener(createScopeChooserListener()); final JComboBox combo = getComboBox(); combo.setRenderer(new ScopeDescriptionWithDelimiterRenderer(combo.getRenderer())); rebuildModel(); selectScope(preselect); }
public FramesPanel(Project project, DebuggerStateManager stateManager) { super(project, stateManager); myStateManager = stateManager; setLayout(new BorderLayout()); myThreadsCombo = new ComboBoxWithWidePopup(); myThreadsCombo.setRenderer(new DebuggerComboBoxRenderer()); myThreadsListener = new ThreadsListener(); myThreadsCombo.addItemListener(myThreadsListener); myFramesList = new FramesList(); myFramesListener = new FramesListener(); myFramesList.addListSelectionListener(myFramesListener); myFramesList.addMouseListener( new MouseAdapter() { public void mousePressed(final MouseEvent e) { int index = myFramesList.locationToIndex(e.getPoint()); if (index >= 0 && myFramesList.isSelectedIndex(index)) { processListValue(myFramesList.getModel().getElementAt(index)); } } }); registerThreadsPopupMenu(myFramesList); setBorder(null); add(myThreadsCombo, BorderLayout.NORTH); add(new JScrollPane(myFramesList), BorderLayout.CENTER); }
/** * Setup remotes combobox. The default remote for the current branch is selected by default. * * @param project the project * @param root the git root * @param currentBranch the current branch * @param remoteCombobox the combobox to update * @param fetchUrl if true, the fetch url is shown for remotes, push otherwise */ public static void setupRemotes( final Project project, final VirtualFile root, final String currentBranch, final JComboBox remoteCombobox, final boolean fetchUrl) { try { List<GitDeprecatedRemote> remotes = GitDeprecatedRemote.list(project, root); String remote = null; if (currentBranch != null) { remote = GitConfigUtil.getValue(project, root, "branch." + currentBranch + ".remote"); } remoteCombobox.setRenderer( getGitRemoteListCellRenderer(remote, fetchUrl, remoteCombobox.getRenderer())); GitDeprecatedRemote toSelect = null; remoteCombobox.removeAllItems(); for (GitDeprecatedRemote r : remotes) { remoteCombobox.addItem(r); if (r.name().equals(remote)) { toSelect = r; } } if (toSelect != null) { remoteCombobox.setSelectedItem(toSelect); } } catch (VcsException e) { GitVcs.getInstance(project) .showErrors(Collections.singletonList(e), GitBundle.getString("pull.retrieving.remotes")); } }
/** * Setup root chooser with specified elements and link selection to the current branch label. * * @param project a context project * @param roots git roots for the project * @param defaultRoot a default root * @param gitRootChooser git root selector * @param currentBranchLabel current branch label (might be null) */ public static void setupRootChooser( @NotNull final Project project, @NotNull final List<VirtualFile> roots, @Nullable final VirtualFile defaultRoot, @NotNull final JComboBox gitRootChooser, @Nullable final JLabel currentBranchLabel) { for (VirtualFile root : roots) { gitRootChooser.addItem(root); } gitRootChooser.setRenderer(getVirtualFileListCellRenderer(gitRootChooser.getRenderer())); gitRootChooser.setSelectedItem(defaultRoot != null ? defaultRoot : roots.get(0)); if (currentBranchLabel != null) { final ActionListener listener = new ActionListener() { public void actionPerformed(final ActionEvent e) { VirtualFile root = (VirtualFile) gitRootChooser.getSelectedItem(); assert root != null : "The root must not be null"; GitRepository repo = GitRepositoryManager.getInstance(project).getRepositoryForRoot(root); assert repo != null : "The repository must not be null"; GitBranch current = repo.getCurrentBranch(); if (current == null) { currentBranchLabel.setText(NO_CURRENT_BRANCH); } else { currentBranchLabel.setText(current.getName()); } } }; listener.actionPerformed(null); gitRootChooser.addActionListener(listener); } }
public StructureFunctionCellEditor() { eventListenerList = new EventListenerList(); this.dataAttributeContext = new DefaultDataAttributeContext(); final EllipsisButton ellipsisButton = new EllipsisButton("..."); ellipsisButton.addActionListener(new ExtendedEditorAction()); expressionEditor = new SmartComboBox<ExpressionMetaData>(); expressionEditor.setEditable(false); expressionEditor.setEditor( new ValuePassThroughCellEditor(expressionEditor, new ExpressionListCellRenderer())); expressionEditor.setRenderer(new ExpressionListCellRenderer()); expressionEditor .getInputMap() .put( UtilMessages.getInstance() .getKeyStroke("PropertyCellEditorWithEllipsis.PopupEditor.Accelerator"), POPUP_EDITOR); expressionEditor.getActionMap().put(POPUP_EDITOR, new ExtendedEditorAction()); expressionEditor.setBorder(BorderFactory.createEmptyBorder()); carrierPanel = new JPanel(new BorderLayout()); carrierPanel.add(expressionEditor, BorderLayout.CENTER); carrierPanel.add(ellipsisButton, BorderLayout.EAST); }
public ColorMapVisualization(MRAPanel panel, String defaultEntity, String fieldToPlot) { this.logSource = panel.getSource(); this.curEntity = defaultEntity; setLayout(new MigLayout()); // Parse field to plot String part[] = fieldToPlot.split("\\."); messageName = part[0]; varName = part[1]; // Initialize entityList with the ALL shorthand entityList.add("ALL"); // Misc setups and interface build redrawButton.addActionListener(this); entCombo.setModel(new DefaultComboBoxModel<String>(entityList)); toolbar.add(Box.createHorizontalGlue()); toolbar.add(cmapMinValue); toolbar.add(cmapMaxValue); toolbar.add(cmapCombo); toolbar.add(entCombo); toolbar.add(redrawButton); toolbar.add(savePng); toolbar.add(savePdf); add(toolbar, "w 100%, wrap"); add(container, "w 100%, h 100%"); cmapCombo.setSelectedItem(ColorMapFactory.createJetColorMap()); cmapCombo.setRenderer(new ColorMapListRenderer()); revalidate(); }
@Override public JComponent createForm() { JComponent component = super.createForm(); annotationComboBox.setRenderer( new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value != null) { Annotation annotation = (Annotation) value; this.setText(annotation.getBrief()); } else { this.setText("-- select annotation --"); } return this; } }); component.setLayout(new FormLayout("right:p, 4dlu, left:p", "p, 4dlu, p, 4dlu, p, 4dlu, p")); CellConstraints cc = new CellConstraints(); component.add(getLabel("annotationLabel"), cc.xy(1, 1)); component.add(annotationComboBox, cc.xy(3, 1)); component.add(getLabel("patternLabel"), cc.xy(1, 3)); component.add(patternField, cc.xy(3, 3)); component.add(getLabel("ciLabel"), cc.xy(1, 5)); component.add(caseInsensitive, cc.xy(3, 5)); component.add(getLabel("remove"), cc.xy(1, 7)); component.add(removeMatched, cc.xy(3, 7)); patternField.setEnabled(false); caseInsensitive.setSelected(true); caseInsensitive.setEnabled(false); // action listener will fill out a suggested pattern for selected annotation types annotationComboBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Object obj = annotationComboBox.getSelectedItem(); if (obj == null) { patternField.setEnabled(false); caseInsensitive.setEnabled(false); setEnabled(false); } else { patternField.setEnabled(true); caseInsensitive.setEnabled(true); patternField.setText(getDefault(obj.getClass())); patternField.setCaretPosition(0); setEnabled(true); } } }); return component; }
@Override public JComponent createOptionsPanel() { final JFormattedTextField valueField = prepareNumberEditor("m_limit"); final JComboBox comboBox = new ComboBox( new Object[] {Scope.NONE, Scope.PRIVATE, Scope.PACKAGE_LOCAL, Scope.PROTECTED}); comboBox.setRenderer( new ListCellRendererWrapper() { @Override public void customize( JList list, Object value, int index, boolean selected, boolean hasFocus) { if (value instanceof Scope) setText(((Scope) value).getText()); } }); comboBox.setSelectedItem(ignoreScope); comboBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ignoreScope = (Scope) comboBox.getSelectedItem(); } }); comboBox.setPrototypeDisplayValue(Scope.PROTECTED); final FormBuilder formBuilder = FormBuilder.createFormBuilder(); formBuilder.addLabeledComponent(getConfigurationLabel(), valueField); formBuilder.addLabeledComponent( InspectionGadgetsBundle.message("constructor.visibility.option"), comboBox); final JPanel panel = new JPanel(new BorderLayout()); panel.add(formBuilder.getPanel(), BorderLayout.NORTH); return panel; }
private void setUpBrowserCombobox() { for (BrowsersConfiguration.BrowserFamily family : BrowsersConfiguration.getInstance().getActiveBrowsers()) { browserComboBox.addItem(family); } browserComboBox.setRenderer( new ListCellRendererWrapper<BrowsersConfiguration.BrowserFamily>(browserComboBox) { @Override public void customize( JList list, BrowsersConfiguration.BrowserFamily family, int index, boolean selected, boolean hasFocus) { if (family != null) { setText(family.getName()); setIcon(family.getIcon()); } } }); if (browserComboBox.getItemCount() < 2) { browserComboBox.setVisible(false); browserComboBox.setVisible(false); } else { browserComboBox.setSelectedItem(0); } }
EvolutionPanel() { super(new FlowLayout(FlowLayout.LEFT, 0, 0)); Container innerPanel = new JPanel(new SpringLayout()); populationLabel = new JLabel("Population Size: "); populationSpinner = new JSpinner(new SpinnerNumberModel(300, 2, 10000, 1)); populationLabel.setLabelFor(populationSpinner); innerPanel.add(populationLabel); innerPanel.add(populationSpinner); elitismLabel = new JLabel("Elitism: "); elitismSpinner = new JSpinner(new SpinnerNumberModel(3, 0, 10000, 1)); elitismLabel.setLabelFor(elitismSpinner); innerPanel.add(elitismLabel); innerPanel.add(elitismSpinner); generationsLabel = new JLabel("Number of Generations: "); generationsSpinner = new JSpinner(new SpinnerNumberModel(100, 1, 10000, 1)); generationsLabel.setLabelFor(generationsSpinner); innerPanel.add(generationsLabel); innerPanel.add(generationsSpinner); selectionLabel = new JLabel("Selection Strategy: "); innerPanel.add(selectionLabel); SelectionStrategy<?>[] selectionStrategies = { new RankSelection(), new RouletteWheelSelection(), new StochasticUniversalSampling(), new TournamentSelection(new Probability(0.95)), new TruncationSelection(0.5) }; selectionCombo = new JComboBox(selectionStrategies); selectionCombo.setRenderer( new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean hasFocus) { SelectionStrategy<?> strategy = (SelectionStrategy<?>) value; String text = strategy.getClass().getSimpleName(); return super.getListCellRendererComponent(list, text, index, isSelected, hasFocus); } }); selectionCombo.setSelectedIndex(selectionCombo.getItemCount() - 1); innerPanel.add(selectionCombo); crossoverCheckbox = new JCheckBox("Cross-over", true); mutationCheckbox = new JCheckBox("Mutation", true); distributedCheckbox = new JCheckBox("Distributed (Mahout)", false); innerPanel.add(crossoverCheckbox); innerPanel.add(mutationCheckbox); innerPanel.add(distributedCheckbox); innerPanel.add(new JLabel()); // pour avoir un nombre paire de components SpringUtilities.makeCompactGrid(innerPanel, 6, 2, 30, 6, 6, 6); add(innerPanel); }
private void creaBox() { for (int i = 0; i < 4; i++) { JComboBox box = new JComboBox<>(ColoriDisponibili.disponibili.getColori().keySet().toArray()); box.setRenderer(new ColorRender()); box.setOpaque(true); boxes.add(box); } }
private void initJComboBox(JComboBox jcb) { jcb.setSize(120, 20); jcb.setOpaque(false); jcb.setFocusable(false); jcb.setRenderer(new StarComboBoxRender()); jcb.setUI((ComboBoxUI) StarComboBoxUI.createUI(jcb)); jcb.setBorder(new RoundBorder(Color.red)); add(jcb); }
public void p(Object obj) throws Exception { JComboBox combo = (JComboBox) obj; combo.setFont(combo.getFont().deriveFont(Font.PLAIN)); combo.setBackground(Color.WHITE); if (color == null) color = DEFAULT_COLOR; if (font == null) font = DEFAULT_FONT; combo.setRenderer(new ListRenderer1(icon, color, font)); }
private JComponent createControls() { JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); dateOption = new JRadioButton(messageResources.getString("results.byDate"), true); teamOption = new JRadioButton(messageResources.getString("results.byTeam"), false); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(dateOption); buttonGroup.add(teamOption); datesCombo.setRenderer( new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent( JList list, Object item, int row, boolean isSelected, boolean hasFocus) { return super.getListCellRendererComponent( list, dateFormat.format(item), row, isSelected, hasFocus); } }); venueCombo = new EnumComboBox<VenueType>(VenueType.class, messageResources); teamsCombo.setEnabled(false); venueCombo.setEnabled(false); ItemListener itemListener = new ItemListener() { public void itemStateChanged(ItemEvent itemEvent) { if (itemEvent.getStateChange() == ItemEvent.SELECTED) { if (itemEvent.getSource() == dateOption) { datesCombo.setEnabled(true); venueCombo.setEnabled(false); teamsCombo.setEnabled(false); } else if (itemEvent.getSource() == teamOption) { datesCombo.setEnabled(false); venueCombo.setEnabled(true); teamsCombo.setEnabled(true); } changeTables(); } } }; dateOption.addItemListener(itemListener); teamOption.addItemListener(itemListener); datesCombo.addItemListener(itemListener); teamsCombo.addItemListener(itemListener); venueCombo.addItemListener(itemListener); panel.add(dateOption); panel.add(datesCombo); panel.add(teamOption); panel.add(teamsCombo); panel.add(venueCombo); return panel; }
public MyRechteComboBox() { component = new JComboBox( new Object[] { SystemConfig.hmSysIcons.get("zuzahlnichtok"), SystemConfig.hmSysIcons.get("zuzahlok") }); ((JComboBox) component).setRenderer(new RechteComboBoxRenderer()); }
public Preferences(EPGSwingEngine swingEngine) { /** Initialize frame from preferences. */ final JDialog jDialog = (JDialog) swingEngine.find(EPGSwingEngine.PREFERENCES_DIALOG); jDialog.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent windowEvent) { Preferences.this.dispatchViewEvent(Preferences.this, ViewEvent.CLOSE_PREFERENCES); jDialog.dispose(); } }); _midiInCheckBox = (JCheckBox) swingEngine.find("MIDI_IN_CHECKBOX"); _midiInCheckBox.addActionListener(this); _midiInComboBox = (JComboBox) swingEngine.find("MIDI_IN_COMBOBOX"); _midiInComboBox.setRenderer(new PromptComboBoxRenderer("Select...")); _midiInComboBox.addActionListener(this); _midiOutCheckBox = (JCheckBox) swingEngine.find("MIDI_OUT_CHECKBOX"); _midiOutCheckBox.addActionListener(this); _midiInClockSyncCheckBox = (JCheckBox) swingEngine.find("MIDI_IN_CLOCK_CHECKBOX"); _midiInClockSyncCheckBox.addActionListener(this); _midiInTriggerByNoteCheckBox = (JCheckBox) swingEngine.find("MIDI_IN_NOTE_TRIGGER_CHECKBOX"); _midiInTriggerByNoteCheckBox.addActionListener(this); _midiOutComboBox = (JComboBox) swingEngine.find("MIDI_OUT_COMBOBOX"); _midiOutComboBox.setRenderer(new PromptComboBoxRenderer("Select...")); _midiOutComboBox.addActionListener(this); _oscOutCheckBox = (JCheckBox) swingEngine.find("OSC_OUT_CHECKBOX"); _oscOutCheckBox.addActionListener(this); _oscOutTextField = (JTextField) swingEngine.find("OSC_OUT_TEXTFIELD"); _oscOutTextField.addActionListener(this); _displayMidiNoteNamesCheckBox = (JCheckBox) swingEngine.find("MIDI_NOTE_NAMES_CHECKBOX"); _displayMidiNoteNamesCheckBox.addActionListener(this); _reloadLastProjectCheckBox = (JCheckBox) swingEngine.find("RELOAD_LAST_PROJECT_CHECKBOX"); _reloadLastProjectCheckBox.addActionListener(this); }