Java Code Examples for javax.swing.JComboBox#setSelectedIndex()
The following examples show how to use
javax.swing.JComboBox#setSelectedIndex() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GenerateCodeDialog.java From jeddict with Apache License 2.0 | 6 votes |
private void populateProjectCombo(JComboBox projectCombo, ProjectInfo projectInfo) { ProjectCellRenderer projectCellRenderer = new ProjectCellRenderer(projectCombo.getRenderer()); projectCombo.setRenderer(projectCellRenderer); List<Project> list = getJavaProjects(); if (list == null || list.isEmpty()) { enableExistingProjectElementGroup(false); } else { DefaultComboBoxModel projectsModel = new DefaultComboBoxModel(list.toArray()); projectCombo.setModel(projectsModel); // Issue Fix #5850 Project modelerProject = FileOwnerQuery.getOwner(modelerFileObject); if (modelerProject != null) { projectCombo.setSelectedItem(modelerProject); } else { projectCombo.setSelectedIndex(-1); } selectProject(projectCombo, projectInfo); } }
Example 2
Source File: BasicInfoVisualPanel.java From netbeans with Apache License 2.0 | 6 votes |
protected static void initPlatformCombo(JComboBox combo) { if (combo == null){ return; } if (combo.getItemCount() <= 0) { return; } boolean set = false; String idToSelect = ModuleUISettings.getDefault().getLastUsedPlatformID(); for (int i = 0; i < combo.getItemCount(); i++) { if (((NbPlatform) combo.getItemAt(i)).getID().equals(idToSelect)) { combo.setSelectedIndex(i); set = true; break; } } if (!set) { NbPlatform defPlaf = NbPlatform.getDefaultPlatform(); combo.setSelectedItem(defPlaf == null ? combo.getItemAt(0) : defPlaf); } }
Example 3
Source File: InfoPanel.java From the-one with GNU General Public License v3.0 | 6 votes |
/** * Show information about a host * @param host Host to show the information of */ public void showInfo(DTNHost host) { Vector<Message> messages = new Vector<Message>(host.getMessageCollection()); Collections.sort(messages); reset(); this.selectedHost = host; String text = (host.isMovementActive() ? "" : "INACTIVE ") + host + " at " + host.getLocation(); msgChooser = new JComboBox(messages); msgChooser.insertItemAt(messages.size() + " messages", 0); msgChooser.setSelectedIndex(0); msgChooser.addActionListener(this); routingInfoButton = new JButton("routing info"); routingInfoButton.addActionListener(this); this.add(new JLabel(text)); this.add(msgChooser); this.add(routingInfoButton); this.revalidate(); }
Example 4
Source File: CExceptionSettingsPanel.java From binnavi with Apache License 2.0 | 6 votes |
/** * Construct a tuple of a label and a corresponding combobox allowing the user to control how the * debugger handles exceptions */ private static JComboBox<String> buildRow(final JPanel componentPanel, final DebuggerException exception) { componentPanel.add(new JLabel(exception.getExceptionName())); final JComboBox<String> combobox = new JComboBox<String>(); combobox.addItem(getString(DebuggerExceptionHandlingAction.Continue)); combobox.addItem(getString(DebuggerExceptionHandlingAction.Halt)); combobox.addItem(getString(DebuggerExceptionHandlingAction.Ignore)); combobox.setSelectedIndex(exception.getExceptionAction().getValue()); componentPanel.add(combobox); return combobox; }
Example 5
Source File: ActionUtils.java From visualvm with GNU General Public License v2.0 | 6 votes |
/** * Insert the given item into the combo box, and set it as first selected * item. If the item already exists, it is removed, so there are no * duplicates. * @param combo * @param item */ public static void insertIntoCombo(JComboBox combo, Object item) { MutableComboBoxModel model = (MutableComboBoxModel) combo.getModel(); if (model.getSize() == 0) { model.insertElementAt(item, 0); return; } Object o = model.getElementAt(0); if (o.equals(item)) { return; } model.removeElement(item); model.insertElementAt(item, 0); combo.setSelectedIndex(0); }
Example 6
Source File: AnimationObjectEditor.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
private void initSourceDestMotion(Motion m, JSpinner start, JCheckBox check, JSpinner dest, JComboBox motionType) { if(m == null) { check.setSelected(false); start.setEnabled(false); dest.setEnabled(false); return; } start.setValue(m.getSourceValue()); //if(m.getSourceValue() != m.getDestinationValue()) { check.setSelected(true); motionType.setEnabled(true); dest.setEnabled(true); start.setEnabled(true); //} else { // check.setSelected(false); //} motionType.setSelectedIndex(AnimationAccessor.getMotionType(m) - 1); dest.setValue(m.getDestinationValue()); }
Example 7
Source File: Attributes.java From Logisim with GNU General Public License v3.0 | 5 votes |
@Override public java.awt.Component getCellEditor(Object value) { JComboBox<Object> combo = new JComboBox<Object>(vals); combo.setRenderer(new OptionComboRenderer<V>(this)); if (value == null) combo.setSelectedIndex(-1); else combo.setSelectedItem(value); return combo; }
Example 8
Source File: SymmetryGui.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
private Box setupAlgorithm() { String[] algorithms = {"JCE-symmetry"}; JLabel algoLabel = new JLabel("Symmetry algorithm: "); JComboBox algorithmList = new JComboBox(algorithms); algorithmList.setSelectedIndex(0); Action paramAction = new AbstractAction("Parameters") { public static final long serialVersionUID = 0l; // This method is called when the button is pressed @Override public void actionPerformed(ActionEvent evt) { // Perform action... configureParameters(); } }; JButton parameterButton = new JButton(paramAction); Box hBoxAlgo = Box.createHorizontalBox(); hBoxAlgo.add(Box.createGlue()); hBoxAlgo.add(algoLabel); hBoxAlgo.add(algorithmList); hBoxAlgo.add(Box.createGlue()); hBoxAlgo.add(parameterButton); hBoxAlgo.add(Box.createGlue()); return hBoxAlgo; }
Example 9
Source File: NextFunctionAction.java From ghidra with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(ActionContext context) { ComponentProvider provider = context.getComponentProvider(); MultiFunctionComparisonPanel panel = (MultiFunctionComparisonPanel) provider.getComponent(); JComboBox<Function> focusedComponent = panel.getFocusedComponent(); focusedComponent.setSelectedIndex(focusedComponent.getSelectedIndex() + 1); }
Example 10
Source File: RetroWeaverGui.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
private Component createTargetChooser() { targetCombo = new JComboBox(new String[] { "1.4", "1.3", "1.2" }); targetCombo.setSelectedIndex(0); targetCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { status.setText(READY); } }); return targetCombo; }
Example 11
Source File: EncodingTab.java From BurpSuiteHTTPSmuggler with GNU Affero General Public License v3.0 | 5 votes |
private void setValueFromExtensionSettings(JComboBox jComboBox, String name, Object defaultValue) { String value = _callbacks.loadExtensionSetting(name); if(value!=null && !value.equals("")) { int temp_value = Integer.valueOf(value); if(temp_value!=jComboBox.getSelectedIndex()) jComboBox.setSelectedIndex(temp_value); }else { jComboBox.setSelectedIndex((int) defaultValue); } }
Example 12
Source File: PersistenceProviderComboboxHelper.java From netbeans with Apache License 2.0 | 5 votes |
private void initCombo(JComboBox providerCombo) { DefaultComboBoxModel providers = new DefaultComboBoxModel(); for(Provider each : providerSupplier.getSupportedProviders()){ providers.addElement(each); } if (providers.getSize() == 0 && providerSupplier.supportsDefaultProvider()){ providers.addElement(ProviderUtil.DEFAULT_PROVIDER); } if (providers.getSize() == 0){ providers.addElement(EMPTY); } providerCombo.setModel(providers); providerCombo.addItem(SEPARATOR); providerCombo.addItem(new NewPersistenceLibraryItem()); providerCombo.addItem(new ManageLibrariesItem()); providerCombo.setRenderer(new PersistenceProviderCellRenderer(getDefaultProvider(providers))); //select either default or first or preferred provider depending on project details int selectIndex = 0; if(providers.getSize()>1 && providers.getElementAt(0) instanceof Provider){ String defProviderVersion = ProviderUtil.getVersion((Provider) providers.getElementAt(0)); boolean specialCase = (Util.isJPAVersionSupported(project, Persistence.VERSION_2_0) || Util.isJPAVersionSupported(project, Persistence.VERSION_2_1)) && (defProviderVersion == null || defProviderVersion.equals(Persistence.VERSION_1_0));//jpa 2.0 is supported by default (or first) is jpa1.0 or udefined version provider if(specialCase){ for (int i = 1; i<providers.getSize() ; i++){ if(preferredProvider.equals(providers.getElementAt(i))){ selectIndex = i; break; } } } } providerCombo.setSelectedIndex(selectIndex); }
Example 13
Source File: EmbeddedFrameGrabTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Test fails if it throws any exception. * * @throws Exception */ private void init() throws Exception { if (!System.getProperty("os.name").startsWith("Windows")) { System.out.println("This is Windows only test."); return; } final Frame frame = new Frame("AWT Frame"); frame.pack(); frame.setSize(200, 200); FramePeer frame_peer = AWTAccessor.getComponentAccessor() .getPeer(frame); Class comp_peer_class = Class.forName("sun.awt.windows.WComponentPeer"); Field hwnd_field = comp_peer_class.getDeclaredField("hwnd"); hwnd_field.setAccessible(true); long hwnd = hwnd_field.getLong(frame_peer); Class clazz = Class.forName("sun.awt.windows.WEmbeddedFrame"); Constructor constructor = clazz.getConstructor(new Class[]{long.class}); final Frame embedded_frame = (Frame) constructor.newInstance(new Object[]{ new Long(hwnd)});; final JComboBox<String> combo = new JComboBox<>(new String[]{ "Item 1", "Item 2" }); combo.setSelectedIndex(1); final Panel p = new Panel(); p.setLayout(new BorderLayout()); embedded_frame.add(p, BorderLayout.CENTER); embedded_frame.validate(); p.add(combo); p.validate(); frame.setVisible(true); Robot robot = new Robot(); robot.delay(2000); Rectangle clos = new Rectangle( combo.getLocationOnScreen(), combo.getSize()); robot.mouseMove(clos.x + clos.width / 2, clos.y + clos.height / 2); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); robot.delay(1000); if (!combo.isPopupVisible()) { throw new RuntimeException("Combobox popup is not visible!"); } robot.mouseMove(clos.x + clos.width / 2, clos.y + clos.height + 3); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); robot.delay(1000); if (combo.getSelectedIndex() != 0) { throw new RuntimeException("Combobox selection has not changed!"); } embedded_frame.remove(p); embedded_frame.dispose(); frame.dispose(); }
Example 14
Source File: MainWindow.java From xdm with GNU General Public License v2.0 | 4 votes |
private void optimizeRWin() { JComboBox<String> cmbLang = new JComboBox<>( new String[] { StringResource.get("LBL_NET_OPT_DEF"), StringResource.get("LBL_NET_OPT_64"), StringResource.get("LBL_NET_OPT_128"), StringResource.get("LBL_NET_OPT_256") }); cmbLang.setSelectedIndex(0); String prompt = StringResource.get("LBL_NET_OPT_MSG"); Object[] obj = new Object[2]; obj[0] = prompt; obj[1] = cmbLang; switch (Config.getInstance().getTcpWindowSize()) { case 64: cmbLang.setSelectedIndex(1); break; case 128: cmbLang.setSelectedIndex(2); break; case 256: cmbLang.setSelectedIndex(3); break; default: cmbLang.setSelectedIndex(0); } if (JOptionPane.showOptionDialog(null, obj, StringResource.get("LBL_OPTIMIZE_NETWORK"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null) == JOptionPane.OK_OPTION) { int index = cmbLang.getSelectedIndex(); if (index != -1) { switch (index) { case 1: Config.getInstance().setTcpWindowSize(64); break; case 2: Config.getInstance().setTcpWindowSize(128); break; case 3: Config.getInstance().setTcpWindowSize(256); break; default: Config.getInstance().setTcpWindowSize(0); } } } }
Example 15
Source File: BinningFilterPanel.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
private Component createTemporalFilterPanel() { TableLayout layout = new TableLayout(3); layout.setTableFill(TableLayout.Fill.BOTH); layout.setTableAnchor(TableLayout.Anchor.NORTHWEST); layout.setTableWeightX(0.0); layout.setTableWeightY(0.0); layout.setTablePadding(10, 5); layout.setCellColspan(0, 1, 2); layout.setCellColspan(3, 1, 2); layout.setCellWeightX(2, 1, 1.0); layout.setCellWeightX(2, 2, 0.0); layout.setColumnWeightX(1, 1.0); JPanel panel = new JPanel(layout); JLabel temporalFilterLabel = new JLabel("Time filter method:"); JLabel startDateLabel = new JLabel("Start date:"); JLabel startDateFormatLabel = new JLabel("yyyy-MM-dd( HH:mm:ss)"); JLabel periodDurationLabel = new JLabel("Period duration:"); JLabel minDataHourLabel = new JLabel("Min data hour:"); JLabel periodDurationUnitLabel = new JLabel("days"); final JComboBox<BinningOp.TimeFilterMethod> temporalFilterComboBox = new JComboBox<>(new BinningOp.TimeFilterMethod[]{ NONE, TIME_RANGE, SPATIOTEMPORAL_DATA_DAY }); temporalFilterComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { BinningOp.TimeFilterMethod method = (BinningOp.TimeFilterMethod) temporalFilterComboBox.getSelectedItem(); if (method != null) { temporalFilterComboBox.setToolTipText(timeFilterMethodDescriptions.get(method)); } } }); JTextField startDateTextField = new JTextField(); JTextField periodDurationTextField = new JTextField(); JTextField minDataHourTextField = new JTextField(); startDateLabel.setEnabled(false); periodDurationLabel.setEnabled(false); temporalFilterLabel.setToolTipText("The method that is used to decide which source pixels are used with respect to their observation time."); startDateLabel.setToolTipText("The UTC start date of the binning period. If only the date part is given, the time 00:00:00 is assumed."); periodDurationLabel.setToolTipText("Duration of the binning period in days."); minDataHourLabel.setToolTipText( "A sensor-dependent constant given in hours of a day (0 to 24) at which a sensor has a minimum number of observations at the date line (the 180 degree meridian)."); BindingContext bindingContext = binningFormModel.getBindingContext(); bindingContext.bind(BinningFormModel.PROPERTY_KEY_TIME_FILTER_METHOD, temporalFilterComboBox); bindingContext.bind(BinningFormModel.PROPERTY_KEY_START_DATE_TIME, startDateTextField); bindingContext.bind(BinningFormModel.PROPERTY_KEY_PERIOD_DURATION, periodDurationTextField); bindingContext.bind(BinningFormModel.PROPERTY_KEY_MIN_DATA_HOUR, minDataHourTextField); bindingContext.getBinding(BinningFormModel.PROPERTY_KEY_START_DATE_TIME).addComponent(startDateLabel); bindingContext.getBinding(BinningFormModel.PROPERTY_KEY_START_DATE_TIME).addComponent(startDateFormatLabel); bindingContext.getBinding(BinningFormModel.PROPERTY_KEY_PERIOD_DURATION).addComponent(periodDurationLabel); bindingContext.getBinding(BinningFormModel.PROPERTY_KEY_PERIOD_DURATION).addComponent(periodDurationUnitLabel); bindingContext.getBinding(BinningFormModel.PROPERTY_KEY_MIN_DATA_HOUR).addComponent(minDataHourLabel); temporalFilterComboBox.setSelectedIndex(0); // selected value must not be empty when setting enablement bindingContext.bindEnabledState(BinningFormModel.PROPERTY_KEY_START_DATE_TIME, true, hasTimeInformation(TIME_RANGE, SPATIOTEMPORAL_DATA_DAY)); bindingContext.bindEnabledState(BinningFormModel.PROPERTY_KEY_PERIOD_DURATION, true, hasTimeInformation(TIME_RANGE, SPATIOTEMPORAL_DATA_DAY)); bindingContext.bindEnabledState(BinningFormModel.PROPERTY_KEY_MIN_DATA_HOUR, true, hasTimeInformation(SPATIOTEMPORAL_DATA_DAY)); temporalFilterComboBox.setSelectedIndex(0); // ensure that enablement is applied panel.add(temporalFilterLabel); panel.add(temporalFilterComboBox); panel.add(startDateLabel); panel.add(startDateTextField); panel.add(startDateFormatLabel); panel.add(periodDurationLabel); panel.add(periodDurationTextField); panel.add(periodDurationUnitLabel); panel.add(minDataHourLabel); panel.add(minDataHourTextField); return panel; }
Example 16
Source File: ProfileBaseForm.java From netbeans with Apache License 2.0 | 4 votes |
protected void setCombo(JComboBox combo, boolean second) { combo.setSelectedIndex(second ? 1 : 0); }
Example 17
Source File: SwingDropDownListWidget.java From atdl4j with MIT License | 4 votes |
@Override protected List< ? extends Component> createBrickComponents() { ArrayList<Component> components = new ArrayList<Component>(); String tooltip = getTooltip(); // label if ( control.getLabel() != null ) { label = new JLabel(); label.setName(getName()+"/label"); label.setText( control.getLabel()); if ( tooltip != null ) label.setToolTipText( tooltip ); } // dropDownList dropDownList = new JComboBox(); dropDownList.setName(getName()+"/dropdownlist"); // set editable dropDownList.setEditable(control instanceof EditableDropDownListT); // dropDownList items List<ListItemT> listItems = ( control instanceof EditableDropDownListT ) ? ( (EditableDropDownListT) control ).getListItem() : ( (DropDownListT) control ).getListItem(); // TODO: throw error if there are no list items for ( ListItemT listItem : listItems ) dropDownList.addItem(listItem.getUiRep() != null ? listItem.getUiRep() : ""); // tooltip if ( tooltip != null ) dropDownList.setToolTipText( tooltip ); // default initializer dropDownList.setSelectedIndex(0); // select initValue if available String initValue = (String) ControlHelper.getInitValue( control, getAtdl4jOptions() ); if ( initValue != null ) setValue( initValue, true ); if (label != null){ components.add(label); } components.add( dropDownList); return components; }
Example 18
Source File: ConnectPanel.java From netbeans with Apache License 2.0 | 4 votes |
private void addConnectors(int defaultIndex) { //assert connectorsLoaded.get(); if (connectors.isEmpty()) { // no attaching connectors available => print message only add (new JLabel ( NbBundle.getMessage (ConnectPanel.class, "CTL_No_Connector") )); return; } if (connectors.size () > 1) { // more than one attaching connector available => // init cbConnectors & selext default connector cbConnectors = new JComboBox (); cbConnectors.getAccessibleContext ().setAccessibleDescription ( NbBundle.getMessage (ConnectPanel.class, "ACSD_CTL_Connector") ); int i, k = connectors.size (); for (i = 0; i < k; i++) { Connector connector = connectors.get (i); int jj = connector.name ().lastIndexOf ('.'); String s = (jj < 0) ? connector.name () : connector.name ().substring (jj + 1); cbConnectors.addItem ( s + " (" + connector.description () + ")" ); } cbConnectors.setActionCommand ("SwitchMe!"); cbConnectors.addActionListener (this); } cbConnectors.setSelectedIndex (defaultIndex); selectedConnector = connectors.get(defaultIndex); setCursor(standardCursor); synchronized (connectorsLoaded) { connectorsLoaded.set(true); connectorsLoaded.notifyAll(); } }
Example 19
Source File: MyMenuBar.java From JByteMod-Beta with GNU General Public License v2.0 | 4 votes |
protected void replaceLDC() { final JPanel panel = new JPanel(new BorderLayout(5, 5)); final JPanel input = new JPanel(new GridLayout(0, 1)); final JPanel labels = new JPanel(new GridLayout(0, 1)); panel.add(labels, "West"); panel.add(input, "Center"); panel.add(new JLabel(JByteMod.res.getResource("big_string_warn")), "South"); labels.add(new JLabel("Find: ")); JTextField find = new JTextField(); input.add(find); labels.add(new JLabel("Replace with: ")); JTextField with = new JTextField(); input.add(with); JComboBox<String> ldctype = new JComboBox<String>(new String[] { "String", "float", "double", "int", "long" }); ldctype.setSelectedIndex(0); labels.add(new JLabel("Ldc Type: ")); input.add(ldctype); JCheckBox exact = new JCheckBox(JByteMod.res.getResource("exact")); JCheckBox cases = new JCheckBox(JByteMod.res.getResource("case_sens")); labels.add(exact); input.add(cases); if (JOptionPane.showConfirmDialog(this.jbm, panel, "Replace LDC", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, searchIcon) == JOptionPane.OK_OPTION && !find.getText().isEmpty()) { int expectedType = ldctype.getSelectedIndex(); boolean equal = exact.isSelected(); boolean ignoreCase = !cases.isSelected(); String findCst = find.getText(); if (ignoreCase) { findCst = findCst.toLowerCase(); } String replaceWith = with.getText(); int i = 0; for (ClassNode cn : jbm.getFile().getClasses().values()) { for (MethodNode mn : cn.methods) { for (AbstractInsnNode ain : mn.instructions) { if (ain.getType() == AbstractInsnNode.LDC_INSN) { LdcInsnNode lin = (LdcInsnNode) ain; Object cst = lin.cst; int type; if (cst instanceof String) { type = 0; } else if (cst instanceof Float) { type = 1; } else if (cst instanceof Double) { type = 2; } else if (cst instanceof Long) { type = 3; } else if (cst instanceof Integer) { type = 4; } else { type = -1; } String cstStr = cst.toString(); if (ignoreCase) { cstStr = cstStr.toLowerCase(); } if (type == expectedType) { if (equal ? cstStr.equals(findCst) : cstStr.contains(findCst)) { switch (type) { case 0: lin.cst = replaceWith; break; case 1: lin.cst = Float.parseFloat(replaceWith); break; case 2: lin.cst = Double.parseDouble(replaceWith); break; case 3: lin.cst = Long.parseLong(replaceWith); break; case 4: lin.cst = Integer.parseInt(replaceWith); break; } i++; } } } } } } JByteMod.LOGGER.log(i + " ldc's replaced"); } }
Example 20
Source File: SiteRateModelEditor.java From beast-mcmc with GNU Lesser General Public License v2.1 | 4 votes |
public SiteRateModelEditor(PartitionDataList dataList, int row) throws NumberFormatException, BadLocationException { this.dataList = dataList; this.row = row; siteParameterFields = new RealNumberField[PartitionData.siteRateModelParameterNames.length]; window = new JDialog(owner, "Setup site rate model for partition " + (row + 1)); optionPanel = new OptionsPanel(12, 12, SwingConstants.CENTER); siteCombo = new JComboBox(); siteCombo.setOpaque(false); for (String siteModel : PartitionData.siteRateModels) { siteCombo.addItem(siteModel); }// END: fill loop siteCombo.addItemListener(new ListenSiteCombo()); for (int i = 0; i < PartitionData.siteRateModelParameterNames.length; i++) { switch (i) { case 0: // GammaCategories siteParameterFields[i] = new RealNumberField(1.0, Double.valueOf(Integer.MAX_VALUE)); break; case 1: // Alpha siteParameterFields[i] = new RealNumberField(0.0, Double.MAX_VALUE); break; case 2: // Invariant sites proportion siteParameterFields[i] = new RealNumberField(0.0, 1.0); break; default: siteParameterFields[i] = new RealNumberField(); }//END: parameter switch siteParameterFields[i].setColumns(8); siteParameterFields[i].setValue(dataList.get(0).siteRateModelParameterValues[i]); }// END: fill loop setSiteArguments(); // Buttons JPanel buttonsHolder = new JPanel(); buttonsHolder.setOpaque(false); cancel = new JButton("Cancel", Utils.createImageIcon(Utils.CLOSE_ICON)); cancel.addActionListener(new ListenCancel()); buttonsHolder.add(cancel); done = new JButton("Done", Utils.createImageIcon(Utils.CHECK_ICON)); done.addActionListener(new ListenOk()); buttonsHolder.add(done); // Window owner = Utils.getActiveFrame(); window.setLocationRelativeTo(owner); window.getContentPane().setLayout(new BorderLayout()); window.getContentPane().add(optionPanel, BorderLayout.CENTER); window.getContentPane().add(buttonsHolder, BorderLayout.SOUTH); window.pack(); //return to the previously chosen index on start siteCombo.setSelectedIndex(dataList.get(row).siteRateModelIndex); }