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); } }
private void handleEntryAction(ActionEvent actionEvent) throws IOException, ParserConfigurationException, XPathExpressionException, SAXException, NoItemException { if (this.getGazetteer() == null) { Util.getLogger().severe("No gazeteer is registered"); return; } String lookupString; JComboBox cmb = ((JComboBox) actionEvent.getSource()); lookupString = cmb.getSelectedItem().toString(); if (lookupString == null || lookupString.length() < 1) return; java.util.List<PointOfInterest> results = this.gazetteer.findPlaces(lookupString); if (results == null || results.size() == 0) return; this.controller.moveToLocation(results.get(0)); // Add it to the list if not already there for (int i = 0; i < cmb.getItemCount(); i++) { Object oi = cmb.getItemAt(i); if (oi != null && oi.toString().trim().equals(lookupString)) return; // item exists } cmb.insertItemAt(lookupString, 0); }
public void setIndexer(LibrariesIndexer indexer) { this.indexer = indexer; DropdownItem<DownloadableContribution> previouslySelectedCategory = (DropdownItem<DownloadableContribution>) categoryChooser.getSelectedItem(); DropdownItem<DownloadableContribution> previouslySelectedType = (DropdownItem<DownloadableContribution>) typeChooser.getSelectedItem(); categoryChooser.removeActionListener(categoryChooserActionListener); typeChooser.removeActionListener(typeChooserActionListener); // TODO: Remove setIndexer and make getContribModel // return a FilteredAbstractTableModel getContribModel().setIndexer(indexer); categoryFilter = null; categoryChooser.removeAllItems(); // Load categories categoryChooser.addItem(new DropdownAllItem()); Collection<String> categories = indexer.getIndex().getCategories(); for (String category : categories) { categoryChooser.addItem(new DropdownLibraryOfCategoryItem(category)); } categoryChooser.setEnabled(categoryChooser.getItemCount() > 1); categoryChooser.addActionListener(categoryChooserActionListener); if (previouslySelectedCategory != null) { categoryChooser.setSelectedItem(previouslySelectedCategory); } else { categoryChooser.setSelectedIndex(0); } typeFilter = null; typeChooser.removeAllItems(); typeChooser.addItem(new DropdownAllItem()); typeChooser.addItem(new DropdownInstalledLibraryItem(indexer.getIndex())); java.util.List<String> types = new LinkedList<String>(indexer.getIndex().getTypes()); Collections.sort(types, new LibraryTypeComparator()); for (String type : types) { typeChooser.addItem(new DropdownLibraryOfTypeItem(type)); } typeChooser.setEnabled(typeChooser.getItemCount() > 1); typeChooser.addActionListener(typeChooserActionListener); if (previouslySelectedType != null) { typeChooser.setSelectedItem(previouslySelectedType); } else { typeChooser.setSelectedIndex(0); } filterField.setEnabled(contribModel.getRowCount() > 0); // Create LibrariesInstaller tied with the provided index installer = new LibraryInstaller(indexer, platform) { @Override public void onProgress(Progress progress) { setProgress(progress); } }; }
@SuppressWarnings("UseJBColor") // Colors are used for the graphics generator, not the plugin UI public RasterAssetSetStep( TemplateWizardState state, @Nullable Project project, @Nullable Module module, @Nullable Icon sidePanelIcon, UpdateListener updateListener, @Nullable VirtualFile invocationTarget) { super(state, project, module, sidePanelIcon, updateListener, invocationTarget); // Speed the scrolling of myScrollPane myScrollPane.getVerticalScrollBar().setUnitIncrement(16); register(ATTR_TEXT, myText); register(ATTR_SCALING, myCropRadioButton, Scaling.CROP); register(ATTR_SCALING, myCenterRadioButton, Scaling.CENTER); register(ATTR_SHAPE, myCircleRadioButton, GraphicGenerator.Shape.CIRCLE); register(ATTR_SHAPE, myNoneRadioButton, GraphicGenerator.Shape.NONE); register(ATTR_SHAPE, mySquareRadioButton, GraphicGenerator.Shape.SQUARE); register(ATTR_SHAPE, myVerticalRadioButton, GraphicGenerator.Shape.VRECT); register(ATTR_SHAPE, myHorizontalRadioButton, GraphicGenerator.Shape.HRECT); register(ATTR_DOGEAR, myDogEarEffectCheckBox); register(ATTR_PADDING, myPaddingSlider); register(ATTR_TRIM, myTrimBlankSpace); register(ATTR_FONT, myFontFamily); register(ATTR_SOURCE_TYPE, myImageRadioButton, AssetStudioAssetGenerator.SourceType.IMAGE); register(ATTR_SOURCE_TYPE, myClipartRadioButton, AssetStudioAssetGenerator.SourceType.CLIPART); register(ATTR_SOURCE_TYPE, myTextRadioButton, AssetStudioAssetGenerator.SourceType.TEXT); register(ATTR_FOREGROUND_COLOR, myForegroundColor); register(ATTR_BACKGROUND_COLOR, myBackgroundColor); register(ATTR_ASSET_TYPE, myAssetTypeComboBox); register(ATTR_ASSET_THEME, myChooseThemeComboBox); register(ATTR_ASSET_NAME, myResourceNameField); myImageFile.addBrowseFolderListener( null, null, null, FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); myForegroundColor.setSelectedColor(Color.BLUE); myBackgroundColor.setSelectedColor(Color.WHITE); for (String font : GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()) { myFontFamily.addItem(new ComboBoxItem(font, font, 1, 1)); if (font.equals(myTemplateState.get(ATTR_FONT))) { myFontFamily.setSelectedIndex(myFontFamily.getItemCount() - 1); } } myChooseClipart.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { displayClipartDialog(); } }); populateComboBox(myAssetTypeComboBox, AssetType.class); populateComboBox(myChooseThemeComboBox, ActionBarIconGenerator.Theme.class); }
public void setSelectedFormat(String format) { for (int i = 0; i < formatComboBox.getItemCount(); i++) { DataSourceQueryChooser chooser = (DataSourceQueryChooser) formatComboBox.getItemAt(i); if (chooser.toString().equals(format)) { formatComboBox.setSelectedIndex(i); return; } } }
protected void createButtons(JPanel panel) { panel.add(new Filler(24, 20)); JComboBox drawingChoice = new JComboBox(); drawingChoice.addItem(fgUntitled); String param = getParameter("DRAWINGS"); if (param == null) { param = ""; } StringTokenizer st = new StringTokenizer(param); while (st.hasMoreTokens()) { drawingChoice.addItem(st.nextToken()); } if (drawingChoice.getItemCount() > 1) { panel.add(drawingChoice); } else { panel.add(new JLabel(fgUntitled)); } drawingChoice.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { loadDrawing((String) e.getItem()); } } }); panel.add(new Filler(6, 20)); JButton button; button = new CommandButton(new DeleteCommand("Delete", this)); panel.add(button); button = new CommandButton(new DuplicateCommand("Duplicate", this)); panel.add(button); button = new CommandButton(new GroupCommand("Group", this)); panel.add(button); button = new CommandButton(new UngroupCommand("Ungroup", this)); panel.add(button); button = new JButton("Help"); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { showHelp(); } }); panel.add(button); fUpdateButton = new JButton("Simple Update"); fUpdateButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { if (fSimpleUpdate) { setBufferedDisplayUpdate(); } else { setSimpleDisplayUpdate(); } } }); }
@Override public void actionPerformed(ActionEvent arg0) { if (version.getItemCount() > 0) { Settings.getSettings() .setPackVer( (String.valueOf(version.getSelectedItem()).equalsIgnoreCase("recommended") ? "Recommended Version" : String.valueOf(version.getSelectedItem()))); Settings.getSettings().save(); } }
private void selectThread(ThreadReferenceProxyImpl toSelect) { int count = myThreadsCombo.getItemCount(); for (int idx = 0; idx < count; idx++) { ThreadDescriptorImpl item = (ThreadDescriptorImpl) myThreadsCombo.getItemAt(idx); if (toSelect.equals(item.getThreadReference())) { if (!item.equals(myThreadsCombo.getSelectedItem())) { myThreadsCombo.setSelectedIndex(idx); } return; } } }
private void applySelectedValue(JComboBox comboBox, Object value) { comboBox.removeItemListener(this); ValueLabelItem currentItem; for (int i = 0; i < comboBox.getItemCount(); i++) { currentItem = (ValueLabelItem) comboBox.getItemAt(i); if (currentItem.getValue().equals(value)) { comboBox.setSelectedIndex(i); break; } } comboBox.addItemListener(this); }
public void finalizeAssetType(AssetType type) { mySelectedAssetType = type; myTemplateState.put(ATTR_ASSET_TYPE, type.name()); for (int i = 0; i < myAssetTypeComboBox.getItemCount(); ++i) { if (((ComboBoxItem) myAssetTypeComboBox.getItemAt(i)).id.equals(type.name())) { myAssetTypeComboBox.setSelectedIndex(i); break; } } hide(myAssetTypeComboBox, myAssetTypeLabel); update(); }
/** Sets up how the different GUI components should be viewed at startup. */ private void initializeDisplay() { if (itemNames.getItemCount() > 0) { itemNames.setSelectedIndex(0); } else { txtFlavor.setEnabled(false); txtStock.setEnabled(false); txtSalePrice.setEnabled(false); btnUpdate.setEnabled(false); btnDelete.setEnabled(false); btnNew.doClick(); } }
public void setAgent(String agentName) { int index = 0; debug("scanning " + agents.getItemCount() + " agents"); for (int i = 0; i < agents.getItemCount(); i++) { if (agents.getItemAt(i).toString().equals(agentName)) { index = i; debug("matched " + agentName); } else { debug("not matched " + agentName); } } agents.setSelectedIndex(index); }
public void updateLists(List<? extends ChangeList> lists) { //noinspection unchecked myChooser.setModel(new DefaultComboBoxModel(lists.toArray())); myChooser.setEnabled(lists.size() > 1); if (lists.contains(mySelectedChangeList)) { myChooser.setSelectedItem(mySelectedChangeList); } else { if (myChooser.getItemCount() > 0) { myChooser.setSelectedIndex(0); } } mySelectedChangeList = (ChangeList) myChooser.getSelectedItem(); }
/*invoked in swing thread*/ protected void rebuild(final boolean updateOnly) { if (!updateOnly) { myThreadsCombo.removeAllItems(); synchronized (myFramesList) { myFramesList.clear(); } } final DebugProcessImpl process = getContext().getDebugProcess(); if (process != null) { process .getManagerThread() .schedule(new RefreshFramePanelCommand(updateOnly && myThreadsCombo.getItemCount() != 0)); } }
/** * Set the fields from the ProjectionClass * * @param projClass projection class to use */ private void setFieldsWithClassParams(ProjectionClass projClass) { // set the projection in the JComboBox String want = projClass.toString(); for (int i = 0; i < projClassCB.getItemCount(); i++) { ProjectionClass pc = (ProjectionClass) projClassCB.getItemAt(i); if (pc.toString().equals(want)) { projClassCB.setSelectedItem((Object) pc); break; } } // set the parameter fields paramPanel.removeAll(); paramPanel.setVisible(0 < projClass.paramList.size()); List widgets = new ArrayList(); for (int i = 0; i < projClass.paramList.size(); i++) { ProjectionParam pp = (ProjectionParam) projClass.paramList.get(i); // construct the label String name = pp.name; String text = ""; // Create a decent looking label for (int cIdx = 0; cIdx < name.length(); cIdx++) { char c = name.charAt(cIdx); if (cIdx == 0) { c = Character.toUpperCase(c); } else { if (Character.isUpperCase(c)) { text += " "; c = Character.toLowerCase(c); } } text += c; } widgets.add(GuiUtils.rLabel(text + ": ")); // text input field JTextField tf = new JTextField(); pp.setTextField(tf); tf.setColumns(12); widgets.add(tf); } GuiUtils.tmpInsets = new Insets(4, 4, 4, 4); JPanel widgetPanel = GuiUtils.doLayout(widgets, 2, GuiUtils.WT_N, GuiUtils.WT_N); paramPanel.add("North", widgetPanel); paramPanel.add("Center", GuiUtils.filler()); }
/** _more_ */ private void setTimesInTimesBox() { DateTime[] theTimesArray = this.timesArray; if (theTimesArray == null) { return; } boolean oldValue = ignoreTimesCbxEvents; try { ignoreTimesCbxEvents = true; GuiUtils.setListData(timesCbx, theTimesArray); timesCbx.setVisible( timesCbxVisible && (theTimesArray != null) && (timesCbx.getItemCount() > 0)); } finally { ignoreTimesCbxEvents = oldValue; } }
/** Alter the bounds of the popup just before it is made visible. */ @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { JComboBox comboBox = (JComboBox) e.getSource(); if (comboBox.getItemCount() == 0) return; final Object child = comboBox.getAccessibleContext().getAccessibleChild(0); if (child instanceof BasicComboPopup) { SwingUtilities.invokeLater( new Runnable() { public void run() { customizePopup((BasicComboPopup) child); } }); } }
public void setSelectedDisplayOption(MatrixType[] options, boolean control) { if (control) { MatrixType originalMatrixType = (MatrixType) displayOptionComboBox.getSelectedItem(); displayOptionComboBox.setModel(new DefaultComboBoxModel<MatrixType>(options)); int indx = 0; for (int i = 0; i < displayOptionComboBox.getItemCount(); i++) { if (originalMatrixType.equals(displayOptionComboBox.getItemAt(i))) { indx = i; break; } } displayOptionComboBox.setSelectedIndex(indx); } else { displayOptionComboBox.setModel(new DefaultComboBoxModel<MatrixType>(options)); displayOptionComboBox.setSelectedIndex(0); } }
public void keyReleased(KeyEvent e) { char ch = e.getKeyChar(); if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch)) return; int pos = m_editor.getCaretPosition(); String str = m_editor.getText(); if (str.length() == 0) return; for (int k = 0; k < m_comboBox.getItemCount(); k++) { String item = m_comboBox.getItemAt(k).toString(); if (item.startsWith(str)) { m_editor.setText(item); m_editor.setCaretPosition(item.length()); m_editor.moveCaretPosition(pos); m_comboBox.setSelectedItem(item); break; } } }
public void loadData() { try { con = dbcon.myconnection(); st = con.createStatement(); rs = st.executeQuery("select * from screen_detail"); while (rs.next() == true) { jscreenName.addItem(rs.getString(2)); } int cnt = jscreenName.getItemCount() - 1; // int cnt1=Integer.parseInt(CDepno.getItem(cnt))+1 ; // screenRowVal.setText(String.valueOf(cnt)); st.close(); rs.close(); con.close(); System.out.println("Retrived successfully...."); } catch (IOException ex) { } catch (SQLException ex) { } }
private void addReflItem(String str, Con con) { reflectivities.put(con, reflBox.getItemCount()); reflBox.addItem(str); }
private void addConItem(String str, Con con) { conspicuities.put(con, conBox.getItemCount()); conBox.addItem(str); }
private void addCnsItem(String str, Cns cns) { constructions.put(cns, constrBox.getItemCount()); constrBox.addItem(str); }
private void addStsItem(String str, Sts sts) { statuses.put(sts, statusBox.getItemCount()); statusBox.addItem(str); }
private void addCatItem(String str, Cat cat) { categories.put(cat, categoryBox.getItemCount()); categoryBox.addItem(str); }
private void addMorItem(String str, Cat cat) { moorings.put(cat, mooringBox.getItemCount()); mooringBox.addItem(str); }
/* * I can't find any property on the scrollBar to determine if it will be * displayed or not so use brute force to determine this. */ protected int getScrollBarWidth(BasicComboPopup popup, JScrollPane scrollPane) { int scrollBarWidth = 0; JComboBox comboBox = (JComboBox) popup.getInvoker(); if (comboBox.getItemCount() > comboBox.getMaximumRowCount()) { JScrollBar vertical = scrollPane.getVerticalScrollBar(); scrollBarWidth = vertical.getPreferredSize().width; } return scrollBarWidth; }