Example usage for javax.swing JComboBox JComboBox

List of usage examples for javax.swing JComboBox JComboBox

Introduction

In this page you can find the example usage for javax.swing JComboBox JComboBox.

Prototype

public JComboBox(Vector<E> items) 

Source Link

Document

Creates a JComboBox that contains the elements in the specified Vector.

Usage

From source file:au.com.jwatmuff.eventmanager.gui.wizard.SeedingPanel.java

private TableCellEditor getSeedingCellEditor(int numPlayers) {
    Object[] values = new Object[numPlayers + 1];
    values[0] = "None";
    for (int i = 1; i <= numPlayers; i++)
        values[i] = "" + i;

    return new DefaultCellEditor(new JComboBox<>(values));
}

From source file:TableSelectionDemo.java

public TableSelectionDemo() {
    super(new BorderLayout());

    String[] columnNames = { "French", "Spanish", "Italian" };
    String[][] tableData = { { "un", "uno", "uno" }, { "deux", "dos", "due" }, { "trois", "tres", "tre" },
            { "quatre", "cuatro", "quattro" }, { "cinq", "cinco", "cinque" }, { "six", "seis", "sei" },
            { "sept", "siete", "sette" } };

    table = new JTable(tableData, columnNames);
    listSelectionModel = table.getSelectionModel();
    listSelectionModel.addListSelectionListener(new SharedListSelectionHandler());
    table.setSelectionModel(listSelectionModel);
    JScrollPane tablePane = new JScrollPane(table);

    // Build control area (use default FlowLayout).
    JPanel controlPane = new JPanel();
    String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" };

    final JComboBox comboBox = new JComboBox(modes);
    comboBox.setSelectedIndex(2);/*from   ww w  .jav a 2  s.  co m*/
    comboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String newMode = (String) comboBox.getSelectedItem();
            if (newMode.equals("SINGLE_SELECTION")) {
                listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) {
                listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
            } else {
                listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            }
            output.append("----------" + "Mode: " + newMode + "----------" + newline);
        }
    });
    controlPane.add(new JLabel("Selection mode:"));
    controlPane.add(comboBox);

    // Build output area.
    output = new JTextArea(1, 10);
    output.setEditable(false);
    JScrollPane outputPane = new JScrollPane(output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    // Do the layout.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    add(splitPane, BorderLayout.CENTER);

    JPanel topHalf = new JPanel();
    topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS));
    JPanel listContainer = new JPanel(new GridLayout(1, 1));
    JPanel tableContainer = new JPanel(new GridLayout(1, 1));
    tableContainer.setBorder(BorderFactory.createTitledBorder("Table"));
    tableContainer.add(tablePane);
    tablePane.setPreferredSize(new Dimension(420, 130));
    topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
    topHalf.add(listContainer);
    topHalf.add(tableContainer);

    topHalf.setMinimumSize(new Dimension(250, 50));
    topHalf.setPreferredSize(new Dimension(200, 110));
    splitPane.add(topHalf);

    JPanel bottomHalf = new JPanel(new BorderLayout());
    bottomHalf.add(controlPane, BorderLayout.PAGE_START);
    bottomHalf.add(outputPane, BorderLayout.CENTER);
    // XXX: next line needed if bottomHalf is a scroll pane:
    // bottomHalf.setMinimumSize(new Dimension(400, 50));
    bottomHalf.setPreferredSize(new Dimension(450, 110));
    splitPane.add(bottomHalf);
}

From source file:sample.fa.ScriptRunnerApplication.java

void createGUI() {
    Box buttonBox = Box.createHorizontalBox();

    JButton loadButton = new JButton("Load");
    loadButton.addActionListener(this::loadScript);
    buttonBox.add(loadButton);/* w  w  w  . j a  v  a 2 s. c o  m*/

    JButton saveButton = new JButton("Save");
    saveButton.addActionListener(this::saveScript);
    buttonBox.add(saveButton);

    JButton executeButton = new JButton("Execute");
    executeButton.addActionListener(this::executeScript);
    buttonBox.add(executeButton);

    languagesModel = new DefaultComboBoxModel();

    ScriptEngineManager sem = new ScriptEngineManager();
    for (ScriptEngineFactory sef : sem.getEngineFactories()) {
        languagesModel.addElement(sef.getScriptEngine());
    }

    JComboBox<ScriptEngine> languagesCombo = new JComboBox<>(languagesModel);
    JLabel languageLabel = new JLabel();
    languagesCombo.setRenderer((JList<? extends ScriptEngine> list, ScriptEngine se, int index,
            boolean isSelected, boolean cellHasFocus) -> {
        ScriptEngineFactory sef = se.getFactory();
        languageLabel.setText(sef.getEngineName() + " - " + sef.getLanguageName() + " (*."
                + String.join(", *.", sef.getExtensions()) + ")");
        return languageLabel;
    });
    buttonBox.add(Box.createHorizontalGlue());
    buttonBox.add(languagesCombo);

    scriptContents = new JTextArea();
    scriptContents.setRows(8);
    scriptContents.setColumns(40);

    scriptResults = new JTextArea();
    scriptResults.setEditable(false);
    scriptResults.setRows(8);
    scriptResults.setColumns(40);

    JSplitPane jsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scriptContents, scriptResults);

    JFrame frame = new JFrame("Script Runner");
    frame.add(buttonBox, BorderLayout.NORTH);
    frame.add(jsp, BorderLayout.CENTER);

    frame.pack();
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    frame.setVisible(true);
}

From source file:CustomComboBoxDemo.java

public CustomComboBoxDemo() {
    super(new BorderLayout());

    //Load the pet images and create an array of indexes.
    images = new ImageIcon[petStrings.length];
    Integer[] intArray = new Integer[petStrings.length];
    for (int i = 0; i < petStrings.length; i++) {
        intArray[i] = new Integer(i);
        images[i] = createImageIcon("images/" + petStrings[i] + ".gif");
        if (images[i] != null) {
            images[i].setDescription(petStrings[i]);
        }//from  w  w  w  .  ja v  a  2 s.  co m
    }

    //Create the combo box.
    JComboBox petList = new JComboBox(intArray);
    ComboBoxRenderer renderer = new ComboBoxRenderer();
    renderer.setPreferredSize(new Dimension(200, 130));
    petList.setRenderer(renderer);
    petList.setMaximumRowCount(3);

    //Lay out the demo.
    add(petList, BorderLayout.PAGE_START);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:medsavant.enrichment.app.OntologyAggregatePanel.java

public OntologyAggregatePanel(String page) {
    super(page);/* w  ww  .  ja  va2  s.  c  o  m*/
    setLayout(new GridBagLayout());

    chooser = new JComboBox(OntologyListItem.DEFAULT_ITEMS);
    chooser.setMaximumSize(new Dimension(400, chooser.getMaximumSize().height));
    progress = new JProgressBar();
    progress.setPreferredSize(new Dimension(600, progress.getMaximumSize().height));
    progress.setStringPainted(true);

    JPanel banner = new JPanel();
    banner.setLayout(new GridBagLayout());
    banner.setBackground(new Color(245, 245, 245));
    banner.setBorder(BorderFactory.createTitledBorder("Ontology"));

    tree = new TreeTable();

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.anchor = GridBagConstraints.WEST;
    banner.add(chooser, gbc);
    gbc.anchor = GridBagConstraints.EAST;
    banner.add(progress, gbc);

    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    add(banner, gbc);

    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    add(new JScrollPane(tree), gbc);

    chooser.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (termFetcher != null) {
                termFetcher.cancel(true);
                termFetcher = null;
            }
            recalculate();
        }
    });

    tree.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
                createPopup().show(e.getComponent(), e.getX(), e.getY());
            }
        }
    });
}

From source file:com.floreantpos.config.ui.DatabaseConfigurationView.java

protected void initUI() {
    setLayout(new BorderLayout());

    JPanel contentPanel = new JPanel();
    contentPanel.setLayout(new MigLayout("fill", "[][grow,fill]", "[][][][][][][][grow,fill]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    tfServerAddress = new POSTextField();
    tfServerPort = new POSTextField();
    tfDatabaseName = new POSTextField();
    tfUserName = new POSTextField();
    tfPassword = new POSPasswordField();
    databaseCombo = new JComboBox(Database.values());

    String databaseProviderName = AppConfig.getDatabaseProviderName();
    if (StringUtils.isNotEmpty(databaseProviderName)) {
        databaseCombo.setSelectedItem(Database.getByProviderName(databaseProviderName));
    }//www .j  av  a  2  s.c om

    contentPanel.add(new JLabel(Messages.getString("DatabaseConfigurationDialog.8"))); //$NON-NLS-1$
    contentPanel.add(databaseCombo, "grow, wrap"); //$NON-NLS-1$
    lblServerAddress = new JLabel(Messages.getString("DatabaseConfigurationDialog.10") + ":"); //$NON-NLS-1$ //$NON-NLS-2$
    contentPanel.add(lblServerAddress);
    contentPanel.add(tfServerAddress, "grow, wrap"); //$NON-NLS-1$
    lblServerPort = new JLabel(Messages.getString("DatabaseConfigurationDialog.13") + ":"); //$NON-NLS-1$ //$NON-NLS-2$
    contentPanel.add(lblServerPort);
    contentPanel.add(tfServerPort, "grow, wrap"); //$NON-NLS-1$
    lblDbName = new JLabel(Messages.getString("DatabaseConfigurationDialog.16") + ":"); //$NON-NLS-1$ //$NON-NLS-2$
    contentPanel.add(lblDbName);
    contentPanel.add(tfDatabaseName, "grow, wrap"); //$NON-NLS-1$
    lblUserName = new JLabel(Messages.getString("DatabaseConfigurationDialog.19") + ":"); //$NON-NLS-1$ //$NON-NLS-2$
    contentPanel.add(lblUserName);
    contentPanel.add(tfUserName, "grow, wrap"); //$NON-NLS-1$
    lblDbPassword = new JLabel(Messages.getString("DatabaseConfigurationDialog.22") + ":"); //$NON-NLS-1$ //$NON-NLS-2$
    contentPanel.add(lblDbPassword);
    contentPanel.add(tfPassword, "grow, wrap"); //$NON-NLS-1$
    contentPanel.add(new JSeparator(), "span, grow, gaptop 10"); //$NON-NLS-1$

    btnTestConnection = new JButton(Messages.getString("DatabaseConfigurationDialog.26")); //$NON-NLS-1$
    btnTestConnection.setActionCommand(TEST);
    btnSave = new JButton(Messages.getString("DatabaseConfigurationDialog.27")); //$NON-NLS-1$
    btnSave.setActionCommand(SAVE);

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    btnCreateDb = new JButton(Messages.getString("DatabaseConfigurationDialog.29")); //$NON-NLS-1$
    btnCreateDb.setActionCommand(CONFIGURE_DB);
    buttonPanel.add(btnCreateDb);
    buttonPanel.add(btnTestConnection);
    buttonPanel.add(btnSave);

    contentPanel.add(buttonPanel, "span, grow"); //$NON-NLS-1$

    JScrollPane scrollPane = new JScrollPane(contentPanel);
    scrollPane.setBorder(null);
    add(scrollPane);
}

From source file:FocusEventDemo.java

public void addComponentsToPane(final Container pane) {
    GridBagLayout gridbag = new GridBagLayout();
    pane.setLayout(gridbag);/*from w  ww. j ava2  s  .c om*/

    GridBagConstraints c = new GridBagConstraints();

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0; // Make column as wide as possible.
    JTextField textField = new JTextField("A TextField");
    textField.setMargin(new Insets(0, 2, 0, 2));
    textField.addFocusListener(this);
    gridbag.setConstraints(textField, c);
    add(textField);

    c.weightx = 0.1; // Widen every other column a bit, when possible.
    c.fill = GridBagConstraints.NONE;
    JLabel label = new JLabel("A Label");
    label.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    label.addFocusListener(this);
    gridbag.setConstraints(label, c);
    add(label);

    String comboPrefix = "ComboBox Item #";
    final int numItems = 15;
    Vector<String> vector = new Vector<String>(numItems);
    for (int i = 0; i < numItems; i++) {
        vector.addElement(comboPrefix + i);
    }
    JComboBox comboBox = new JComboBox(vector);
    comboBox.addFocusListener(this);
    gridbag.setConstraints(comboBox, c);
    add(comboBox);

    c.gridwidth = GridBagConstraints.REMAINDER;
    JButton button = new JButton("A Button");
    button.addFocusListener(this);
    gridbag.setConstraints(button, c);
    add(button);

    c.weightx = 0.0;
    c.weighty = 0.1;
    c.fill = GridBagConstraints.BOTH;
    String listPrefix = "List Item #";
    Vector<String> listVector = new Vector<String>(numItems);
    for (int i = 0; i < numItems; i++) {
        listVector.addElement(listPrefix + i);
    }
    JList list = new JList(listVector);
    list.setSelectedIndex(1); // It's easier to see the focus change
    // if an item is selected.
    list.addFocusListener(this);
    JScrollPane listScrollPane = new JScrollPane(list);

    gridbag.setConstraints(listScrollPane, c);
    add(listScrollPane);

    c.weighty = 1.0; // Make this row as tall as possible.
    c.gridheight = GridBagConstraints.REMAINDER;
    // Set up the area that reports focus-gained and focus-lost events.
    display = new JTextArea();
    display.setEditable(false);
    // The setRequestFocusEnabled method prevents a
    // component from being clickable, but it can still
    // get the focus through the keyboard - this ensures
    // user accessibility.
    display.setRequestFocusEnabled(false);
    display.addFocusListener(this);
    JScrollPane displayScrollPane = new JScrollPane(display);

    gridbag.setConstraints(displayScrollPane, c);
    add(displayScrollPane);
    setPreferredSize(new Dimension(450, 450));
    ((JPanel) pane).setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:projects.hip.exec.HrDiagram.java

/**
 * Main constructor./*from w ww  . j a v  a2  s .c  o  m*/
 */
public HrDiagram() {

    hipStars = HipUtils.loadHipCatalogue();

    method = METHOD.NAIVE;
    fMax = 1.0;

    final JComboBox<METHOD> methodComboBox = new JComboBox<METHOD>(METHOD.values());
    methodComboBox.setSelectedItem(method);
    methodComboBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            method = (METHOD) methodComboBox.getSelectedItem();
            updateChart();
        }
    });

    final JSlider fSlider = GuiUtil.buildSlider(0.0, 2.0, 5, "%3.3f");
    fSlider.setValue((int) Math.rint(100.0 * fMax / 2.0));
    final JLabel fLabel = new JLabel(getFLabel());
    // Create a change listener fot these
    ChangeListener cl = new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();

            if (source == fSlider) {
                // Compute fractional parallax error from slider position
                double newF = (2.0 * source.getValue() / 100.0);
                fMax = newF;
                fLabel.setText(getFLabel());
            }
            updateChart();
        }
    };
    fSlider.addChangeListener(cl);
    // Add a bit of padding to space things out
    fSlider.setBorder(new EmptyBorder(5, 5, 5, 5));

    // Present controls below the HR diagram
    JPanel controls = new JPanel(new GridLayout(2, 2));
    controls.add(new JLabel("Distance estimation method:"));
    controls.add(methodComboBox);
    controls.add(fLabel);
    controls.add(fSlider);

    // Initialise the ChartPanel
    updateChart();

    // Build the panel contents
    setLayout(new BorderLayout());
    add(hrDiagPanel, BorderLayout.WEST);
    add(dDistPanel, BorderLayout.EAST);
    add(controls, BorderLayout.SOUTH);
}

From source file:DecimalFormatDemo.java

public DecimalFormatDemo() {

    availableLocales = new LocaleGroup();
    inputFormatter = NumberFormat.getNumberInstance();

    String[] patternExamples = { "##.##", "###,###.##", "##,##,##.##", "#", "000,000.0000", "##.0000",
            "'hello'###.##" };

    currentPattern = patternExamples[0];

    // Set up the UI for entering a number.
    JLabel numberLabel = new JLabel("Enter the number to format:");
    numberLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

    JTextField numberField = new JTextField();
    numberField.setEditable(true);//from   w  ww .  j a  v a  2s.c  o  m
    numberField.setAlignmentX(Component.LEFT_ALIGNMENT);
    NumberListener numberListener = new NumberListener();
    numberField.addActionListener(numberListener);

    // Set up the UI for selecting a pattern.
    JLabel patternLabel1 = new JLabel("Enter the pattern string or");
    JLabel patternLabel2 = new JLabel("select one from the list:");
    patternLabel1.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternLabel2.setAlignmentX(Component.LEFT_ALIGNMENT);

    JComboBox patternList = new JComboBox(patternExamples);
    patternList.setSelectedIndex(0);
    patternList.setEditable(true);
    patternList.setAlignmentX(Component.LEFT_ALIGNMENT);
    PatternListener patternListener = new PatternListener();
    patternList.addActionListener(patternListener);

    // Set up the UI for selecting a locale.
    JLabel localeLabel = new JLabel("Select a Locale from the list:");
    localeLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

    JComboBox localeList = new JComboBox(availableLocales.getStrings());
    localeList.setSelectedIndex(0);
    localeList.setAlignmentX(Component.LEFT_ALIGNMENT);
    LocaleListener localeListener = new LocaleListener();
    localeList.addActionListener(localeListener);

    // Create the UI for displaying result.
    JLabel resultLabel = new JLabel("Result", JLabel.LEFT);
    resultLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    result = new JLabel(" ");
    result.setForeground(Color.black);
    result.setAlignmentX(Component.LEFT_ALIGNMENT);
    result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Lay out everything
    JPanel numberPanel = new JPanel();
    numberPanel.setLayout(new GridLayout(0, 1));
    numberPanel.add(numberLabel);
    numberPanel.add(numberField);

    JPanel patternPanel = new JPanel();
    patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.Y_AXIS));
    patternPanel.add(patternLabel1);
    patternPanel.add(patternLabel2);
    patternPanel.add(patternList);

    JPanel localePanel = new JPanel();
    localePanel.setLayout(new BoxLayout(localePanel, BoxLayout.Y_AXIS));
    localePanel.add(localeLabel);
    localePanel.add(localeList);

    JPanel resultPanel = new JPanel();
    resultPanel.setLayout(new GridLayout(0, 1));
    resultPanel.add(resultLabel);
    resultPanel.add(result);

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    patternPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    numberPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    localePanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    resultPanel.setAlignmentX(Component.CENTER_ALIGNMENT);

    add(numberPanel);
    add(Box.createVerticalStrut(10));
    add(patternPanel);
    add(Box.createVerticalStrut(10));
    add(localePanel);
    add(Box.createVerticalStrut(10));
    add(resultPanel);

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    reformat();
    numberField.setText(result.getText());

}

From source file:org.tsho.dmc2.ui.bifurcation.BifurcationControlForm2.java

public BifurcationControlForm2(final Model model, AbstractPlotComponent frame) {
    super(frame);
    setOpaque(true);/*from   www .  ja va2  s.co m*/

    this.model = model;

    type = TYPE_DOUBLE;

    parFields = FormHelper.createFields(model.getParNames(), "parameter");
    varFields = FormHelper.createFields(model.getVarNames(), "initial value");

    box1 = new JComboBox(model.getParNames());
    box2 = new JComboBox(model.getParNames());
    MyListener myListener = new MyListener();
    box1.addItemListener(myListener);
    box2.addItemListener(myListener);

    transientsField = new GetInt("transients", FormHelper.FIELD_LENGTH, new Range(0, Integer.MAX_VALUE));

    iterationsField = new GetInt("iterations", FormHelper.FIELD_LENGTH, new Range(1, Integer.MAX_VALUE));

    periodField = new GetInt("maximal period", FormHelper.FIELD_LENGTH,
            new Range(0, DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length));

    epsilonField = new GetFloat("epsilon", FormHelper.FIELD_LENGTH, new Range(0, Double.MAX_VALUE));

    infinityField = new GetFloat("infinity", FormHelper.FIELD_LENGTH, new Range(0, Double.MAX_VALUE));

    lFirstParRange = new GetFloat("first parameter lower value", FormHelper.FIELD_LENGTH);
    uFirstParRange = new GetFloat("first parameter upper value", FormHelper.FIELD_LENGTH);
    lSecondParRange = new GetFloat("second parameter upper value", FormHelper.FIELD_LENGTH);
    uSecondParRange = new GetFloat("second parameter upper value", FormHelper.FIELD_LENGTH);

    lowerVRangeField = new GetFloat("lower vertical range", FormHelper.FIELD_LENGTH);
    upperVRangeField = new GetFloat("upper vertical range", FormHelper.FIELD_LENGTH);

    verticalBox = new JComboBox(model.getVarNames());

    timeField = new GetFloat("time", FormHelper.FIELD_LENGTH);
    stepField = new GetFloat("step", FormHelper.FIELD_LENGTH);
    hyperplaneCoeffField = new GetVector("hyperplane coefficients", model.getNVar() + 1);

    FormLayout layout = new FormLayout("f:p:n", "");

    setLayout(layout);
    layout.appendRow(new RowSpec("f:p:n"));
    add(createPanel(), new CellConstraints(1, 1));

    if (model.getNPar() >= 2) {
        box1.setSelectedIndex(0);
        box2.setSelectedIndex(1);
        item1 = (String) box1.getSelectedItem();
        item2 = (String) box2.getSelectedItem();
    }
}