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() 

Source Link

Document

Creates a JComboBox with a default data model.

Usage

From source file:com.chenjw.imagegrab.ui.MainFrame.java

public MainFrame() {
    {//from   w  w  w.j a v a 2 s.  c  om
        this.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }

        });
    }

    GroupLayout configPanelLayout = new GroupLayout((JComponent) configPanel);
    configPanel.setLayout(configPanelLayout);
    configPanel.setPreferredSize(new java.awt.Dimension(1035, 726));
    {
        downloadButton = new JButton();
        downloadButton.setText("");
        downloadButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                executeService.execute(new Runnable() {
                    @Override
                    public void run() {
                        imagegrabService.grab();
                    }
                });

            }

        });
        downloadButton.registerKeyboardAction(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                executeService.execute(new Runnable() {
                    @Override
                    public void run() {
                        imagegrabService.grab();
                    }
                });
            }
        }, KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.CTRL_DOWN_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
    }
    {
        jLabel1 = new JLabel();
        jLabel1.setText("??");
    }
    {
        resultScrollPane = new JScrollPane(resultPane);
        {
            resultPane = new JTextArea();
            resultScrollPane.setViewportView(resultPane);
        }
    }
    {
        sourceComboBox = new JComboBox();
    }
    {

        maxNumComboBox = new HistoryComboBox("maxNum");
    }
    {
        jLabel6 = new JLabel();
        jLabel6.setText("??");
    }
    {
        jLabel3 = new JLabel();
        jLabel3.setText("??");
    }

    {
        searchWordComboBox = new HistoryComboBox("searchWord");
    }
    configPanelLayout.setHorizontalGroup(configPanelLayout.createSequentialGroup().addContainerGap()
            .addGroup(configPanelLayout.createParallelGroup()
                    .addGroup(configPanelLayout.createSequentialGroup()
                            .addComponent(resultScrollPane, GroupLayout.PREFERRED_SIZE, 979,
                                    GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(GroupLayout.Alignment.LEADING, configPanelLayout.createSequentialGroup()
                            .addPreferredGap(resultScrollPane, jLabel1, LayoutStyle.ComponentPlacement.INDENT)
                            .addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, 75, GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(searchWordComboBox, 0, 213, Short.MAX_VALUE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jLabel3, GroupLayout.PREFERRED_SIZE, 39, GroupLayout.PREFERRED_SIZE)
                            .addComponent(sourceComboBox, GroupLayout.PREFERRED_SIZE, 112,
                                    GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jLabel6, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(maxNumComboBox, GroupLayout.PREFERRED_SIZE, 72,
                                    GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(downloadButton, GroupLayout.PREFERRED_SIZE, 162,
                                    GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 164, GroupLayout.PREFERRED_SIZE)))
            .addContainerGap());
    configPanelLayout.setVerticalGroup(configPanelLayout.createSequentialGroup().addContainerGap()
            .addGroup(configPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 27,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 27,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(searchWordComboBox, GroupLayout.Alignment.BASELINE,
                            GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 27,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(sourceComboBox, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                            27, GroupLayout.PREFERRED_SIZE)
                    .addComponent(downloadButton, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                            27, GroupLayout.PREFERRED_SIZE)
                    .addComponent(maxNumComboBox, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                            27, GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 698, GroupLayout.PREFERRED_SIZE)
            .addComponent(resultScrollPane, GroupLayout.PREFERRED_SIZE, 686, GroupLayout.PREFERRED_SIZE));
    //
    pack();
    this.setSize(1010, 768);
    setVisible(true);
    this.setTitle("?");
    getContentPane().add(configPanel, BorderLayout.CENTER);
    initSpring();
}

From source file:de.fhg.iais.asc.ui.parts.HarvesterPanel.java

private void init(final MyCortexModel myCortexModel) {
    // OAI-PMH URL
    this.oaipmhTextField = new JTextField(20);
    this.retrieveInformationButton = LocalizedUI.createButton("Contact_Repository", new ActionListener() {
        @Override//from  w ww.ja  v  a2 s . c o m
        public void actionPerformed(ActionEvent e) {
            MetadataFormatsAndSetNamesRetriever retriever = new MetadataFormatsAndSetNamesRetriever(
                    HarvesterPanel.this.oaipmhTextField.getText(), myCortexModel.getConfig().getASCState(),
                    myCortexModel.getConfig().get(AscConfiguration.OAIPMH_PROXYHOST, ""), //$NON-NLS-1$
                    Integer.valueOf(myCortexModel.getConfig().get(AscConfiguration.OAIPMH_PROXYPORT, 0)));

            String[] metadataformats = retriever.listMetadataFormats();
            HarvesterPanel.this.oaipmhMetadataComboBox.removeAllItems();
            for (String metadataformat : metadataformats) {
                HarvesterPanel.this.oaipmhMetadataComboBox.addItem(metadataformat);
            }

            HarvesterPanel.this.availableSets = retriever.listSets();

            if (metadataformats.length == 0 && HarvesterPanel.this.availableSets == null) {

                // get the frame the panel is embedded in
                Component currentComponent = HarvesterPanel.this;
                while (currentComponent.getParent() != null && !(currentComponent instanceof JFrame)) {
                    currentComponent = currentComponent.getParent();
                }
                final JFrame parentFrame = currentComponent instanceof JFrame ? (JFrame) currentComponent
                        : null;

                LocalizedOptionPane.showMessageDialog(parentFrame, "UnableToContactRepository",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }

        }
    });
    this.add("OAI-PMH_URL", this.oaipmhTextField, this.retrieveInformationButton);

    this.oaipmhMetadataComboBox = this.add("Metadata_format", new JComboBox());
    this.oaipmhMetadataComboBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Object item = HarvesterPanel.this.oaipmhMetadataComboBox.getSelectedItem();
            myCortexModel.setSelectedMetadataFolder(ObjectUtils.toString(item, null));
        }
    });
    this.oaipmhMetadataFormatLabel = this.getLastLabel();

    this.setsTextField = this.add("Sets", createSetsTextField());

    this.harvestingStrategyComboBox = this.add("Harvesting_Strategy", new JComboBox(HARVEST_STRATEGIES));
    this.harvestingStrategyComboBox.setSelectedIndex(0);

    this.fromDateTextField = this.add("From_date", new DatePickerJTextField());

    this.untilDateTextField = this.add("Until_date", new DatePickerJTextField());

    this.inboxfolder = myCortexModel.getConfig().get(INBOX,
            MyCortex.DEFAULT_REPOSITORY_LOCATION + "/asc/inbox"); //$NON-NLS-1$
    this.outboxfolder = myCortexModel.getConfig().get(OUTBOX,
            MyCortex.DEFAULT_REPOSITORY_LOCATION + "/asc/outbox"); //$NON-NLS-1$
}

From source file:Trabalho.HistogramaHSB.java

private JPanel criaPainel() {
    JPanel panel = new JPanel();
    JComboBox Jbox = new JComboBox();
    JButton histEqual = new JButton("Equalizar Histograma");
    panel.add(new JCheckBox(new HistogramaHSB.exibeAcao(0)));
    panel.add(new JCheckBox(new HistogramaHSB.exibeAcao(1)));
    panel.add(new JCheckBox(new HistogramaHSB.exibeAcao(2)));
    panel.add(histEqual);//w w w  .  j  a va  2s . c o m
    panel.add(Jbox);
    return panel;
}

From source file:edu.gmu.cs.sim.util.media.chart.ScatterPlotSeriesAttributes.java

public void buildAttributes() {
    // The following three variables aren't defined until AFTER construction if
    // you just define them above.  So we define them below here instead.
    opacity = 1.0;/*from w w w.  ja  v  a  2  s .  c  o m*/

    // NOTE:
    // Paint paint = renderer.getSeriesPaint(getSeriesIndex());        
    // In JFreeChart 1.0.6 getSeriesPaint returns null!!!
    // You need lookupSeriesPaint(), but that's not backward compatible.
    // The only thing consistent in all versions is getItemPaint 
    // (which looks like a gross miss-use, but gets the job done)

    color = (Color) ((((XYPlot) getPlot()).getRenderer()).getItemPaint(getSeriesIndex(), -1));

    colorWell = new ColorWell(color) {
        public Color changeColor(Color c) {
            color = c;
            rebuildGraphicsDefinitions();
            return c;
        }
    };

    addLabelled("Color", colorWell);

    opacityField = new NumberTextField("Opacity ", opacity, 1.0, 0.125) {
        public double newValue(double newValue) {
            if (newValue < 0.0 || newValue > 1.0) {
                newValue = currentValue;
            }
            opacity = (float) newValue;
            rebuildGraphicsDefinitions();
            return newValue;
        }
    };
    addLabelled("", opacityField);

    shapeList = new JComboBox();
    shapeList.setEditable(false);
    shapeList.setModel(new DefaultComboBoxModel(new java.util.Vector(Arrays.asList(shapeNames))));
    shapeList.setSelectedIndex(shapeNum);
    shapeList.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            shapeNum = shapeList.getSelectedIndex();
            shape = shapes[shapeNum];
            rebuildGraphicsDefinitions();
        }
    });
    addLabelled("Shape", shapeList);
}

From source file:org.jfree.demo.DrawStringDemo.java

/**
 * Creates the content for tab 2./*ww w.j  a v a 2 s .  com*/
 *
 * @return The content panel.
 */
private JPanel createTab2Content() {
    final JPanel content = new JPanel(new BorderLayout());
    final JPanel controls = new JPanel();
    controls.add(new JLabel("Text anchor: "));
    this.combo2 = new JComboBox();
    populateTextAnchorCombo(this.combo2);
    this.combo2.setActionCommand("combo2.changed");
    this.combo2.addActionListener(this);
    controls.add(this.combo2);
    controls.add(new JLabel("Rotation anchor: "));
    this.combo3 = new JComboBox();
    populateTextAnchorCombo(this.combo3);
    this.combo3.setActionCommand("combo3.changed");
    this.combo3.addActionListener(this);
    controls.add(this.combo3);
    this.spinner = new Spinner(0);
    this.spinner.addPropertyChangeListener(this);
    controls.add(this.spinner);
    content.add(controls, BorderLayout.NORTH);
    this.drawStringPanel2 = new DrawStringPanel("Rotated Text", true);
    content.add(this.drawStringPanel2);
    return content;
}

From source file:org.jfree.demo.DrawStringDemo.java

/**
 * Creates the content for tab 2.//w w  w. j  ava  2  s.  c o m
 *
 * @return The content panel.
 */
private JPanel createTab2Content() {
    JPanel content = new JPanel(new BorderLayout());
    JPanel controls = new JPanel();
    controls.add(new JLabel("Text anchor: "));
    this.combo2 = new JComboBox();
    populateTextAnchorCombo(this.combo2);
    this.combo2.setActionCommand("combo2.changed");
    this.combo2.addActionListener(this);
    controls.add(this.combo2);
    controls.add(new JLabel("Rotation anchor: "));
    this.combo3 = new JComboBox();
    populateTextAnchorCombo(this.combo3);
    this.combo3.setActionCommand("combo3.changed");
    this.combo3.addActionListener(this);
    controls.add(this.combo3);
    this.slider = new JSlider(SwingConstants.VERTICAL, 0, 360, 0);
    this.slider.setMajorTickSpacing(45);
    this.slider.setMinorTickSpacing(5);
    this.slider.setPaintLabels(true);
    this.slider.setPaintTicks(true);
    this.slider.setPaintTrack(true);
    this.slider.addChangeListener(this);
    content.add(controls, BorderLayout.NORTH);
    content.add(this.slider, BorderLayout.WEST);
    this.drawStringPanel2 = new DrawStringPanel("Rotated Text", true);
    content.add(this.drawStringPanel2);
    return content;
}

From source file:com.entertailion.java.fling.FlingFrame.java

public FlingFrame(String appId) {
    super();/*from   w w  w . j av a2 s. c  o  m*/
    this.appId = appId;
    rampClient = new RampClient(this);

    addWindowListener(this);

    simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

    Locale locale = Locale.getDefault();
    resourceBundle = ResourceBundle.getBundle("com/entertailion/java/fling/resources/resources", locale);
    setTitle(MessageFormat.format(resourceBundle.getString("fling.title"), Fling.VERSION));

    JPanel listPane = new JPanel();
    // show list of ChromeCast devices detected on the local network
    listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS));
    JPanel devicePane = new JPanel();
    devicePane.setLayout(new BoxLayout(devicePane, BoxLayout.LINE_AXIS));
    deviceList = new JComboBox();
    deviceList.addActionListener(this);
    devicePane.add(deviceList);
    URL url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/refresh.png");
    ImageIcon icon = new ImageIcon(url, resourceBundle.getString("button.refresh"));
    refreshButton = new JButton(icon);
    refreshButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            // refresh the list of devices
            if (deviceList.getItemCount() > 0) {
                deviceList.setSelectedIndex(0);
            }
            discoverDevices();
        }
    });
    refreshButton.setToolTipText(resourceBundle.getString("button.refresh"));
    devicePane.add(refreshButton);
    url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/settings.png");
    icon = new ImageIcon(url, resourceBundle.getString("settings.title"));
    settingsButton = new JButton(icon);
    settingsButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JTextField transcodingExtensions = new JTextField(50);
            transcodingExtensions.setText(transcodingExtensionValues);
            JTextField transcodingParameters = new JTextField(50);
            transcodingParameters.setText(transcodingParameterValues);

            JPanel myPanel = new JPanel(new BorderLayout());
            JPanel labelPanel = new JPanel(new GridLayout(3, 1));
            JPanel fieldPanel = new JPanel(new GridLayout(3, 1));
            myPanel.add(labelPanel, BorderLayout.WEST);
            myPanel.add(fieldPanel, BorderLayout.CENTER);
            labelPanel.add(new JLabel(resourceBundle.getString("transcoding.extensions"), JLabel.RIGHT));
            fieldPanel.add(transcodingExtensions);
            labelPanel.add(new JLabel(resourceBundle.getString("transcoding.parameters"), JLabel.RIGHT));
            fieldPanel.add(transcodingParameters);
            labelPanel.add(new JLabel(resourceBundle.getString("device.manual"), JLabel.RIGHT));
            JPanel devicePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
            final JComboBox manualDeviceList = new JComboBox();
            if (manualServers.size() == 0) {
                manualDeviceList.setVisible(false);
            } else {
                for (DialServer dialServer : manualServers) {
                    manualDeviceList.addItem(dialServer);
                }
            }
            devicePanel.add(manualDeviceList);
            JButton addButton = new JButton(resourceBundle.getString("device.manual.add"));
            addButton.setToolTipText(resourceBundle.getString("device.manual.add.tooltip"));
            addButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    JTextField name = new JTextField();
                    JTextField ipAddress = new JTextField();
                    Object[] message = { resourceBundle.getString("device.manual.name") + ":", name,
                            resourceBundle.getString("device.manual.ipaddress") + ":", ipAddress };

                    int option = JOptionPane.showConfirmDialog(null, message,
                            resourceBundle.getString("device.manual"), JOptionPane.OK_CANCEL_OPTION);
                    if (option == JOptionPane.OK_OPTION) {
                        try {
                            manualServers.add(
                                    new DialServer(name.getText(), InetAddress.getByName(ipAddress.getText())));

                            Object selected = deviceList.getSelectedItem();
                            int selectedIndex = deviceList.getSelectedIndex();
                            deviceList.removeAllItems();
                            deviceList.addItem(resourceBundle.getString("devices.select"));
                            for (DialServer dialServer : servers) {
                                deviceList.addItem(dialServer);
                            }
                            for (DialServer dialServer : manualServers) {
                                deviceList.addItem(dialServer);
                            }
                            deviceList.invalidate();
                            if (selectedIndex > 0) {
                                deviceList.setSelectedItem(selected);
                            } else {
                                if (deviceList.getItemCount() == 2) {
                                    // Automatically select single device
                                    deviceList.setSelectedIndex(1);
                                }
                            }

                            manualDeviceList.removeAllItems();
                            for (DialServer dialServer : manualServers) {
                                manualDeviceList.addItem(dialServer);
                            }
                            manualDeviceList.setVisible(true);
                            storeProperties();
                        } catch (UnknownHostException e1) {
                            Log.e(LOG_TAG, "manual IP address", e1);

                            JOptionPane.showMessageDialog(FlingFrame.this,
                                    resourceBundle.getString("device.manual.invalidip"));
                        }
                    }
                }
            });
            devicePanel.add(addButton);
            JButton removeButton = new JButton(resourceBundle.getString("device.manual.remove"));
            removeButton.setToolTipText(resourceBundle.getString("device.manual.remove.tooltip"));
            removeButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    Object selected = manualDeviceList.getSelectedItem();
                    manualDeviceList.removeItem(selected);
                    if (manualDeviceList.getItemCount() == 0) {
                        manualDeviceList.setVisible(false);
                    }
                    deviceList.removeItem(selected);
                    deviceList.invalidate();
                    manualServers.remove(selected);
                    storeProperties();
                }
            });
            devicePanel.add(removeButton);
            fieldPanel.add(devicePanel);
            int result = JOptionPane.showConfirmDialog(FlingFrame.this, myPanel,
                    resourceBundle.getString("settings.title"), JOptionPane.OK_CANCEL_OPTION);
            if (result == JOptionPane.OK_OPTION) {
                transcodingParameterValues = transcodingParameters.getText();
                transcodingExtensionValues = transcodingExtensions.getText();
                storeProperties();
            }
        }
    });
    settingsButton.setToolTipText(resourceBundle.getString("settings.title"));
    devicePane.add(settingsButton);
    listPane.add(devicePane);

    // TODO
    volume = new JSlider(JSlider.VERTICAL, 0, 100, 0);
    volume.setUI(new MySliderUI(volume));
    volume.setMajorTickSpacing(25);
    // volume.setMinorTickSpacing(5);
    volume.setPaintTicks(true);
    volume.setEnabled(true);
    volume.setValue(100);
    volume.setToolTipText(resourceBundle.getString("volume.title"));
    volume.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();
            if (!source.getValueIsAdjusting()) {
                int position = (int) source.getValue();
                rampClient.volume(position / 100.0f);
            }
        }

    });
    JPanel centerPanel = new JPanel(new BorderLayout());
    // centerPanel.add(volume, BorderLayout.WEST);

    centerPanel.add(DragHereIcon.makeUI(this), BorderLayout.CENTER);
    listPane.add(centerPanel);

    scrubber = new JSlider(JSlider.HORIZONTAL, 0, 100, 0);
    scrubber.addChangeListener(this);
    scrubber.setMajorTickSpacing(25);
    scrubber.setMinorTickSpacing(5);
    scrubber.setPaintTicks(true);
    scrubber.setEnabled(false);
    listPane.add(scrubber);

    // panel of playback buttons
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    label = new JLabel("00:00:00");
    buttonPane.add(label);
    url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/play.png");
    icon = new ImageIcon(url, resourceBundle.getString("button.play"));
    playButton = new JButton(icon);
    playButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            rampClient.play();
        }
    });
    buttonPane.add(playButton);
    url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/pause.png");
    icon = new ImageIcon(url, resourceBundle.getString("button.pause"));
    pauseButton = new JButton(icon);
    pauseButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            rampClient.pause();
        }
    });
    buttonPane.add(pauseButton);
    url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/stop.png");
    icon = new ImageIcon(url, resourceBundle.getString("button.stop"));
    stopButton = new JButton(icon);
    stopButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            rampClient.stop();
            setDuration(0);
            scrubber.setValue(0);
            scrubber.setEnabled(false);
        }
    });
    buttonPane.add(stopButton);
    listPane.add(buttonPane);
    getContentPane().add(listPane);

    createProgressDialog();
    startWebserver();
    discoverDevices();
}

From source file:com.rapidminer.gui.new_plotter.gui.dialog.AddParallelLineDialog.java

/**
 * Setup the GUI.//from  www . j ava  2s. com
 */
private void setupGUI() {
    JPanel mainPanel = new JPanel();
    this.setContentPane(mainPanel);

    // start layout
    mainPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 2, 5);
    horizontalLineRadiobutton = new JRadioButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.horizontal.label"));
    horizontalLineRadiobutton.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.horizontal.tip"));
    horizontalLineRadiobutton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setHorizontalLineSelected();
        }
    });
    horizontalLineRadiobutton.setSelected(true);
    this.add(horizontalLineRadiobutton, gbc);

    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.EAST;
    verticalLineRadiobutton = new JRadioButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.vertical.label"));
    verticalLineRadiobutton
            .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.vertical.tip"));
    verticalLineRadiobutton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setVerticalLineSelected();
        }
    });
    this.add(verticalLineRadiobutton, gbc);

    ButtonGroup group = new ButtonGroup();
    group.add(horizontalLineRadiobutton);
    group.add(verticalLineRadiobutton);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1;
    gbc.gridwidth = 2;
    gbc.anchor = GridBagConstraints.CENTER;
    rangeAxisSelectionCombobox = new JComboBox();
    rangeAxisSelectionCombobox.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.range_axis_combobox.tip"));
    rangeAxisSelectionCombobox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateYFieldValue();
        }
    });
    this.add(rangeAxisSelectionCombobox, gbc);

    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 2, 5);
    JLabel xLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.width.label"));
    this.add(xLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.insets = new Insets(2, 5, 2, 5);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    xField = new JTextField();
    xField.setText(String.valueOf(x));
    xField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyYInput(input);
        }
    });
    xField.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.width.tip"));
    xField.setEnabled(false);
    this.add(xField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.NONE;
    JLabel yLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.height.label"));
    this.add(yLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    yField = new JTextField();
    yField.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.height.tip"));
    yField.setText(String.valueOf(y));
    yField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyXInput(input);
        }
    });
    this.add(yField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets = new Insets(10, 5, 0, 5);
    modifyLineButton = new JButton();
    modifyLineButton.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.modify_line.tip"));
    modifyLineButton.setIcon(SwingTools.createIcon(
            "16/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.modify_line.icon")));
    modifyLineButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            modifyLine();
        }
    });
    this.add(modifyLineButton, gbc);

    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.gridwidth = 2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(15, 5, 5, 5);
    this.add(new JSeparator(), gbc);

    gbc.gridx = 0;
    gbc.gridy = 6;
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 5, 5);
    okButton = new JButton(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.label"));
    okButton.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.tip"));
    okButton.setIcon(SwingTools
            .createIcon("24/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.icon")));
    okButton.setMnemonic(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.mne").toCharArray()[0]);
    okButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean successful = addSpecifiedLine();
            // don't dispose dialog if not successful
            if (!successful) {
                return;
            }

            AddParallelLineDialog.this.dispose();
        }
    });
    okButton.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                okButton.doClick();
            }
        }
    });
    this.add(okButton, gbc);

    gbc.gridx = 1;
    gbc.gridy = 6;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    cancelButton = new JButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.label"));
    cancelButton
            .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.tip"));
    cancelButton.setIcon(SwingTools.createIcon(
            "24/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.icon")));
    cancelButton.setMnemonic(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.mne").toCharArray()[0]);
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // cancel requested, close dialog
            AddParallelLineDialog.this.dispose();
        }
    });
    this.add(cancelButton, gbc);

    // misc settings
    this.setMinimumSize(new Dimension(300, 250));
    // center dialog
    this.setLocationRelativeTo(null);
    this.setTitle(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.title.label"));
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.setModal(true);

    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowActivated(WindowEvent e) {
            okButton.requestFocusInWindow();
        }
    });
}

From source file:gui.FormFrame.java

public void init() throws PaysNotFoundException {

    finish = new JButton(usage);

    //Init text fields
    if (argpays != null) {
        IDJTF = new JTextField(String.valueOf(argpays.getID()));
        indicatifJTF = new JTextField(argpays.getIndicatif());
        libellefrJTF = new JTextField(argpays.getLibelleFr());
        libelleenJTF = new JTextField(argpays.getLibelleEn());
        nationaliteJTF = new JTextField(argpays.getNationalite());
        monnaie_codeJTF = new JTextField(argpays.getMonnaieCode());
        monnaie_pdJTF = new JTextField(String.valueOf(argpays.getMonnaiePerdiem()));
        drapeauJTF = new JTextField(argpays.getDrapeau());
        tauxJTF = new JTextField(String.valueOf(argpays.getTauxChange()));
        dangerJTF = new JTextField(String.valueOf(argpays.isDanger()));
        coords1JTF = new JTextField(argpays.getCoords1());
        coords2JTF = new JTextField(argpays.getCoords2());
        coords3JTF = new JTextField(argpays.getCoords3());
        coords4JTF = new JTextField(argpays.getCoords4());
        coords5JTF = new JTextField(argpays.getCoords5());

    } else {/*from  www .java  2s  . co  m*/
        IDJTF = new JTextField();
        indicatifJTF = new JTextField();
        libellefrJTF = new JTextField();
        libelleenJTF = new JTextField();
        nationaliteJTF = new JTextField();
        monnaie_codeJTF = new JTextField();
        monnaie_pdJTF = new JTextField();
        drapeauJTF = new JTextField();
        tauxJTF = new JTextField();
        dangerJTF = new JTextField();
        coords1JTF = new JTextField();
        coords2JTF = new JTextField();
        coords3JTF = new JTextField();
        coords4JTF = new JTextField();
        coords5JTF = new JTextField();
    }
    //init jlabels
    IDJL = new JLabel("ID");
    indicatifJL = new JLabel("Indicatif");
    libellefrJL = new JLabel("LibelleFR");
    libelleenJL = new JLabel("LibelleEN");
    nationaliteJL = new JLabel("Nationalit");
    monnaie_codeJL = new JLabel("Code Monnaie");
    monnaie_pdJL = new JLabel("Monnaie per diem");
    drapeauJL = new JLabel("Drapeau");
    tauxJL = new JLabel("Taux");
    dangerJL = new JLabel("danger (boolean)");
    coords1JL = new JLabel("c1");
    coords2JL = new JLabel("c2");
    coords3JL = new JLabel("c3");
    coords4JL = new JLabel("c4");
    coords5JL = new JLabel("c5");

    //finish.setEnabled(false);
    finish.addActionListener(this);
    mainPanel.setLayout(new GridLayout(1, 2));
    //formPanel construction pour l'ajout
    if (usage.equals("add") || argpays != null) {
        formPanel.setLayout(new GridLayout(16, 2));
        formPanel.add(IDJL);
        formPanel.add(IDJTF);
        formPanel.add(indicatifJL);
        formPanel.add(indicatifJTF);
        formPanel.add(libellefrJL);
        formPanel.add(libellefrJTF);
        formPanel.add(libelleenJL);
        formPanel.add(libelleenJTF);
        formPanel.add(nationaliteJL);
        formPanel.add(nationaliteJTF);
        formPanel.add(monnaie_codeJL);
        formPanel.add(monnaie_codeJTF);
        formPanel.add(monnaie_pdJL);
        formPanel.add(monnaie_pdJTF);
        formPanel.add(tauxJL);
        formPanel.add(tauxJTF);
        formPanel.add(dangerJL);
        formPanel.add(dangerJTF);
        formPanel.add(drapeauJL);
        formPanel.add(drapeauJTF);
        formPanel.add(coords1JL);
        formPanel.add(coords1JTF);
        formPanel.add(coords2JL);
        formPanel.add(coords2JTF);
        formPanel.add(coords3JL);
        formPanel.add(coords3JTF);
        formPanel.add(coords4JL);
        formPanel.add(coords4JTF);
        formPanel.add(coords5JL);
        formPanel.add(coords5JTF);

    } else {
        JCB = new JComboBox();
        //menu droulant de choix
        ListableBeanFactory bf;
        bf = new XmlBeanFactory(new ClassPathResource("applicationContext.xml"));
        IPaysMetier instance = (IPaysMetier) bf.getBean("paysMetier");
        List<Pays> result = instance.findAllPays();
        for (Pays pays : result) {
            JCB.addItem(pays.getLibelleFr());
            System.out.println("libelle : " + pays.getLibelleFr());
        }
        formPanel.setLayout(new FlowLayout());
        formPanel.add(JCB);
    }

    mainPanel.add(formPanel);
    mainPanel.add(finish);
    mainPanel.setSize(new Dimension(600, 320));
    this.revalidate();
    this.setVisible(true);
    this.pack();
}

From source file:DateTimeEditor.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            System.exit(0);//from   w  ww . jav  a  2 s.c  om
        }
    });

    JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(new EmptyBorder(5, 5, 5, 5));
    frame.setContentPane(panel);
    final DateTimeEditor field = new DateTimeEditor(DateTimeEditor.DATETIME, DateFormat.FULL);
    panel.add(field, "North");

    JPanel buttonBox = new JPanel(new GridLayout(2, 2));
    JButton showDateButton = new JButton("Show Date");
    buttonBox.add(showDateButton);

    final JComboBox timeDateChoice = new JComboBox();
    timeDateChoice.addItem("Time");
    timeDateChoice.addItem("Date");
    timeDateChoice.addItem("Date/Time");
    timeDateChoice.setSelectedIndex(2);
    timeDateChoice.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            field.setTimeOrDateType(timeDateChoice.getSelectedIndex());
        }
    });
    buttonBox.add(timeDateChoice);

    JButton toggleButton = new JButton("Toggle Enable");
    buttonBox.add(toggleButton);
    showDateButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            System.out.println(field.getDate());
        }
    });
    toggleButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            field.setEnabled(!field.isEnabled());
        }
    });
    panel.add(buttonBox, "South");

    final JComboBox lengthStyleChoice = new JComboBox();
    lengthStyleChoice.addItem("Full");
    lengthStyleChoice.addItem("Long");
    lengthStyleChoice.addItem("Medium");
    lengthStyleChoice.addItem("Short");
    lengthStyleChoice.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            field.setLengthStyle(lengthStyleChoice.getSelectedIndex());
        }
    });
    buttonBox.add(lengthStyleChoice);

    frame.pack();
    Dimension dim = frame.getToolkit().getScreenSize();
    frame.setLocation(dim.width / 2 - frame.getWidth() / 2, dim.height / 2 - frame.getHeight() / 2);
    frame.show();
}