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:dbseer.gui.user.DBSeerDataSet.java

public DBSeerDataSet() {
    live = new Boolean(false);
    Boolean[] trueFalse = { Boolean.TRUE, Boolean.FALSE };
    JComboBox trueFalseBox = new JComboBox(trueFalse);
    final DefaultCellEditor dce = new DefaultCellEditor(trueFalseBox);

    uniqueVariableName = "dataset_" + UUID.randomUUID().toString().replace('-', '_');
    uniqueModelVariableName = "mv_" + UUID.randomUUID().toString().replace('-', '_');
    name = "Unnamed dataset";
    tableModel = new DBSeerDataSetTableModel(null, new String[] { "Name", "Value" }, true);
    tableModel.addTableModelListener(this);
    table = new JTable(tableModel) {
        @Override// w  ww .j  a va 2s.c  o  m
        public TableCellEditor getCellEditor(int row, int col) {
            if ((row == DBSeerDataSet.TYPE_USE_ENTIRE_DATASET
                    || row > TYPE_NUM_TRANSACTION_TYPE + numTransactionTypes) && col == 1)
                return dce;
            return super.getCellEditor(row, col);
        }
    };
    DefaultTableCellRenderer customRenderder = new DefaultTableCellRenderer() {
        @Override
        public Component getTableCellRendererComponent(JTable jTable, Object o, boolean b, boolean b2, int row,
                int col) {
            Component cell = super.getTableCellRendererComponent(jTable, o, b, b2, row, col);
            if (row == DBSeerDataSet.TYPE_START_INDEX || row == DBSeerDataSet.TYPE_END_INDEX) {
                if (((Boolean) table.getValueAt(DBSeerDataSet.TYPE_USE_ENTIRE_DATASET, 1))
                        .booleanValue() == true) {
                    cell.setForeground(Color.LIGHT_GRAY);
                } else {
                    cell.setForeground(Color.BLACK);
                }
            } else if (row == DBSeerDataSet.TYPE_NUM_TRANSACTION_TYPE) {
                cell.setForeground(Color.LIGHT_GRAY);
            } else {
                cell.setForeground(Color.BLACK);
            }
            return cell;
        }
    };
    table.getColumnModel().getColumn(0).setCellRenderer(customRenderder);
    table.getColumnModel().getColumn(1).setCellRenderer(customRenderder);

    table.setFillsViewportHeight(true);
    table.getColumnModel().getColumn(0).setMaxWidth(400);
    table.getColumnModel().getColumn(0).setPreferredWidth(300);
    table.getColumnModel().getColumn(1).setPreferredWidth(600);
    table.setRowHeight(20);

    this.useEntireDataSet = true;
    for (String header : tableHeaders) {
        if (header.equalsIgnoreCase("Use Entire DataSet"))
            tableModel.addRow(new Object[] { header, Boolean.TRUE });
        else
            tableModel.addRow(new Object[] { header, "" });
    }

    for (int i = 0; i < numTransactionTypes; ++i) {
        tableModel.addRow(new Object[] { "Name of Transaction Type " + (i + 1), "Type " + (i + 1) });
        DBSeerTransactionType type = new DBSeerTransactionType("Type " + (i + 1), true);
        transactionTypes.add(type);
    }

    for (int i = 0; i < transactionTypes.size(); ++i) {
        DBSeerTransactionType txType = transactionTypes.get(i);
        if (txType.isEnabled()) {
            tableModel.addRow(new Object[] { "Use Transaction Type " + (i + 1), Boolean.TRUE });
        } else {
            tableModel.addRow(new Object[] { "Use Transaction Type " + (i + 1), Boolean.FALSE });
        }
    }

    this.updateTable();
    dataSetLoaded = false;
    isCurrent = false;

    tableModel.setUseEntireDataSet(this.useEntireDataSet.booleanValue());
}

From source file:com.rapidminer.gui.new_plotter.gui.GlobalConfigurationPanel.java

private void createComponents() {

    // create panel for global configuration

    {//from w w  w  .  j a v  a2s  .  c  o  m
        // add title label
        JLabel titleLabel = new ResourceLabel("plotter.configuration_dialog.chart_title");

        String title = getPlotConfiguration().getTitleText();
        if (title == null) {
            title = "";
        }

        titleTextField = new JTextField(title);
        titleLabel.setLabelFor(titleTextField);
        titleTextField.addKeyListener(new KeyListener() {

            @Override
            public void keyTyped(KeyEvent e) {
                return;
            }

            @Override
            public void keyReleased(KeyEvent e) {
                String newTitle = titleTextField.getText();
                String titleText = getCurrentPlotInstance().getMasterPlotConfiguration().getTitleText();
                if (titleText != null) {
                    if (!titleText.equals(newTitle) || titleText == null && newTitle.length() > 0) {
                        if (newTitle.length() > 0) {
                            getPlotConfiguration().setTitleText(newTitle);
                        } else {
                            getPlotConfiguration().setTitleText(null);
                        }
                    }
                } else {
                    if (newTitle.length() > 0) {
                        getPlotConfiguration().setTitleText(newTitle);
                    } else {
                        getPlotConfiguration().setTitleText(null);
                    }
                }

                if (newTitle.equals("Iris") && SwingTools.isControlOrMetaDown(e)
                        && e.getKeyCode() == KeyEvent.VK_D) {
                    startAnimation();
                }
            }

            @Override
            public void keyPressed(KeyEvent e) {
                return;
            }
        });
        titleTextField.setPreferredSize(new Dimension(115, 23));

        titleConfigButton = new JToggleButton(new PopupAction(true, "plotter.configuration_dialog.open_popup",
                chartTitleConfigurationContainer, PopupPosition.HORIZONTAL));

        addThreeComponentRow(this, titleLabel, titleTextField, titleConfigButton);
    }

    // add orientation check box
    {
        JLabel plotOrientationLabel = new ResourceLabel(
                "plotter.configuration_dialog.global_config_panel.plot_orientation");

        PlotOrientation[] orientations = { PlotOrientation.HORIZONTAL, PlotOrientation.VERTICAL };
        plotOrientationComboBox = new JComboBox(orientations);
        plotOrientationLabel.setLabelFor(plotOrientationComboBox);
        plotOrientationComboBox.setRenderer(new EnumComboBoxCellRenderer("plotter"));
        plotOrientationComboBox.setSelectedIndex(0);
        plotOrientationComboBox.addPopupMenuListener(new PopupMenuListener() {

            @Override
            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                return;

            }

            @Override
            public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                getPlotConfiguration()
                        .setOrientation((PlotOrientation) plotOrientationComboBox.getSelectedItem());
            }

            @Override
            public void popupMenuCanceled(PopupMenuEvent e) {
                return;
            }
        });

        addTwoComponentRow(this, plotOrientationLabel, plotOrientationComboBox);
    }

    // add legend popup button
    {
        JLabel legendStyleConfigureLabel = new ResourceLabel(
                "plotter.configuration_dialog.global_config_panel.legend_style");

        JToggleButton legendStyleConfigButton = new JToggleButton(
                new PopupAction(true, "plotter.configuration_dialog.open_popup", legendConfigContainer,
                        PopupAction.PopupPosition.HORIZONTAL));
        legendStyleConfigureLabel.setLabelFor(legendStyleConfigButton);

        addTwoComponentRow(this, legendStyleConfigureLabel, legendStyleConfigButton);

    }

    // add legend popup button
    {
        JLabel axisStyleConfigureLabel = new ResourceLabel(
                "plotter.configuration_dialog.global_config_panel.axis_style");

        JToggleButton axisStyleConfigureButton = new JToggleButton(
                new PopupAction(true, "plotter.configuration_dialog.open_popup", axisConfigurationContainer,
                        PopupAction.PopupPosition.HORIZONTAL));
        axisStyleConfigureLabel.setLabelFor(axisStyleConfigureButton);

        addTwoComponentRow(this, axisStyleConfigureLabel, axisStyleConfigureButton);
    }

    // add color scheme dialog button
    {
        JLabel colorConfigureLabel = new ResourceLabel(
                "plotter.configuration_dialog.global_config_panel.color_scheme");

        colorsSchemesComboBoxModel = new DefaultComboBoxModel();
        colorSchemesComboBox = new JComboBox(colorsSchemesComboBoxModel);
        colorConfigureLabel.setLabelFor(colorSchemesComboBox);
        colorSchemesComboBox.setRenderer(new ColorSchemeComboBoxRenderer());
        colorSchemesComboBox.addPopupMenuListener(new PopupMenuListener() {

            @Override
            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                return;

            }

            @Override
            public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                ColorScheme colorScheme = (ColorScheme) colorSchemesComboBox.getSelectedItem();
                if (colorScheme != null) {
                    getPlotConfiguration().setActiveColorScheme(colorScheme.getName());
                }
            }

            @Override
            public void popupMenuCanceled(PopupMenuEvent e) {
                return;
            }
        });

        JButton colorConfigButton = new JButton(
                new ResourceAction(true, "plotter.configuration_dialog.open_color_scheme_dialog") {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        createColorSchemeDialog();
                    }
                });

        addThreeComponentRow(this, colorConfigureLabel, colorSchemesComboBox, colorConfigButton);

    }

    // add plot background color
    {
        plotBackGroundColorLabel = new ResourceLabel(
                "plotter.configuration_dialog.global_config_panel.select_plot_background_color");

        plotBackgroundColorChooserButton = new JButton(
                new ResourceAction(true, "plotter.configuration_dialog.select_plot_color") {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        createPlotBackgroundColorDialog();

                    }
                });
        plotBackGroundColorLabel.setLabelFor(plotBackgroundColorChooserButton);

        addTwoComponentRow(this, plotBackGroundColorLabel, plotBackgroundColorChooserButton);

    }

    // add chart background color
    {
        frameBackGroundColorLabel = new ResourceLabel(
                "plotter.configuration_dialog.global_config_panel.select_frame_background_color");

        frameBackgroundColorChooserButton = new JButton(
                new ResourceAction(true, "plotter.configuration_dialog.select_frame_color") {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        createFrameBackgroundColorDialog();
                    }
                });
        frameBackGroundColorLabel.setLabelFor(frameBackgroundColorChooserButton);

        addTwoComponentRow(this, frameBackGroundColorLabel, frameBackgroundColorChooserButton);

        // GridBagConstraints itemConstraint = new GridBagConstraints();
        // itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
        // itemConstraint.weightx = 1.0;
        // this.add(frameBackgroundColorChooserButton, itemConstraint);

    }

    // add spacer panel
    {
        JPanel spacerPanel = new JPanel();
        GridBagConstraints itemConstraint = new GridBagConstraints();
        itemConstraint.fill = GridBagConstraints.BOTH;
        itemConstraint.weightx = 1;
        itemConstraint.weighty = 1;
        itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
        this.add(spacerPanel, itemConstraint);
    }

}

From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.IntHistogramVisualizer.java

/**
 * Creates the combo box (drop-down list) to choose between visualization of the histogram as bar chart or
 * as a scatter plot./*from  w  w  w .  j av a2 s. c  om*/
 * 
 * @param aContainer Container control, to which the combo box is to be added.
 * @param aSelectedIndex Which choice is to be initially selected. This parameter must have one of the
 *        values <code>{1; 2}</code>.
 * @return The newly created combo box control.
 */
private static JComboBox addChoice(Box aContainer, int aSelectedIndex) {
    final String[] choices = new String[] { Messages.DI_SHOWHIST, Messages.DI_SHOWSCAT };
    JComboBox choiceCombo = new JComboBox(choices);
    choiceCombo.setSelectedIndex(aSelectedIndex);
    choiceCombo.setEditable(false);
    JPanel choicePanel = new JPanel();
    choicePanel.add(choiceCombo);
    aContainer.add(choicePanel);
    return choiceCombo;
}

From source file:ch.admin.hermes.etl.load.HermesETLApplication.java

/**
 * CommandLine parse und fehlende Argumente verlangen
 * @param args Args// ww w  . j  a va2 s  .  co m
 * @throws ParseException
 */
private static void parseCommandLine(String[] args) throws Exception {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

    // HACK um UTF-8 CharSet fuer alle Dateien zu setzen (http://stackoverflow.com/questions/361975/setting-the-default-java-character-encoding)
    System.setProperty("file.encoding", "UTF-8");
    Field charset = Charset.class.getDeclaredField("defaultCharset");
    charset.setAccessible(true);
    charset.set(null, null);

    // commandline Options - FremdsystemSite, Username und Password
    Options options = new Options();
    options.addOption("s", true, "Zielsystem - URL");
    options.addOption("u", true, "Zielsystem - Username");
    options.addOption("p", true, "Zielsystem - Password");

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = parser.parse(options, args);
    site = cmd.getOptionValue("s");
    user = cmd.getOptionValue("u");
    passwd = cmd.getOptionValue("p");

    // restliche Argumente pruefen - sonst usage ausgeben
    String[] others = cmd.getArgs();
    if (others.length >= 1 && (others[0].endsWith(".js") || others[0].endsWith(".ftl")))
        script = others[0];
    if (others.length >= 2 && others[1].endsWith(".xml"))
        model = others[1];

    // Dialog mit allen Werten zusammenstellen
    JComboBox<String> scenarios = new JComboBox<String>(crawler.getScenarios());

    JTextField tsite = new JTextField(45);
    tsite.setText(site);
    JTextField tuser = new JTextField(16);
    tuser.setText(user);
    JPasswordField tpasswd = new JPasswordField(16);
    tpasswd.setText(passwd);
    final JTextField tscript = new JTextField(45);
    tscript.setText(script);
    final JTextField tmodel = new JTextField(45);
    tmodel.setText(model);

    JPanel myPanel = new JPanel(new GridLayout(6, 2));
    myPanel.add(new JLabel("Szenario (von http://www.hermes.admin.ch):"));
    myPanel.add(scenarios);

    myPanel.add(new JLabel("XML Model:"));
    myPanel.add(tmodel);
    JPanel pmodel = new JPanel();
    pmodel.add(tmodel);
    JButton bmodel = new JButton("...");
    pmodel.add(bmodel);
    bmodel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            model = getFile("Szenario XML Model", new String[] { "XML Model" }, new String[] { ".xml" });
            if (model != null)
                tmodel.setText(model);
        }
    });
    myPanel.add(pmodel);

    scenarios.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            try {
                Object o = e.getItem();
                tmodel.setText(crawler.getModelURL(o.toString()));
                scenario = o.toString();
            } catch (Exception e1) {
            }
        }
    });

    // Script
    myPanel.add(new JLabel("Umwandlungs-Script:"));
    JPanel pscript = new JPanel();
    pscript.add(tscript);
    JButton bscript = new JButton("...");
    pscript.add(bscript);
    myPanel.add(pscript);
    bscript.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            script = getFile("JavaScript/Freemarker Umwandlungs-Script",
                    new String[] { "JavaScript", "Freemarker" }, new String[] { ".js", ".ftl" });
            if (script != null)
                tscript.setText(script);
        }
    });

    // Zielsystem Angaben
    myPanel.add(new JLabel("Zielsystem URL:"));
    myPanel.add(tsite);
    myPanel.add(new JLabel("Zielsystem Benutzer:"));
    myPanel.add(tuser);
    myPanel.add(new JLabel("Zielsystem Password:"));
    myPanel.add(tpasswd);

    // Trick um Feld scenario und model zu setzen.
    if (scenarios.getItemCount() >= 8)
        scenarios.setSelectedIndex(8);

    // Dialog
    int result = JOptionPane.showConfirmDialog(null, myPanel, "HERMES 5 XML Model nach Fremdsystem/Format",
            JOptionPane.OK_CANCEL_OPTION);
    if (result == JOptionPane.OK_OPTION) {
        site = tsite.getText();
        user = tuser.getText();
        passwd = new String(tpasswd.getPassword());
        model = tmodel.getText();
        script = tscript.getText();
    } else
        System.exit(1);

    if (model == null || script == null || script.trim().length() == 0)
        usage();

    if (script.endsWith(".js"))
        if (site == null || user == null || passwd == null || user.trim().length() == 0
                || passwd.trim().length() == 0)
            usage();
}

From source file:cimat.tesis.sna.visualization.ShowLayouts.java

private static JPanel getGraphPanel() {
    g_array = (Graph<? extends Object, ? extends Object>[]) new Graph<?, ?>[graph_names.length];

    Factory<Graph<Integer, Number>> graphFactory = new Factory<Graph<Integer, Number>>() {
        public Graph<Integer, Number> create() {
            return new SparseMultigraph<Integer, Number>();
        }/* w w  w  .  j a v a2  s  . c  o m*/
    };

    Factory<Integer> vertexFactory = new Factory<Integer>() {
        int count;

        public Integer create() {
            return count++;
        }
    };
    Factory<Number> edgeFactory = new Factory<Number>() {
        int count;

        public Number create() {
            return count++;
        }
    };

    g_array[0] = TestGraphs.createTestGraph(false);
    g_array[1] = MixedRandomGraphGenerator.generateMixedRandomGraph(graphFactory, vertexFactory, edgeFactory,
            new HashMap<Number, Number>(), 20, true, new HashSet<Integer>());
    g_array[2] = TestGraphs.getDemoGraph();
    g_array[3] = TestGraphs.createDirectedAcyclicGraph(4, 4, 0.3);
    g_array[4] = TestGraphs.getOneComponentGraph();
    g_array[5] = TestGraphs.createChainPlusIsolates(18, 5);
    g_array[6] = TestGraphs.createChainPlusIsolates(0, 20);

    Graph<? extends Object, ? extends Object> g = g_array[4]; // initial graph

    final VisualizationViewer<Integer, Number> vv = new VisualizationViewer<Integer, Number>(new FRLayout(g));

    vv.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.red, Color.yellow));

    final DefaultModalGraphMouse<Integer, Number> graphMouse = new DefaultModalGraphMouse<Integer, Number>();
    vv.setGraphMouse(graphMouse);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });
    JButton reset = new JButton("reset");
    reset.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Layout<Integer, Number> layout = vv.getGraphLayout();
            layout.initialize();
            Relaxer relaxer = vv.getModel().getRelaxer();
            if (relaxer != null) {
                //            if(layout instanceof IterativeContext) {
                relaxer.stop();
                relaxer.prerelax();
                relaxer.relax();
            }
        }
    });

    JComboBox modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(((DefaultModalGraphMouse<Integer, Number>) vv.getGraphMouse()).getModeListener());

    JPanel jp = new JPanel();
    jp.setBackground(Color.WHITE);
    jp.setLayout(new BorderLayout());
    jp.add(vv, BorderLayout.CENTER);
    Class[] combos = getCombos();
    final JComboBox jcb = new JComboBox(combos);
    // use a renderer to shorten the layout name presentation
    jcb.setRenderer(new DefaultListCellRenderer() {
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            String valueString = value.toString();
            valueString = valueString.substring(valueString.lastIndexOf('.') + 1);
            return super.getListCellRendererComponent(list, valueString, index, isSelected, cellHasFocus);
        }
    });
    jcb.addActionListener(new LayoutChooser(jcb, vv));
    jcb.setSelectedItem(FRLayout.class);

    JPanel control_panel = new JPanel(new GridLayout(2, 1));
    JPanel topControls = new JPanel();
    JPanel bottomControls = new JPanel();
    control_panel.add(topControls);
    control_panel.add(bottomControls);
    jp.add(control_panel, BorderLayout.NORTH);

    final JComboBox graph_chooser = new JComboBox(graph_names);

    graph_chooser.addActionListener(new GraphChooser(jcb));

    topControls.add(jcb);
    topControls.add(graph_chooser);
    bottomControls.add(plus);
    bottomControls.add(minus);
    bottomControls.add(modeBox);
    bottomControls.add(reset);
    return jp;
}

From source file:MainProgram.MainProgram.java

private void initComponents() throws InterruptedException {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    welcomeMessage = new JLabel();
    welcomeMessage2 = new JLabel();
    pennIDLabel = new JLabel();
    pennIDTextField = new JTextField();
    pennPassLabel = new JLabel();
    pennPassField = new JPasswordField();
    emailLabel = new JLabel();
    emailTextField = new JTextField();
    emailDomainLabel = new JLabel();
    emailPassLabel = new JLabel();
    emailPassField = new JPasswordField();
    semesterLabel = new JLabel();
    semesterComboBox = new JComboBox(semestersString);
    credentials = new JLabel();
    dropLabel = new JLabel();
    dropCheckBox = new JCheckBox();
    button = new JButton();
    stopWatchLabel = new JLabel();
    checkMail = false;/* w  w  w .j  a  v a2  s .co  m*/
    testConnection = false;

    mailCheckTimeInitializer();
    StopWatchInitializer();
    try {
        setUIFont(new javax.swing.plaf.FontUIResource("Segoe UI", Font.ROMAN_BASELINE, 12));
    } catch (Exception e) {
        e.printStackTrace(MainProgram.errorLog);
    }

    String lcOSName = System.getProperty("os.name").toLowerCase();
    boolean IS_MAC = lcOSName.startsWith("mac os x");
    //======== this ========
    setLayout(new GridBagLayout());
    ((GridBagLayout) getLayout()).columnWidths = new int[] { 81, 5, 119, 5, 0, 0 };
    if (!IS_MAC) {
        ((GridBagLayout) getLayout()).rowHeights = new int[] { 17, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 0, 0,
                0 };
    }
    ((GridBagLayout) getLayout()).rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4 };
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.fill = GridBagConstraints.HORIZONTAL;

    //---- welcomeMessage ----
    welcomeMessage.setText("Course Registration");
    welcomeMessage.setHorizontalAlignment(SwingConstants.CENTER);
    add(welcomeMessage, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- welcomeMessage2 ----
    welcomeMessage2.setText("for Penn State (BETA)");
    welcomeMessage2.setHorizontalAlignment(SwingConstants.CENTER);
    add(welcomeMessage2, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- pennIDLabel ----
    pennIDLabel.setText("Penn State ID: ");
    pennIDLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    add(pennIDLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- pennIDTextField ----
    pennIDTextField.setText("xxx123");
    add(pennIDTextField, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- pennPassLabel ----
    pennPassLabel.setText("Penn State Password: ");
    pennPassLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    add(pennPassLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    add(pennPassField, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- emailLabel ----
    emailLabel.setText("Email: ");
    emailLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    add(emailLabel, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- emailTextField ----
    emailTextField.setText("myEmail");
    add(emailTextField, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- emailDomainLabel ----
    emailDomainLabel.setText("@mail.com");
    add(emailDomainLabel, new GridBagConstraints(2, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- emailPassLabel ----
    emailPassLabel.setText("Email Password: ");
    emailPassLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    add(emailPassLabel, new GridBagConstraints(0, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    add(emailPassField, new GridBagConstraints(1, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    //---- Semester label ----
    semesterLabel.setText("Semester/Drop Option: ");
    semesterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    add(semesterLabel, new GridBagConstraints(0, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    //---- Semester ComboBox ----
    add(semesterComboBox, new GridBagConstraints(1, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    //---- Drop CheckBox ----
    add(dropCheckBox, new GridBagConstraints(2, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    //---- button ----
    button.setText("Start");
    add(button, new GridBagConstraints(1, 16, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    //---- stopWatchLabel ----
    stopWatchLabel.setText("  " + stopWatchSplitting[0]);
    stopWatchLabel.setHorizontalAlignment(SwingConstants.LEFT);
    add(stopWatchLabel, new GridBagConstraints(2, 16, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    //---- label11 ----
    credentials.setText(" Created by Daniyar Yeralin");
    credentials.setForeground(Color.gray);
    credentials.setHorizontalAlignment(SwingConstants.RIGHT);
    credentials.setFont(new Font("Cambria", Font.ITALIC, 12));
    add(credentials, new GridBagConstraints(2, 17, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    /*button.registerKeyboardAction(button.getActionForKeyStroke(
     KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, false)),
     KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false),
     JComponent.WHEN_FOCUSED);
            
     button.registerKeyboardAction(button.getActionForKeyStroke(
     KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true)),
     KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true),
     JComponent.WHEN_FOCUSED);*/
    StartButtonHandler buttonListener = new StartButtonHandler();
    button.addActionListener(buttonListener);

}

From source file:com.marginallyclever.makelangelo.MainGUI.java

public void chooseLanguage() {
    final JDialog driver = new JDialog(mainframe, "Language", true);
    driver.setLayout(new GridBagLayout());

    final String[] choices = translator.getLanguageList();
    final JComboBox<String> language_options = new JComboBox<String>(choices);
    final JButton save = new JButton(">>>");

    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = 2;//from  ww  w.j  a v a  2 s.c o m
    c.gridx = 0;
    c.gridy = 0;
    driver.add(language_options, c);
    c.anchor = GridBagConstraints.EAST;
    c.gridwidth = 1;
    c.gridx = 2;
    c.gridy = 0;
    driver.add(save, c);

    ActionListener driveButtons = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Object subject = e.getSource();
            // TODO prevent "close" icon.  Must press save to continue!
            if (subject == save) {
                translator.currentLanguage = choices[language_options.getSelectedIndex()];
                translator.saveConfig();
                driver.dispose();
            }
        }
    };

    save.addActionListener(driveButtons);

    driver.pack();
    driver.setVisible(true);
}

From source file:fedroot.dacs.swingdemo.DacsSwingDemo.java

private void init(JFrame mainFrame) {

    JPanel mainPanel = new JPanel(new BorderLayout());
    JPanel gotoUrlPanel = new JPanel(new FlowLayout());
    JPanel actionPanel = new JPanel(new FlowLayout());
    JPanel modifiersPanel = new JPanel(new FlowLayout());

    btnGO = new JButton("GO");
    btnGO.addActionListener(new ActionListener() {

        @Override/*from   ww  w  . j a  v  a 2 s. c  o m*/
        public void actionPerformed(ActionEvent ae) {
            loadPage("text/html", testURLs[actionsComboBox.getSelectedIndex()]);
        }
    });

    btnLOGIN = new JButton("Login");
    btnLOGIN.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            loginDialog.showDialog();
        }
    });

    btnLOGOUT = new JButton("Logout");
    btnLOGOUT.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            sessionManager.signout();
        }
    });
    //initially user is not signed in - btnLOGOUT will be enabled upon successful login
    btnLOGOUT.setEnabled(false);

    actionsComboBox = new JComboBox(actions);
    actionsComboBox.setToolTipText("Select an Action");
    actionsComboBox.setEditable(true);
    actionsComboBox.setSelectedIndex(0);

    JLabel actionLabel = new JLabel("Action:");

    urlTextField = new TextField(70);
    urlTextField.setEditable(true);

    actionPanel.add(actionLabel);
    actionPanel.add(actionsComboBox);
    actionPanel.add(btnGO);
    actionPanel.add(btnLOGIN);
    actionPanel.add(btnLOGOUT);

    mainPanel.add(gotoUrlPanel, BorderLayout.NORTH);
    mainPanel.add(actionPanel, BorderLayout.SOUTH);

    JSplitPane splitInputPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, mainPanel, modifiersPanel);

    splitInputPane.setOneTouchExpandable(false);

    responseTextArea = new JTextArea();
    responseTextArea.setEditable(false);
    responseTextArea.setCaretPosition(0);

    htmlPane = new JEditorPane();
    // htmlPane.setContentType("image/png");
    htmlPane.setEditable(false);

    JSplitPane splitResponsePane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(responseTextArea),
            new JScrollPane(htmlPane));
    splitResponsePane.setOneTouchExpandable(false);
    splitResponsePane.setResizeWeight(0.35);

    Container container = mainFrame.getContentPane();
    container.setLayout(new BorderLayout());
    container.add(splitInputPane, BorderLayout.NORTH);
    container.add(splitResponsePane, BorderLayout.CENTER);

    mainFrame.pack();
}

From source file:edu.uci.ics.jung.samples.ShowLayouts.java

@SuppressWarnings({ "rawtypes", "unchecked" })
private static JPanel getGraphPanel() {
    g_array = (Graph<? extends Object, ? extends Object>[]) new Graph<?, ?>[graph_names.length];

    Factory<Graph<Integer, Number>> graphFactory = new Factory<Graph<Integer, Number>>() {
        public Graph<Integer, Number> create() {
            return new SparseMultigraph<Integer, Number>();
        }//from  ww w.j av a 2 s.co m
    };

    Factory<Integer> vertexFactory = new Factory<Integer>() {
        int count;

        public Integer create() {
            return count++;
        }
    };
    Factory<Number> edgeFactory = new Factory<Number>() {
        int count;

        public Number create() {
            return count++;
        }
    };

    g_array[0] = TestGraphs.createTestGraph(false);
    g_array[1] = MixedRandomGraphGenerator.generateMixedRandomGraph(graphFactory, vertexFactory, edgeFactory,
            new HashMap<Number, Number>(), 20, true, new HashSet<Integer>());
    g_array[2] = TestGraphs.getDemoGraph();
    g_array[3] = TestGraphs.createDirectedAcyclicGraph(4, 4, 0.3);
    g_array[4] = TestGraphs.getOneComponentGraph();
    g_array[5] = TestGraphs.createChainPlusIsolates(18, 5);
    g_array[6] = TestGraphs.createChainPlusIsolates(0, 20);

    Graph<? extends Object, ? extends Object> g = g_array[4]; // initial graph

    final VisualizationViewer<Integer, Number> vv = new VisualizationViewer<Integer, Number>(new FRLayout(g));

    vv.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.red, Color.yellow));

    final DefaultModalGraphMouse<Integer, Number> graphMouse = new DefaultModalGraphMouse<Integer, Number>();
    vv.setGraphMouse(graphMouse);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });
    JButton reset = new JButton("reset");
    reset.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Layout<Integer, Number> layout = vv.getGraphLayout();
            layout.initialize();
            Relaxer relaxer = vv.getModel().getRelaxer();
            if (relaxer != null) {
                //            if(layout instanceof IterativeContext) {
                relaxer.stop();
                relaxer.prerelax();
                relaxer.relax();
            }
        }
    });

    JComboBox modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(((DefaultModalGraphMouse<Integer, Number>) vv.getGraphMouse()).getModeListener());

    JPanel jp = new JPanel();
    jp.setBackground(Color.WHITE);
    jp.setLayout(new BorderLayout());
    jp.add(vv, BorderLayout.CENTER);
    Class[] combos = getCombos();
    final JComboBox jcb = new JComboBox(combos);
    // use a renderer to shorten the layout name presentation
    jcb.setRenderer(new DefaultListCellRenderer() {
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            String valueString = value.toString();
            valueString = valueString.substring(valueString.lastIndexOf('.') + 1);
            return super.getListCellRendererComponent(list, valueString, index, isSelected, cellHasFocus);
        }
    });
    jcb.addActionListener(new LayoutChooser(jcb, vv));
    jcb.setSelectedItem(FRLayout.class);

    JPanel control_panel = new JPanel(new GridLayout(2, 1));
    JPanel topControls = new JPanel();
    JPanel bottomControls = new JPanel();
    control_panel.add(topControls);
    control_panel.add(bottomControls);
    jp.add(control_panel, BorderLayout.NORTH);

    final JComboBox graph_chooser = new JComboBox(graph_names);

    graph_chooser.addActionListener(new GraphChooser(jcb));

    topControls.add(jcb);
    topControls.add(graph_chooser);
    bottomControls.add(plus);
    bottomControls.add(minus);
    bottomControls.add(modeBox);
    bottomControls.add(reset);
    return jp;
}

From source file:com.projity.dialog.ResourceSubstitutionDialog.java

protected void initControls() {
    entireProject = new JRadioButton(Messages.getString("UpdateProjectDialogBox.EntireProject")); //$NON-NLS-1$
    entireProject.setSelected(true);// w w w.  j  a  v a2  s. c  o m
    selectedTask = new JRadioButton(Messages.getString("UpdateProjectDialogBox.SelectedTasks")); //$NON-NLS-1$
    if (!hasTasksSelected) {
        selectedTask.setEnabled(false);
    }
    projectOrTask = new ButtonGroup();
    projectOrTask.add(entireProject);
    projectOrTask.add(selectedTask);

    rescheduleDateChooser = CalendarFactory.createDateField();

    ignoreInProgress = new JCheckBox("Ignore in-progress assignments"); //$NON-NLS-1$
    ignoreInProgress.setSelected(false);
    List resources = (List) project.getResourcePool().getResourceList().clone();
    resources.add(0, null); // allow blank
    fromResource = new JComboBox(resources.toArray());
    toResource = new JComboBox(resources.toArray());
    ok.setEnabled(false);
    toResource.addActionListener(this);
    fromResource.addActionListener(this);
}