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:ImageDrawingComponent.java

public void buildUI() {
    final ImageDrawingComponent id = new ImageDrawingComponent(imageSrc);
    add("Center", id);
    JComboBox choices = new JComboBox(id.getDescriptions());
    choices.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JComboBox cb = (JComboBox) e.getSource();
            id.setOpIndex(cb.getSelectedIndex());
            id.repaint();/*from   w  w w. j  av  a  2s.  c o m*/
        };
    });
    add("South", choices);
}

From source file:electroStaticUI.UserInput.java

@SuppressWarnings({ "rawtypes", "unchecked" })
private void getChargeData() {
    numberOfCharges = Integer.parseInt(getNumberOfCharges.getText());
    DefaultValues.allocatePointChargeArray(numberOfCharges);
    chargesToCalc = new PointCharge[numberOfCharges];
    mapper = new CustomMapper(DefaultValues.getCircOrRect());
    chargeDataFrame = new JFrame();
    chargeDataFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    JPanel chargeDataPanel = new JPanel();
    chargeDataFrame.setTitle("Data For Charge #: " + (1 + okButtonPushes));
    JLabel chargeLabel = new JLabel("Charge");
    JLabel chargeUnitLabel = new JLabel("C");
    charge = new JTextField(10);
    charge.setEditable(true);//  www.  jav  a  2 s . com
    chargeModComboBox = new JComboBox(chargeModList);
    chargeModComboBox.setSelectedIndex(5);
    chargeModComboBox.setVisible(true);
    JLabel xPositionLabel = new JLabel("X Value");
    xPosition = new JTextField(10);
    xPosition.setEditable(true);
    JLabel yPositionLabel = new JLabel("Y Value");
    yPosition = new JTextField(10);
    yPosition.setEditable(true);
    //JLabel zPositionLabel = new JLabel("Z Value");
    //JTextField zPosition = new JTextField(5);
    //zPosition.setEditable(true);
    JButton okButton = new JButton("OK");
    chargeDataPanel.add(chargeLabel);
    chargeDataPanel.add(charge);
    chargeDataPanel.add(chargeModComboBox);
    chargeDataPanel.add(chargeUnitLabel);
    chargeDataPanel.add(xPositionLabel);
    chargeDataPanel.add(xPosition);
    chargeDataPanel.add(yPositionLabel);
    chargeDataPanel.add(yPosition);
    chargeDataPanel.add(okButton);
    chargeDataPanel.setMinimumSize(new Dimension(600, 100));
    chargeDataPanel.setVisible(true);
    chargeDataFrame.add(chargeDataPanel);
    chargeDataFrame.setVisible(true);
    chargeDataFrame.setMinimumSize(new Dimension(600, 100));
    xPosition.setText("0");
    yPosition.setText("0");
    charge.setText("0");
    /*
     * okButton anonymous action listener takes the data entered into the JTextfields and creates point charges from it.
     */
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //do {
            //chargesToCalc[okButtonPushes] = new PointCharge(Double.parseDouble(charge.getText()), Double.parseDouble(xPosition.getText()), Double.parseDouble(yPosition.getText()));
            int chargeModIndex = chargeModComboBox.getSelectedIndex();
            DefaultValues.setChargeModIndex(chargeModIndex);
            chargeValue = Double.parseDouble(charge.getText());
            xValue = Double.parseDouble(xPosition.getText());
            yValue = Double.parseDouble(yPosition.getText());
            chargesToCalc[okButtonPushes] = new PointCharge(chargeValue, xValue, yValue);
            charge.setText("0");
            xPosition.setText("0");
            yPosition.setText("0");
            okButtonPushes++;
            chargeDataFrame.setTitle("Data For Charge #: " + (1 + okButtonPushes));
            if (okButtonPushes == numberOfCharges) {
                confirm = JOptionPane.showConfirmDialog(null,
                        "You have entered " + okButtonPushes
                                + " charges. Press OK to confirm. \nPress Cancel to re-enter the charges",
                        null, JOptionPane.OK_CANCEL_OPTION);
                if (confirm == JOptionPane.OK_OPTION) {
                    DefaultValues.setCurrentPointCharges(chargesToCalc);
                    ElectroStaticUIContainer.removeGraphFromdisplayPanel();
                    theCalculator = new CalculatorPanel();
                    calcVec = new VectorCalculator(mapper);
                    volts = new VoltageAtPoint(mapper.getFieldPoints());
                    manGraph = new ManualPolygons(mapper);
                    chart = manGraph.delaunayBuild();
                    drawVecs = new DrawElectricFieldLines(mapper);
                    ElectroStaticUIContainer.add3DGraphToDisplayPanel(chart);
                    ElectroStaticUIContainer.addVectorGraphToDisplayPanel(drawVecs.getChart());
                    setVectorChartToSave();
                    setChart3dToSave();
                    rotateIt = new ChartMouseController(chart);
                    okButtonPushes = 0;
                    chargeDataFrame.removeAll();
                    chargeDataFrame.dispose();
                } else if (confirm == JOptionPane.CANCEL_OPTION)
                    okButtonPushes = 0;
            }

        }
        //while(okButtonPushes < numberOfCharges);

        //}
    });
}

From source file:com._17od.upm.gui.OptionsDialog.java

public OptionsDialog(JFrame frame) {
    super(frame, Translator.translate("options"), true);

    Container container = getContentPane();

    // Create a pane with an empty border for spacing
    Border emptyBorder = BorderFactory.createEmptyBorder(2, 5, 5, 5);
    JPanel emptyBorderPanel = new JPanel();
    emptyBorderPanel.setLayout(new BoxLayout(emptyBorderPanel, BoxLayout.Y_AXIS));
    emptyBorderPanel.setBorder(emptyBorder);
    container.add(emptyBorderPanel);/*from   w  w w.  j  a  v  a  2  s. co m*/

    // ******************
    // *** The DB TO Load On Startup Section
    // ******************
    // Create a pane with an title etched border
    Border etchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    Border etchedTitleBorder = BorderFactory.createTitledBorder(etchedBorder,
            ' ' + Translator.translate("general") + ' ');
    JPanel mainPanel = new JPanel(new GridBagLayout());
    mainPanel.setBorder(etchedTitleBorder);
    emptyBorderPanel.add(mainPanel);

    GridBagConstraints c = new GridBagConstraints();

    // The "Database to Load on Startup" row
    JLabel urlLabel = new JLabel(Translator.translate("dbToLoadOnStartup"));
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 3, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.NONE;
    mainPanel.add(urlLabel, c);

    // The "Database to Load on Startup" input field row
    dbToLoadOnStartup = new JTextField(Preferences.get(Preferences.ApplicationOptions.DB_TO_LOAD_ON_STARTUP),
            25);
    dbToLoadOnStartup.setHorizontalAlignment(JTextField.LEFT);
    c.gridx = 0;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 5);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(dbToLoadOnStartup, c);

    JButton dbToLoadOnStartupButton = new JButton("...");
    dbToLoadOnStartupButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            getDBToLoadOnStartup();
        }
    });
    c.gridx = 1;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(0, 0, 5, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    mainPanel.add(dbToLoadOnStartupButton, c);

    // The "Language" label row
    JLabel localeLabel = new JLabel(Translator.translate("language"));
    c.gridx = 0;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 3, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.NONE;
    mainPanel.add(localeLabel, c);

    // The "Locale" field row
    localeComboBox = new JComboBox(getSupportedLocaleNames());
    for (int i = 0; i < localeComboBox.getItemCount(); i++) {
        // If the locale language is blank then set it to the English language
        // I'm not sure why this happens. Maybe it's because the default locale
        // is English???
        String currentLanguage = Translator.getCurrentLocale().getLanguage();
        if (currentLanguage.equals("")) {
            currentLanguage = "en";
        }

        if (currentLanguage.equals(Translator.SUPPORTED_LOCALES[i].getLanguage())) {
            localeComboBox.setSelectedIndex(i);
            break;
        }
    }
    c.gridx = 0;
    c.gridy = 3;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 8, 5);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(localeComboBox, c);

    // The "Hide account password" row
    Boolean hideAccountPassword = new Boolean(
            Preferences.get(Preferences.ApplicationOptions.ACCOUNT_HIDE_PASSWORD, "true"));
    hideAccountPasswordCheckbox = new JCheckBox(Translator.translate("hideAccountPassword"),
            hideAccountPassword.booleanValue());
    c.gridx = 0;
    c.gridy = 4;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 2, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    mainPanel.add(hideAccountPasswordCheckbox, c);

    // The "Database auto lock" row
    Boolean databaseAutoLock = new Boolean(
            Preferences.get(Preferences.ApplicationOptions.DATABASE_AUTO_LOCK, "false"));
    databaseAutoLockCheckbox = new JCheckBox(Translator.translate("databaseAutoLock"),
            databaseAutoLock.booleanValue());
    c.gridx = 0;
    c.gridy = 5;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 2, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    mainPanel.add(databaseAutoLockCheckbox, c);
    databaseAutoLockCheckbox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            databaseAutoLockTime.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    // The "Database auto lock" field row
    databaseAutoLockTime = new JTextField(
            Preferences.get(Preferences.ApplicationOptions.DATABASE_AUTO_LOCK_TIME), 5);
    c.gridx = 1;
    c.gridy = 5;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(databaseAutoLockTime, c);
    databaseAutoLockTime.setEnabled(databaseAutoLockCheckbox.isSelected());

    // The "Generated password length" row
    accountPasswordLengthLabel = new JLabel(Translator.translate("generatedPasswodLength"));
    c.gridx = 0;
    c.gridy = 6;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 2, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    mainPanel.add(accountPasswordLengthLabel, c);

    accountPasswordLength = new JTextField(
            Preferences.get(Preferences.ApplicationOptions.ACCOUNT_PASSWORD_LENGTH, "8"), 5);
    c.gridx = 1;
    c.gridy = 6;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(accountPasswordLength, c);

    // Some spacing
    emptyBorderPanel.add(Box.createVerticalGlue());

    // ******************
    // *** The HTTPS Section
    // ******************
    // Create a pane with an title etched border
    Border httpsEtchedTitleBorder = BorderFactory.createTitledBorder(etchedBorder, " HTTPS ");
    final JPanel httpsPanel = new JPanel(new GridBagLayout());
    httpsPanel.setBorder(httpsEtchedTitleBorder);
    emptyBorderPanel.add(httpsPanel);

    // The "Accept Self Sigend Certificates" checkbox row
    Boolean acceptSelfSignedCerts = new Boolean(
            Preferences.get(Preferences.ApplicationOptions.HTTPS_ACCEPT_SELFSIGNED_CERTS, "false"));
    acceptSelfSignedCertsCheckbox = new JCheckBox(Translator.translate("acceptSelfSignedCerts"),
            acceptSelfSignedCerts.booleanValue());
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 2, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    httpsPanel.add(acceptSelfSignedCertsCheckbox, c);

    // ******************
    // *** The Proxy Section
    // ******************
    // Create a pane with an title etched border
    Border proxyEtchedTitleBorder = BorderFactory.createTitledBorder(etchedBorder,
            ' ' + Translator.translate("httpProxy") + ' ');
    final JPanel proxyPanel = new JPanel(new GridBagLayout());
    proxyPanel.setBorder(proxyEtchedTitleBorder);
    emptyBorderPanel.add(proxyPanel);

    // The "Enable Proxy" row
    Boolean proxyEnabled = new Boolean(Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_ENABLED));
    enableProxyCheckbox = new JCheckBox(Translator.translate("enableProxy"), proxyEnabled.booleanValue());
    enableProxyCheckbox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                enableProxyComponents(true);
            } else {
                enableProxyComponents(false);
            }
        }
    });
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 2, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    proxyPanel.add(enableProxyCheckbox, c);

    // The "HTTP Proxy" label row
    proxyLabel = new JLabel(Translator.translate("httpProxy"));
    c.gridx = 0;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 3, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.NONE;
    proxyPanel.add(proxyLabel, c);

    // The "HTTP Proxy Port" label
    proxyPortLabel = new JLabel(Translator.translate("port"));
    c.gridx = 1;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 3, 5);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    proxyPanel.add(proxyPortLabel, c);

    // The "HTTP Proxy" field row
    httpProxyHost = new JTextField(Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_HOST), 20);
    c.gridx = 0;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    proxyPanel.add(httpProxyHost, c);

    httpProxyPort = new JTextField(Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_PORT), 6);
    c.gridx = 1;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    proxyPanel.add(httpProxyPort, c);

    // The "HTTP Proxy Username" label row
    proxyUsernameLabel = new JLabel(Translator.translate("httpProxyUsername"));
    c.gridx = 0;
    c.gridy = 3;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 3, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.NONE;
    proxyPanel.add(proxyUsernameLabel, c);

    // The "HTTP Proxy Username" field row
    httpProxyUsername = new JTextField(Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_USERNAME), 20);
    c.gridx = 0;
    c.gridy = 4;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 5);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.HORIZONTAL;
    proxyPanel.add(httpProxyUsername, c);

    // The "HTTP Proxy Password" label row
    proxyPasswordLabel = new JLabel(Translator.translate("httpProxyPassword"));
    c.gridx = 0;
    c.gridy = 5;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 3, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.NONE;
    proxyPanel.add(proxyPasswordLabel, c);

    // The "HTTP Proxy Password" field row
    String encodedPassword = Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_PASSWORD);
    String decodedPassword = null;
    if (encodedPassword != null) {
        decodedPassword = new String(Base64.decodeBase64(encodedPassword.getBytes()));
    }
    httpProxyPassword = new JPasswordField(decodedPassword, 20);
    c.gridx = 0;
    c.gridy = 6;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 5);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    proxyPanel.add(httpProxyPassword, c);

    hidePasswordCheckbox = new JCheckBox(Translator.translate("hide"), true);
    defaultEchoChar = httpProxyPassword.getEchoChar();
    hidePasswordCheckbox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                httpProxyPassword.setEchoChar(defaultEchoChar);
            } else {
                httpProxyPassword.setEchoChar((char) 0);
            }
        }
    });
    c.gridx = 1;
    c.gridy = 6;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 0);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    proxyPanel.add(hidePasswordCheckbox, c);

    // Some spacing
    emptyBorderPanel.add(Box.createVerticalGlue());

    // The buttons row
    JPanel buttonPanel = new JPanel(new FlowLayout());
    emptyBorderPanel.add(buttonPanel);
    JButton okButton = new JButton(Translator.translate("ok"));
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            okButtonAction();
        }
    });
    buttonPanel.add(okButton);

    JButton cancelButton = new JButton(Translator.translate("cancel"));
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
            dispose();
        }
    });
    buttonPanel.add(cancelButton);

    enableProxyComponents(proxyEnabled.booleanValue());
}

From source file:de.freese.base.swing.mac_os_x.MyApp.java

/**
 *
 *///from w w w .  j  av  a2s  .co m
public MyApp() {
    super("OSXAdapter");

    addMenus();

    // Main content area; set up a JLabel to display images selected by the user
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(this.imageLabel = new JLabel("Open an image to view it"));
    this.imageLabel.setHorizontalAlignment(SwingConstants.CENTER);
    this.imageLabel.setVerticalAlignment(SwingConstants.CENTER);
    this.imageLabel.setOpaque(true);

    // set up a simple about box
    this.aboutBox = new JDialog(this, "About OSXAdapter");
    this.aboutBox.getContentPane().setLayout(new BorderLayout());
    this.aboutBox.getContentPane().add(new JLabel("OSXAdapter", SwingConstants.CENTER));
    this.aboutBox.getContentPane().add(new JLabel("\u00A92003-2007 Apple, Inc.", SwingConstants.CENTER),
            BorderLayout.SOUTH);
    this.aboutBox.setSize(160, 120);
    this.aboutBox.setResizable(false);

    // Preferences dialog lets you select the background color when displaying an image
    this.prefs = new JDialog(this, "OSXAdapter Preferences");
    this.colorComboBox = new JComboBox<>(this.colorNames);
    this.colorComboBox.addActionListener(new ActionListener() {
        /**
         * @see
         * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
         */
        @Override
        public void actionPerformed(final ActionEvent ev) {
            if (MyApp.this.currentImage != null) {
                MyApp.this.imageLabel
                        .setBackground(MyApp.this.colors[MyApp.this.colorComboBox.getSelectedIndex()]);
            }
        }
    });

    JPanel masterPanel = new JPanel();
    masterPanel.setBorder(new TitledBorder("Window background color:"));
    masterPanel.add(this.colorComboBox);
    this.prefs.getContentPane().add(masterPanel);
    this.prefs.setSize(240, 100);
    this.prefs.setResizable(false);

    // Set up our application to respond to the Mac OS X application menu
    registerForMacOSXEvents();

    setSize(320, 240);
}

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

/**
 * Main constructor./*  w w w  . j ava 2 s.  co  m*/
 */
public HrDiagram() {

    List<UpcStar> upcStars = UpcUtils.loadUpcCatalogue();
    List<UpcStar> hipStars = UpcUtils.getHipparcosSubset(upcStars);
    List<UpcStar> unmatchedStars = UpcUtils.getUnmatchedSubset(upcStars);

    upcStarCrossMatches = XmUtil.getUpcStarCrossMatchMap(upcStars);
    hipStarCrossMatches = XmUtil.getUpcStarCrossMatchMap(hipStars);
    unmatchedStarCrossMatches = XmUtil.getUpcStarCrossMatchMap(unmatchedStars);

    logger.info("Loaded " + upcStarCrossMatches.size() + " UpcStars with SSA cross matches");
    logger.info("Loaded " + hipStarCrossMatches.size() + " UpcStars with Hipparcos and SSA cross matches");
    logger.info("Loaded " + unmatchedStarCrossMatches.size()
            + " UpcStars with no parallax cross-match, and with SSA cross matches");

    starsToPlot = upcStarCrossMatches;

    useHip = false;
    method = METHOD.NAIVE;
    fMax = 1.0;

    final JCheckBox plotAllCheckBox = new JCheckBox("Plot all UPC stars: ", true);
    plotAllCheckBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (plotAllCheckBox.isSelected()) {
                starsToPlot = upcStarCrossMatches;
                updateChart();
            }
        }
    });

    final JCheckBox plotHipCheckBox = new JCheckBox("Plot Hipparcos stars only: ", false);
    plotHipCheckBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (plotHipCheckBox.isSelected()) {
                starsToPlot = hipStarCrossMatches;
                updateChart();
            }
        }
    });

    final JCheckBox plotUnmatchedCheckBox = new JCheckBox("Plot all stars with no external match: ", false);
    plotUnmatchedCheckBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (plotUnmatchedCheckBox.isSelected()) {
                starsToPlot = unmatchedStarCrossMatches;
                updateChart();
            }
        }
    });

    final ButtonGroup bg = new ButtonGroup();
    bg.add(plotHipCheckBox);
    bg.add(plotAllCheckBox);
    bg.add(plotUnmatchedCheckBox);

    JCheckBox useHipCheckBox = new JCheckBox("Use Hipparcos parallaxes when available", useHip);
    useHipCheckBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            useHip = !useHip;
            updateChart();
        }
    });

    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));
    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(3, 3));
    controls.add(plotAllCheckBox);
    controls.add(plotHipCheckBox);
    controls.add(plotUnmatchedCheckBox);
    controls.add(new JLabel("Distance estimation method:"));
    controls.add(methodComboBox);
    controls.add(useHipCheckBox);
    controls.add(fLabel);
    controls.add(fSlider);

    // Initialise the ChartPanel
    updateChart();

    // Build the panel contents
    setLayout(new BorderLayout());
    add(chartPanel, BorderLayout.CENTER);
    add(controls, BorderLayout.SOUTH);
}

From source file:com.apatar.ui.JPublishToApatarDialog.java

public JPublishToApatarDialog(Frame arg0) throws HeadlessException {
    super(arg0);//from w  ww  .  j  a  v  a 2s  .co m
    setSize(500, 600);
    setModal(true);
    setTitle("Publish to Apatar");

    try {
        location = new JComboBox(getDataMapLocations());
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (JDOMException e) {
        e.printStackTrace();
    }

    createDialog();
    createListeners();
}

From source file:es.emergya.ui.gis.ControlPanel.java

public ControlPanel(final CustomMapView view) {
    super(new FlowLayout(FlowLayout.LEADING, 12, 0));
    this.view = view;
    // Posicion: panel con un label de icono y un textfield
    JPanel posPanel = new JPanel();
    posPanel.setOpaque(true);//from ww w  .  ja  v  a2  s .  c  om
    posPanel.setVisible(true);
    JLabel mouseLocIcon = new JLabel(LogicConstants.getIcon("map_icon_coordenadas"));
    posPanel.add(mouseLocIcon);
    final JTextField posField = new JTextField(15);
    posField.setEditable(false);
    posField.setBorder(null);
    posField.setForeground(UIManager.getColor("Label.foreground"));
    posField.setFont(UIManager.getFont("Label.font"));
    posPanel.add(posField);
    view.addMouseMotionListener(new MouseMotionListener() {

        @Override
        public void mouseMoved(MouseEvent e) {
            LatLon ll = ((ICustomMapView) e.getSource()).getLatLon(e.getX(), e.getY());
            String position = "";
            String format = LogicConstants.get("FORMATO_COORDENADAS_MAPA", "UTM");
            if (format.equals(LogicConstants.COORD_UTM)) {
                UTM u = new UTM(LogicConstants.getInt("ZONA_UTM"));
                EastNorth en = u.latlon2eastNorth(ll);
                position = String.format("x: %.1f y: %.1f", en.getX(), en.getY());
            } else {
                position = String.format("Lat: %.4f Lon: %.4f", ll.lat(), ll.lon());
            }

            posField.setText(position);
            validate();
        }

        @Override
        public void mouseDragged(MouseEvent e) {
        }
    });
    posPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    add(posPanel);

    // Panel de centrado: label, desplegable y parte cambiante
    JPanel centerPanel = new JPanel();
    centerPanel.add(new JLabel(i18n.getString("map.centerIn")));
    centerOptions = new JComboBox(new String[] { i18n.getString("map.street"), i18n.getString("map.resource"),
            i18n.getString("map.incidence"), i18n.getString("map.location") });
    centerPanel.add(centerOptions);

    centerData = new JPanel(new CardLayout());
    centerPanel.add(centerData);

    JPanel centerStreet = new JPanel();
    street = new JTextField(30);
    street.setName(i18n.getString("map.street"));
    autocompleteKeyListener = new AutocompleteKeyListener(street);
    street.addKeyListener(autocompleteKeyListener);
    street.addActionListener(this);
    centerStreet.add(street);
    centerData.add(centerStreet, i18n.getString("map.street"));

    JPanel centerResource = new JPanel();
    resources = new JComboBox(avaliableResources);
    resources.setName(i18n.getString("map.resource"));
    resources.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    resources.addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            isComboResourcesShowing = true;
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            isComboResourcesShowing = false;
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            // view.repaint();
        }
    });
    centerResource.add(resources);
    centerData.add(centerResource, i18n.getString("map.resource"));

    centerResource = new JPanel();
    incidences = new JComboBox(avaliableIncidences);
    incidences.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    incidences.setName(i18n.getString("map.incidence"));
    incidences.addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            isComboIncidencesShowing = true;
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            isComboIncidencesShowing = false;
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {

        }
    });
    centerResource.add(incidences);
    centerData.add(centerResource, i18n.getString("map.incidence"));

    JPanel centerLocation = new JPanel();
    cx = new JTextField(10);
    cx.setName("x");
    cx.addActionListener(this);
    centerLocation.add(cx);
    cy = new JTextField(10);
    cy.setName("y");
    cy.addActionListener(this);
    centerLocation.add(cy);
    centerData.add(centerLocation, i18n.getString("map.location"));

    centerOptions.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            ((CardLayout) centerData.getLayout()).show(centerData, (String) e.getItem());
        }
    });

    JButton centerButton = new JButton(i18n.getString("map.center"));
    centerButton.addActionListener(this);
    centerPanel.add(centerButton);
    add(centerPanel);

}

From source file:gov.loc.repository.bagger.ui.NewBagInPlaceFrame.java

private void layoutBagVersionContent(JPanel contentPanel, int row) {
    GridBagConstraints glbc = new GridBagConstraints();

    JLabel bagVersionLabel = new JLabel(bagView.getPropertyMessage("bag.label.version"));
    bagVersionLabel.setToolTipText(bagView.getPropertyMessage("bag.versionlist.help"));
    ArrayList<String> versionModel = new ArrayList<String>();
    Version[] vals = Version.values();// w  w w .  ja v a2s.  c  o m
    for (int i = 0; i < vals.length; i++) {
        versionModel.add(vals[i].versionString);
    }

    bagVersionList = new JComboBox(versionModel.toArray());
    bagVersionList.setName(bagView.getPropertyMessage("bag.label.versionlist"));
    bagVersionList.setSelectedItem(Version.V0_96.versionString);
    bagVersionList.setToolTipText(bagView.getPropertyMessage("bag.versionlist.help"));

    glbc = LayoutUtil.buildGridBagConstraints(0, row, 1, 1, 1, 50, GridBagConstraints.NONE,
            GridBagConstraints.WEST);
    contentPanel.add(bagVersionLabel, glbc);
    glbc = LayoutUtil.buildGridBagConstraints(1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.WEST);
    contentPanel.add(bagVersionList, glbc);
}

From source file:sanger.team16.gui.genevar.eqtl.snp.CisEQTLSNPPane2.java

public void setParameterPanel(int statisticId, Vector<Algorithm> algorithms) {
    BaseJPane panel = new BaseJPane("Analysis Parameters", 10, 20, 10, 20);

    // ------------------ Panel p0 (start) ----------------- */
    BaseJPane p0 = new BaseJPane();

    p0.add(new JLabel("1. Correlation and regression: "));
    cbStatistic = new JComboBox(Message.getStatistics(this.ui.getAddress()));

    if (!Statistic.isExternalAlgorithm(statisticId)) {
        this.setNullAlgorithms(Statistic.getStatisticIndex(statisticId));
        cbStatistic.removeItemAt(2);//from w  w w  . j a v a2  s .  c o  m
    } else
        this.setAlgorithms(algorithms);
    cbStatistic.addActionListener(this);
    p0.add(cbStatistic);
    p0.add(cbAlgorithm);

    p0.add(new JLabel(" "));

    p0.setBaseSpringBoxTrailing();
    panel.add(p0);
    // ------------------ Panel p0 (end) ----------------- */

    panel.add(new JLabel(""));

    // ------------------ Panel p1 (start) ----------------- */
    BaseJPane p1 = new BaseJPane();

    p1.add(new JLabel("2. Number of permutations: "));
    cbPermutation = new JComboBox(permutations);
    cbPermutation.setSelectedIndex(1);
    cbPermutation.addActionListener(this);
    p1.add(cbPermutation);

    p1.add(new JLabel(" "));

    p1.setBaseSpringBoxTrailing();
    panel.add(p1);
    // ------------------ Panel p1 (end) ----------------- */

    panel.setBaseSpringGrid(1);
    this.add(panel);
}

From source file:FontChooser.java

private void createUserInterface() {
    final JPanel content = new JPanel(new GridBagLayout());
    final GridBagConstraints gbc = new GridBagConstraints();

    setContentPane(content);//w  ww .ja v  a 2  s  . c  o m
    content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.fill = GridBagConstraints.HORIZONTAL;

    gbc.gridx = gbc.gridy = 0;
    content.add(new JLabel("Font"), gbc);

    ++gbc.gridx;
    content.add(new JLabel("Size"), gbc);

    if (_selectStyles) {
        ++gbc.gridx;
        content.add(new JLabel("Style"), gbc);
    }

    ++gbc.gridy;
    gbc.gridx = 0;
    _fontNamesCmb = new JComboBox(
            GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
    content.add(_fontNamesCmb, gbc);

    ++gbc.gridx;
    _fontSizesCmb.setEditable(true);
    content.add(_fontSizesCmb, gbc);

    if (_selectStyles) {
        ++gbc.gridx;
        content.add(_boldChk, gbc);
        ++gbc.gridy;
        content.add(_italicChk, gbc);
    }

    gbc.gridx = 0;
    ++gbc.gridy;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.CENTER;
    content.add(createPreviewPanel(), gbc);

    ++gbc.gridy;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    content.add(createButtonsPanel(), gbc);

    pack();
    setResizable(true);
}