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:components.LayeredPaneDemo.java

private JPanel createControlPanel() {
    onTop = new JCheckBox("Top Position in Layer");
    onTop.setSelected(true);/*w w  w  . ja v a 2s  .  c o m*/
    onTop.setActionCommand(ON_TOP_COMMAND);
    onTop.addActionListener(this);

    layerList = new JComboBox(layerStrings);
    layerList.setSelectedIndex(2); //cyan layer
    layerList.setActionCommand(LAYER_COMMAND);
    layerList.addActionListener(this);

    JPanel controls = new JPanel();
    controls.add(layerList);
    controls.add(onTop);
    controls.setBorder(BorderFactory.createTitledBorder("Choose Duke's Layer and Position"));
    return controls;
}

From source file:com.game.ui.views.CharacterEditor.java

/**
 * This method draws up the gui on the panel.
 *///from   w  w  w  .j  a  v  a  2 s .  c  om
public void doGui() {
    JPanel outerPane = new JPanel();
    outerPane.setLayout(new GridBagLayout());
    //        setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JLabel noteLbl = new JLabel(lblContent);
    noteLbl.setAlignmentX(0);
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.NONE;
    c.insets = new Insets(5, 5, 5, 5);
    c.gridwidth = 4;
    c.gridy = 0;
    c.gridx = 0;
    outerPane.add(noteLbl, c);
    System.out.println(c.gridy);
    c.gridy++;
    System.out.println(c.gridy);
    c.gridx = 0;
    c.gridwidth = 1;
    comboBox = new JComboBox(model);
    comboBox.setSelectedIndex(-1);
    comboBox.setMaximumSize(new Dimension(100, 30));
    comboBox.setAlignmentX(0);
    comboBox.setActionCommand("dropDown");
    comboBox.addActionListener(this);
    outerPane.add(comboBox, c);
    c.gridy++;
    JLabel nameLbl = new JLabel("Name : ");
    outerPane.add(nameLbl, c);
    c.gridx++;
    name = new JTextField();
    name.setColumns(20);
    outerPane.add(name, c);
    c.gridx = 0;
    c.gridy++;
    JLabel imageLbl = new JLabel("Image Path : ");
    outerPane.add(imageLbl, c);
    c.gridx++;
    imgPath = new JTextField();
    imgPath.setColumns(20);
    outerPane.add(imgPath, c);
    c.gridx = 0;
    c.gridy++;
    JLabel hitPtsLbl = new JLabel("Hit Points : ");
    outerPane.add(hitPtsLbl, c);
    c.gridx++;
    hitPoints = new JTextField();
    hitPoints.setColumns(20);
    outerPane.add(hitPoints, c);
    c.gridx = 0;
    c.gridy++;
    JLabel lvl = new JLabel("Level : ");
    outerPane.add(lvl, c);
    c.gridx++;
    level = new JTextField();
    level.setColumns(20);
    /*if(!isEnemy){
    level.setText("1");
    level.setEnabled(false);
    }*/
    outerPane.add(level, c);
    c.gridx = 0;
    c.gridy++;
    JLabel mlWpn = new JLabel("Melee Weapon : ");
    outerPane.add(mlWpn, c);
    c.gridx++;
    model = new DefaultComboBoxModel();
    LinkedList<String> meleeWpnList = new LinkedList<String>();
    LinkedList<String> rngdWpnList = new LinkedList<String>();
    for (Item item : GameBean.weaponDetails) {
        Weapon wpn = (Weapon) item;
        if (wpn.getWeaponType().equalsIgnoreCase(Configuration.weaponTypes[0])) {
            meleeWpnList.add(wpn.getName());
        } else {
            rngdWpnList.add(wpn.getName());
        }
        weaponMap.put(wpn.getName(), wpn);
    }
    meleeWeapon = new JComboBox(new DefaultComboBoxModel(meleeWpnList.toArray()));
    meleeWeapon.setSelectedIndex(-1);
    meleeWeapon.setMaximumSize(new Dimension(100, 30));
    outerPane.add(meleeWeapon, c);
    c.gridx++;
    JLabel rngdWpn = new JLabel("Ranged Weapon : ");
    outerPane.add(rngdWpn, c);
    c.gridx++;
    rangedWeapon = new JComboBox(new DefaultComboBoxModel(rngdWpnList.toArray()));
    rangedWeapon.setSelectedIndex(-1);
    rangedWeapon.setMaximumSize(new Dimension(100, 30));
    outerPane.add(rangedWeapon, c);
    c.gridy++;
    c.gridx = 0;
    JLabel armourLbl = new JLabel("Armour : ");
    outerPane.add(armourLbl, c);
    c.gridx++;
    LinkedList<String> armourList = new LinkedList<String>();
    LinkedList<String> shildList = new LinkedList<String>();
    for (Item item : GameBean.armourDetails) {
        Armour temp = (Armour) item;
        if (temp.getArmourType() != null) {
            if (temp.getArmourType().equalsIgnoreCase(Configuration.armourTypes[1])) {
                armourList.add(temp.getName());
            } else {
                shildList.add(temp.getName());
            }
        } else {
            armourList.add(temp.getName());
            //            else if(temp.getArmourType().equalsIgnoreCase(Configuration.armourTypes[2]))
            shildList.add(temp.getName());
        }
        armorMap.put(temp.getName(), temp);
    }
    armour = new JComboBox(new DefaultComboBoxModel(armourList.toArray()));
    armour.setSelectedIndex(-1);
    armour.setMaximumSize(new Dimension(100, 30));
    outerPane.add(armour, c);
    c.gridx++;
    JLabel shieldLbl = new JLabel("Shield : ");
    outerPane.add(shieldLbl, c);
    c.gridx++;
    shield = new JComboBox(new DefaultComboBoxModel(shildList.toArray()));
    shield.setSelectedIndex(-1);
    shield.setMaximumSize(new Dimension(100, 30));
    outerPane.add(shield, c);
    ta = new JTextArea(10, 50);
    ta.setRows(40);
    ta.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
    JScrollPane scrollPane = new JScrollPane(ta);
    scrollPane.setPreferredSize(new Dimension(600, 250));
    c.gridx = 0;
    c.gridy++;
    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = 4;
    c.gridheight = 4;
    c.weightx = .5;
    c.weighty = 1;
    outerPane.add(scrollPane, c);
    c.gridy += 4;
    c.gridx = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    c.gridheight = 1;
    c.gridwidth = 1;
    JButton generate = new JButton("Generate");
    JButton submit = new JButton("Submit");
    outerPane.add(generate, c);
    submit.addActionListener(this);
    generate.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            ta.setText("");
            HashSet<Integer> set = new HashSet<Integer>();
            int strength = getUniqueVal(set);
            int constitution = getUniqueVal(set);
            int dext = getUniqueVal(set);
            int intel = getUniqueVal(set);
            int charisma = getUniqueVal(set);
            int wisdom = getUniqueVal(set);
            if (character == null) {
                builder = new CharacterBuilder(isEnemy);
            } else {
                builder = new CharacterBuilder(character);
            }
            builder.setStrength(strength);
            builder.setConstitution(constitution);
            builder.setDexterity(dext);
            builder.setIntelligence(intel);
            builder.setCharisma(charisma);
            builder.setWisdom(wisdom);
            int strModifier = GameUtils.calculateAbilityModifier(strength);
            int conModifier = GameUtils.calculateAbilityModifier(constitution);
            int dexModifier = GameUtils.calculateAbilityModifier(dext);
            int wisModifier = GameUtils.calculateAbilityModifier(wisdom);
            int intModifier = GameUtils.calculateAbilityModifier(intel);
            int chaModifier = GameUtils.calculateAbilityModifier(charisma);
            builder.setStrengthModifier(strModifier);
            builder.setConstitutionModifier(conModifier);
            builder.setCharismaModifier(chaModifier);
            builder.setWisdomModifier(wisModifier);
            builder.setIntelligenceModifier(intModifier);
            builder.setDexterityModifier(dexModifier);
            String type = null;
            if (constitution < strength && constitution > dext) {
                type = "Bully";
                builder.setType("Bully");
            } else if (dext > constitution && constitution > strength) {
                builder.setType("Nimble");
                type = "Nimble";
            } else {
                builder.setType("Tank");
                type = "Tank";
            }
            ta.append("Strength : " + strength);
            ta.append("\nDexterity : " + dexModifier);
            ta.append("\nConstitution : " + constitution);
            ta.append("\nIntelligence : " + intel);
            ta.append("\nCharisma: " + charisma);
            ta.append("\nWisdom : " + wisdom);
            ta.append("\nType :" + type);
            ta.append("\nStrength Modifier :" + strModifier);
            ta.append("\nConstitution Modifier :" + conModifier);
            ta.append("\nDexterity Modifier :" + dexModifier);
            generated = true;
            if (character != null) {
                character = builder.build();
            }
        }
    });
    c.gridx++;
    outerPane.add(submit, c);
    validationMess = new JLabel();
    validationMess.setForeground(Color.red);
    //        validationMess.setVisible(false);
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 4;
    outerPane.add(validationMess, c);
    JScrollPane outerScrollPane = new JScrollPane(outerPane);
    setLayout(new BorderLayout());
    add(outerScrollPane, BorderLayout.CENTER);
}

From source file:de.huxhorn.lilith.swing.preferences.PreferencesDialog.java

private void createUI() {
    generalPanel = new GeneralPanel(this);
    startupShutdownPanel = new StartupShutdownPanel(this);
    windowsPanel = new WindowsPanel(this);
    soundsPanel = new SoundsPanel(this);
    sourcesPanel = new SourcesPanel(this);
    sourceListsPanel = new SourceListsPanel(this);
    sourceFilteringPanel = new SourceFilteringPanel(this);
    conditionsPanel = new ConditionsPanel(this);
    loggingLevelPanel = new LoggingLevelPanel(this);
    accessStatusTypePanel = new AccessStatusTypePanel(this);
    TroubleshootingPanel troubleshootingPanel = new TroubleshootingPanel(this);

    comboBoxModel = new DefaultComboBoxModel<>();
    for (Panes current : Panes.values()) {
        comboBoxModel.addElement(current);
    }/* w ww.  j a  va  2 s. co m*/
    comboBox = new JComboBox<>(comboBoxModel);
    comboBox.setRenderer(new MyComboBoxRenderer());
    comboBox.setEditable(false);
    comboBox.addItemListener(new ComboItemListener());

    cardLayout = new CardLayout();
    content = new JPanel(cardLayout);
    content.setPreferredSize(new Dimension(600, 500));

    content.add(generalPanel, Panes.General.toString());
    content.add(startupShutdownPanel, Panes.StartupShutdown.toString());
    content.add(windowsPanel, Panes.Windows.toString());
    content.add(soundsPanel, Panes.Sounds.toString());
    content.add(sourcesPanel, Panes.Sources.toString());
    content.add(sourceListsPanel, Panes.SourceLists.toString());
    content.add(sourceFilteringPanel, Panes.SourceFiltering.toString());
    content.add(conditionsPanel, Panes.Conditions.toString());
    content.add(loggingLevelPanel, Panes.LoggingLevels.toString());
    content.add(accessStatusTypePanel, Panes.AccessStatus.toString());
    content.add(troubleshootingPanel, Panes.Troubleshooting.toString());

    // Main buttons
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    OkAction okAction = new OkAction();
    buttonPanel.add(new JButton(okAction));
    buttonPanel.add(new JButton(new ApplyAction()));
    buttonPanel.add(new JButton(new ResetAction()));
    CancelAction cancelAction = new CancelAction();
    buttonPanel.add(new JButton(cancelAction));

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(comboBox, BorderLayout.NORTH);
    contentPane.add(content, BorderLayout.CENTER);
    contentPane.add(buttonPanel, BorderLayout.SOUTH);
    KeyStrokes.registerCommand(content, okAction, "OK_ACTION");
    KeyStrokes.registerCommand(buttonPanel, okAction, "OK_ACTION");
    KeyStrokes.registerCommand(content, cancelAction, "CANCEL_ACTION");
    KeyStrokes.registerCommand(buttonPanel, cancelAction, "CANCEL_ACTION");
}

From source file:com.moneydance.modules.features.mdvenmoimporter.VenmoImporterWindow.java

public VenmoImporterWindow(Main extension) {
    super("VenmoImporter Console");
    this.extension = extension;

    loadSettings();// w  ww.j  a  v a 2  s  .c o  m

    setResizable(false);
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    setBounds(100, 100, 516, 176);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(10, 10, 10, 10));
    setContentPane(contentPane);
    contentPane.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, RowSpec.decode("8dlu"),
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    JLabel lblVenmoToken = new JLabel("Venmo Token");
    lblVenmoToken.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPane.add(lblVenmoToken, "2, 2");

    venmoTokenField = new JTextField(venmoToken);
    venmoTokenField.setToolTipText(venmoTokenTooltip);
    contentPane.add(venmoTokenField, "4, 2, fill, default");
    venmoTokenField.setColumns(50);

    JLabel lblAccount = new JLabel("Account");
    contentPane.add(lblAccount, "2, 4, right, default");

    targetAccountCombo = new JComboBox<>(
            new Vector<>(extension.getUnprotectedContext().getRootAccount().getSubAccounts()));
    contentPane.add(targetAccountCombo, "4, 4, fill, default");
    if (targetAcctId != null) {
        targetAccountCombo.setSelectedItem(
                extension.getUnprotectedContext().getCurrentAccountBook().getAccountByUUID(targetAcctId));
    }

    JLabel lblDescriptionFormat = new JLabel("Memo template");
    contentPane.add(lblDescriptionFormat, "2, 6, right, default");

    descriptionFormatField = new JTextField(
            descriptionFormat == null ? descriptionFormatDefault : descriptionFormat);
    descriptionFormatField.setToolTipText(descriptionFormatTooltip);
    contentPane.add(descriptionFormatField, "4, 6, fill, default");
    descriptionFormatField.setColumns(10);

    panel = new JPanel();
    panel.setBorder(null);
    contentPane.add(panel, "2, 8, 3, 1, fill, fill");

    btnDelete = new JButton("Delete Settings");
    panel.add(btnDelete);

    btnCancel = new JButton("Cancel");
    panel.add(btnCancel);

    btnSave = new JButton("Save");
    panel.add(btnSave);

    btnDownloadTransactions = new JButton("Download Transactions");
    panel.add(btnDownloadTransactions);

    btnCancel.addActionListener(this);
    btnSave.addActionListener(this);
    btnDelete.addActionListener(this);
    btnDownloadTransactions.addActionListener(this);

    enableEvents(WindowEvent.WINDOW_CLOSING);

}

From source file:ec.util.chart.swing.JTimeSeriesRendererSupportDemo.java

private Component createToolBar() {
    JToolBar result = new JToolBar();
    result.setFloatable(false);/* w  w  w .ja v  a2  s. c  om*/

    result.add(RANDOM_DATA.toAction(chart)).setIcon(FontAwesome.FA_RANDOM.getIcon(getForeground(), 16f));

    JComboBox<RendererType> types = new JComboBox<>(
            support.getSupportedRendererTypes().toArray(new RendererType[0]));
    types.setMaximumSize(new Dimension(150, 100));
    types.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            RendererType type = (RendererType) e.getItem();
            chart.getXYPlot().setRenderer(support.createRenderer(type));
            chart.getXYPlot().setBackgroundPaint(support.getPlotColor());
            chart.setBackgroundPaint(colorSchemeSupport.getBackColor());
        }
    });
    types.setSelectedIndex(1);
    result.add(types);

    return result;
}

From source file:com.codeasylum.liquibase.Liquidate.java

public Liquidate() {

    super("Liquidate");

    ParaboxLayoutManager layout;/*from   w  ww.  j  a  v a2s .c  o  m*/
    ParallelBox goalHorizontalBox;
    SerialBox sourceHorizontalBox;
    ParallelBox sourceVerticalBox;
    SerialBox goalVerticalBox;
    JSeparator buttonSeparator;
    JRadioButton[] sourceButtons;
    JRadioButton[] goalButtons;
    JLabel databaseLabel;
    JLabel hostLabel;
    JLabel colonLabel;
    JLabel schemaLabel;
    JLabel userLabel;
    JLabel passwordLabel;
    JLabel sourceLabel;
    JLabel goalLabel;
    JLabel outputLabel;
    int sourceIndex = 0;
    int goalIndex = 0;

    config = new LiquidateConfig();

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setLayout(layout = new ParaboxLayoutManager(getContentPane()));

    databaseLabel = new JLabel("Database:");
    databaseCombo = new JComboBox(Database.values());
    databaseCombo.addItemListener(this);

    hostLabel = new JLabel("Host and Port:");
    hostTextField = new JTextField();
    hostTextField.getDocument().addDocumentListener(this);

    portTextField = new JTextField();
    portTextField.setHorizontalAlignment(JTextField.RIGHT);
    portTextField.setPreferredSize(new Dimension(50, (int) portTextField.getPreferredSize().getHeight()));
    portTextField.setMaximumSize(portTextField.getPreferredSize());
    portTextField.getDocument().addDocumentListener(this);
    colonLabel = new JLabel(":");

    schemaLabel = new JLabel("Schema:");
    schemaTextField = new JTextField();
    schemaTextField.getDocument().addDocumentListener(this);

    userLabel = new JLabel("User:");
    userTextField = new JTextField();
    userTextField.getDocument().addDocumentListener(this);

    passwordLabel = new JLabel("Password:");
    passwordField = new JPasswordField();
    passwordField.getDocument().addDocumentListener(this);

    sourceLabel = new JLabel("Change Log:");
    sourceButtonGroup = new EventCoalescingButtonGroup();
    sourceButtons = new JRadioButton[Source.values().length];
    for (Source source : Source.values()) {
        sourceButtonGroup.add(sourceButtons[sourceIndex] = new JRadioButton(
                StringUtilities.toDisplayCase(source.name(), '_')));
        sourceButtons[sourceIndex++].setActionCommand(source.name());
    }
    sourceButtons[0].setSelected(true);
    sourceButtonGroup.addActionListener(this);

    changeLogTextField = new JTextField();
    changeLogTextField.getDocument().addDocumentListener(this);

    goalLabel = new JLabel("Goal:");
    goalButtonGroup = new EventCoalescingButtonGroup();
    goalButtons = new JRadioButton[Goal.values().length - 1];
    for (Goal goal : Goal.values()) {
        if (!goal.equals(Goal.NONE)) {
            goalButtonGroup.add(
                    goalButtons[goalIndex] = new JRadioButton(StringUtilities.toDisplayCase(goal.name(), '_')));
            goalButtons[goalIndex++].setActionCommand(goal.name());
        }
    }
    goalButtons[0].setSelected(true);
    goalButtonGroup.addActionListener(this);

    outputLabel = new JLabel("Output:");
    browseButton = new JButton("Browse...", BROWSE_ICON);
    browseButton.setMargin(new Insets(2, 2, 2, 2));
    browseButton.setFocusable(false);
    browseButton.setToolTipText("browse for a file");
    browseButton.addActionListener(this);
    browseButton.setEnabled(false);
    outputTextField = new JTextField();
    outputTextField.getDocument().addDocumentListener(this);
    outputTextField.setEnabled(false);

    buttonSeparator = new JSeparator(JSeparator.HORIZONTAL);
    buttonSeparator.setMaximumSize(
            new Dimension(Integer.MAX_VALUE, (int) buttonSeparator.getPreferredSize().getHeight()));

    startButton = new JButton("Start");
    startButton.addActionListener(this);

    layout.setHorizontalBox(layout.parallelBox().add(layout.sequentialBox()
            .add(layout.parallelBox(Alignment.TRAILING).add(databaseLabel).add(hostLabel).add(schemaLabel)
                    .add(userLabel).add(passwordLabel).add(sourceLabel).add(goalLabel).add(outputLabel))
            .add(goalHorizontalBox = layout.parallelBox().add(databaseCombo, Constraint.expand())
                    .add(layout.sequentialBox(3).add(hostTextField, Constraint.expand()).add(colonLabel)
                            .add(portTextField))
                    .add(schemaTextField, Constraint.expand()).add(userTextField, Constraint.expand())
                    .add(passwordField, Constraint.expand()).add(sourceHorizontalBox = layout.sequentialBox())
                    .add(changeLogTextField, Constraint.expand())
                    .add(layout.parallelBox(Alignment.TRAILING).add(outputTextField, Constraint.expand())
                            .add(browseButton))))
            .add(buttonSeparator, Constraint.expand())
            .add(layout.sequentialBox(Justification.LAST, true).add(startButton)));

    for (JRadioButton sourceButton : sourceButtons) {
        sourceHorizontalBox.add(sourceButton);
    }

    for (JRadioButton goalButton : goalButtons) {
        goalHorizontalBox.add(goalButton);
    }

    layout.setVerticalBox(layout.sequentialBox()
            .add(layout.sequentialBox()
                    .add(layout.parallelBox(Alignment.BASELINE).add(databaseLabel).add(databaseCombo))
                    .add(layout.parallelBox(Alignment.BASELINE).add(hostLabel).add(hostTextField)
                            .add(colonLabel).add(portTextField))
                    .add(layout.parallelBox(Alignment.BASELINE).add(schemaLabel).add(schemaTextField))
                    .add(layout.parallelBox(Alignment.BASELINE).add(userLabel).add(userTextField))
                    .add(layout.parallelBox(Alignment.BASELINE).add(passwordLabel).add(passwordField)))
            .add(layout.sequentialBox(3)
                    .add(layout.parallelBox(Alignment.CENTER).add(sourceLabel)
                            .add(sourceVerticalBox = layout.parallelBox()))
                    .add(changeLogTextField))
            .add(goalVerticalBox = layout.sequentialBox(Gap.NONE)
                    .add(layout.parallelBox(Alignment.BASELINE).add(goalLabel).add(goalButtons[0]))));

    for (JRadioButton sourceButton : sourceButtons) {
        sourceVerticalBox.add(sourceButton);
    }

    for (int count = 1; count < goalButtons.length; count++) {
        goalVerticalBox.add(goalButtons[count]);
    }

    layout.getVerticalBox()
            .add(layout.sequentialBox(Gap.RELATED)
                    .add(layout.parallelBox(Alignment.BASELINE).add(outputLabel).add(outputTextField))
                    .add(browseButton))
            .add(layout.sequentialBox(Gap.RELATED).add(buttonSeparator).add(startButton));

    setSize(new Dimension(((int) getLayout().preferredLayoutSize(this).getWidth()) + 150,
            ((int) getLayout().preferredLayoutSize(this).getHeight()) + 50));
    setResizable(false);
    setLocationByPlatform(true);
}

From source file:de.atomfrede.tools.evalutation.ui.MainPanel.java

private JComboBox getEvaluationTypeComboBox() {
    if (evaluationTypeCombobox == null) {
        evaluationTypeCombobox = new JComboBox(AbstractEvaluation.EvaluationType.values());

        evaluationTypeCombobox.setRenderer(new EvaluationTypeRender());

        evaluationTypeCombobox.addActionListener(new ActionListener() {

            @Override//from   w  ww . j a  v  a  2  s  . c om
            public void actionPerformed(ActionEvent arg0) {
                AbstractEvaluation.EvaluationType type = (EvaluationType) evaluationTypeCombobox
                        .getSelectedItem();
                switch (type) {
                case JULIANE:
                    plantListPanel.setVisible(true);
                    getAddButton().setVisible(true);
                    revalidate();
                    break;

                default:
                    plantListPanel.setVisible(false);
                    getAddButton().setVisible(false);
                    revalidate();
                    break;
                }
            }
        });

        evaluationTypeCombobox.setSelectedItem(EvaluationType.JULIANE);
    }
    return evaluationTypeCombobox;
}

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

private void layoutProfileSelection(JPanel contentPane, int row) {
    // content//from  ww  w . ja v a  2  s . c  o  m
    // profile selection
    JLabel bagProfileLabel = new JLabel(bagView.getPropertyMessage("Select Profile:"));
    bagProfileLabel.setToolTipText(bagView.getPropertyMessage("bag.projectlist.help"));

    profileList = new JComboBox(bagView.getProfileStore().getProfileNames());
    profileList.setName(bagView.getPropertyMessage("bag.label.projectlist"));
    profileList.setSelectedItem(bagView.getPropertyMessage("bag.project.noproject"));
    profileList.setToolTipText(bagView.getPropertyMessage("bag.projectlist.help"));

    GridBagConstraints glbc = new GridBagConstraints();

    JLabel spacerLabel = new JLabel();
    glbc = LayoutUtil.buildGridBagConstraints(0, row, 1, 1, 5, 50, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.WEST);
    contentPane.add(bagProfileLabel, glbc);
    glbc = LayoutUtil.buildGridBagConstraints(1, row, 1, 1, 40, 50, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.CENTER);
    contentPane.add(profileList, glbc);
    glbc = LayoutUtil.buildGridBagConstraints(2, row, 1, 1, 40, 50, GridBagConstraints.NONE,
            GridBagConstraints.EAST);
    contentPane.add(spacerLabel, glbc);
}

From source file:net.pms.newgui.GeneralTab.java

public JComponent build() {
    // Apply the orientation for the locale
    Locale locale = new Locale(configuration.getLanguage());
    ComponentOrientation orientation = ComponentOrientation.getOrientation(locale);
    String colSpec = FormLayoutUtil.getColSpec(COL_SPEC, orientation);

    FormLayout layout = new FormLayout(colSpec, ROW_SPEC);
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.DLU4_BORDER);
    builder.setOpaque(true);//  ww w  . j av a 2 s .c  o  m

    CellConstraints cc = new CellConstraints();

    smcheckBox = new JCheckBox(Messages.getString("NetworkTab.3"));
    smcheckBox.setContentAreaFilled(false);
    smcheckBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            configuration.setMinimized((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    if (configuration.isMinimized()) {
        smcheckBox.setSelected(true);
    }

    JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"),
            FormLayoutUtil.flip(cc.xyw(1, 1, 9), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));
    builder.addLabel(Messages.getString("NetworkTab.0"),
            FormLayoutUtil.flip(cc.xy(1, 7), colSpec, orientation));
    final KeyedComboBoxModel kcbm = new KeyedComboBoxModel(
            new Object[] { "ar", "bg", "ca", "zhs", "zht", "cz", "da", "nl", "en", "fi", "fr", "de", "el", "iw",
                    "is", "it", "ja", "ko", "no", "pl", "pt", "br", "ro", "ru", "sl", "es", "sv", "tr" },
            new Object[] { "Arabic", "Bulgarian", "Catalan", "Chinese (Simplified)", "Chinese (Traditional)",
                    "Czech", "Danish", "Dutch", "English", "Finnish", "French", "German", "Greek", "Hebrew",
                    "Icelandic", "Italian", "Japanese", "Korean", "Norwegian", "Polish", "Portuguese",
                    "Portuguese (Brazilian)", "Romanian", "Russian", "Slovenian", "Spanish", "Swedish",
                    "Turkish" });
    langs = new JComboBox(kcbm);
    langs.setEditable(false);
    String defaultLang = null;
    if (configuration.getLanguage() != null && configuration.getLanguage().length() > 0) {
        defaultLang = configuration.getLanguage();
    } else {
        defaultLang = Locale.getDefault().getLanguage();
    }
    if (defaultLang == null) {
        defaultLang = "en";
    }
    kcbm.setSelectedKey(defaultLang);
    if (langs.getSelectedIndex() == -1) {
        langs.setSelectedIndex(0);
    }

    langs.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                configuration.setLanguage((String) kcbm.getSelectedKey());

            }
        }
    });

    builder.add(langs, FormLayoutUtil.flip(cc.xyw(3, 7, 7), colSpec, orientation));

    builder.add(smcheckBox, FormLayoutUtil.flip(cc.xyw(1, 9, 9), colSpec, orientation));

    JButton service = new JButton(Messages.getString("NetworkTab.4"));
    service.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (PMS.get().installWin32Service()) {
                JOptionPane.showMessageDialog(
                        (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
                        Messages.getString("NetworkTab.11") + Messages.getString("NetworkTab.12"),
                        Messages.getString("Dialog.Information"), JOptionPane.INFORMATION_MESSAGE);

            } else {
                JOptionPane.showMessageDialog(
                        (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
                        Messages.getString("NetworkTab.14"), Messages.getString("Dialog.Error"),
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    builder.add(service, FormLayoutUtil.flip(cc.xy(1, 11), colSpec, orientation));

    if (System.getProperty(LooksFrame.START_SERVICE) != null || !Platform.isWindows()) {
        service.setEnabled(false);
    }

    JButton checkForUpdates = new JButton(Messages.getString("NetworkTab.8"));

    checkForUpdates.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            LooksFrame frame = (LooksFrame) PMS.get().getFrame();
            frame.checkForUpdates();
        }
    });

    builder.add(checkForUpdates, FormLayoutUtil.flip(cc.xy(1, 13), colSpec, orientation));

    autoUpdateCheckBox = new JCheckBox(Messages.getString("NetworkTab.9"));
    autoUpdateCheckBox.setContentAreaFilled(false);
    autoUpdateCheckBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            configuration.setAutoUpdate((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    if (configuration.isAutoUpdate()) {
        autoUpdateCheckBox.setSelected(true);
    }

    builder.add(autoUpdateCheckBox, FormLayoutUtil.flip(cc.xyw(7, 13, 3), colSpec, orientation));

    if (!Build.isUpdatable()) {
        checkForUpdates.setEnabled(false);
        autoUpdateCheckBox.setEnabled(false);
    }

    host = new JTextField(configuration.getServerHostname());
    host.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setHostname(host.getText());
        }
    });

    port = new JTextField(configuration.getServerPort() != 5001 ? "" + configuration.getServerPort() : "");
    port.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            try {
                String p = port.getText();
                if (StringUtils.isEmpty(p)) {
                    p = "5001";
                }
                int ab = Integer.parseInt(p);
                configuration.setServerPort(ab);
            } catch (NumberFormatException nfe) {
                logger.debug("Could not parse port from \"" + port.getText() + "\"");
            }

        }
    });

    cmp = builder.addSeparator(Messages.getString("NetworkTab.22"),
            FormLayoutUtil.flip(cc.xyw(1, 21, 9), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    final KeyedComboBoxModel networkInterfaces = createNetworkInterfacesModel();
    networkinterfacesCBX = new JComboBox(networkInterfaces);
    networkInterfaces.setSelectedKey(configuration.getNetworkInterface());
    networkinterfacesCBX.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                configuration.setNetworkInterface((String) networkInterfaces.getSelectedKey());
            }
        }
    });

    ip_filter = new JTextField(configuration.getIpFilter());
    ip_filter.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setIpFilter(ip_filter.getText());
        }
    });

    maxbitrate = new JTextField(configuration.getMaximumBitrate());
    maxbitrate.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            PMS.getConfiguration().setMaximumBitrate(maxbitrate.getText());
        }
    });

    builder.addLabel(Messages.getString("NetworkTab.20"),
            FormLayoutUtil.flip(cc.xy(1, 23), colSpec, orientation));
    builder.add(networkinterfacesCBX, FormLayoutUtil.flip(cc.xyw(3, 23, 7), colSpec, orientation));
    builder.addLabel(Messages.getString("NetworkTab.23"),
            FormLayoutUtil.flip(cc.xy(1, 25), colSpec, orientation));
    builder.add(host, FormLayoutUtil.flip(cc.xyw(3, 25, 7), colSpec, orientation));
    builder.addLabel(Messages.getString("NetworkTab.24"),
            FormLayoutUtil.flip(cc.xy(1, 27), colSpec, orientation));
    builder.add(port, FormLayoutUtil.flip(cc.xyw(3, 27, 7), colSpec, orientation));
    builder.addLabel(Messages.getString("NetworkTab.30"),
            FormLayoutUtil.flip(cc.xy(1, 29), colSpec, orientation));
    builder.add(ip_filter, FormLayoutUtil.flip(cc.xyw(3, 29, 7), colSpec, orientation));
    builder.addLabel(Messages.getString("NetworkTab.35"),
            FormLayoutUtil.flip(cc.xy(1, 31), colSpec, orientation));
    builder.add(maxbitrate, FormLayoutUtil.flip(cc.xyw(3, 31, 7), colSpec, orientation));

    cmp = builder.addSeparator(Messages.getString("NetworkTab.31"),
            FormLayoutUtil.flip(cc.xyw(1, 33, 9), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    newHTTPEngine = new JCheckBox(Messages.getString("NetworkTab.32"));
    newHTTPEngine.setSelected(configuration.isHTTPEngineV2());
    newHTTPEngine.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            configuration.setHTTPEngineV2((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(newHTTPEngine, FormLayoutUtil.flip(cc.xyw(1, 35, 9), colSpec, orientation));

    preventSleep = new JCheckBox(Messages.getString("NetworkTab.33"));
    preventSleep.setSelected(configuration.isPreventsSleep());
    preventSleep.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            configuration.setPreventsSleep((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(preventSleep, FormLayoutUtil.flip(cc.xyw(1, 37, 9), colSpec, orientation));

    JCheckBox fdCheckBox = new JCheckBox(Messages.getString("NetworkTab.38"));
    fdCheckBox.setContentAreaFilled(false);
    fdCheckBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            configuration.setRendererForceDefault((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    if (configuration.isRendererForceDefault()) {
        fdCheckBox.setSelected(true);
    }

    builder.addLabel(Messages.getString("NetworkTab.36"),
            FormLayoutUtil.flip(cc.xy(1, 39), colSpec, orientation));

    ArrayList<RendererConfiguration> allConfs = RendererConfiguration.getAllRendererConfigurations();
    ArrayList<Object> keyValues = new ArrayList<Object>();
    ArrayList<Object> nameValues = new ArrayList<Object>();
    keyValues.add("");
    nameValues.add(Messages.getString("NetworkTab.37"));

    if (allConfs != null) {
        for (RendererConfiguration renderer : allConfs) {
            if (renderer != null) {
                keyValues.add(renderer.getRendererName());
                nameValues.add(renderer.getRendererName());
            }
        }
    }

    final KeyedComboBoxModel renderersKcbm = new KeyedComboBoxModel(
            (Object[]) keyValues.toArray(new Object[keyValues.size()]),
            (Object[]) nameValues.toArray(new Object[nameValues.size()]));
    renderers = new JComboBox(renderersKcbm);
    renderers.setEditable(false);
    String defaultRenderer = configuration.getRendererDefault();
    renderersKcbm.setSelectedKey(defaultRenderer);

    if (renderers.getSelectedIndex() == -1) {
        renderers.setSelectedIndex(0);
    }

    builder.add(renderers, FormLayoutUtil.flip(cc.xyw(3, 39, 7), colSpec, orientation));

    builder.add(fdCheckBox, FormLayoutUtil.flip(cc.xyw(1, 41, 9), colSpec, orientation));

    cmp = builder.addSeparator(Messages.getString("NetworkTab.34"),
            FormLayoutUtil.flip(cc.xyw(1, 43, 9), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    pPlugins = new JPanel(new GridLayout());
    builder.add(pPlugins, FormLayoutUtil.flip(cc.xyw(1, 45, 9), colSpec, orientation));

    JPanel panel = builder.getPanel();

    // Apply the orientation to the panel and all components in it
    panel.applyComponentOrientation(orientation);

    JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    return scrollPane;
}

From source file:com.liveperson.infra.akka.actorx.ui.DisplayGraph.java

public static JPanel getGraphPanel() {

    final VisualizationViewer<String, String> vv = new VisualizationViewer<String, String>(new FRLayout(graph));

    vv.setBackground(Color.white);

    vv.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(vv.getPickedVertexState(), Color.blue, Color.yellow));
    vv.getRenderContext().setVertexLabelTransformer(new Transformer<String, String>() {
        @Override//from w  w  w. j a v a2 s .  co  m
        public String transform(String s) {
            return getClassName(s);
        }
    });
    vv.setVertexToolTipTransformer(new Transformer<String, String>() {
        @Override
        public String transform(String s) {
            return getClassName(s);
        }
    });

    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<String>(vv.getPickedEdgeState(), Color.black, Color.green));
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<String, String>());
    vv.setEdgeToolTipTransformer(new Transformer<String, String>() {
        @Override
        public String transform(String edge) {
            StringBuffer buffer = new StringBuffer();
            buffer.append("<html>");
            int index = edge.indexOf(Main.DELIMITER);
            String fromActor = edge.substring(0, index);
            String toActor = edge.substring(index + Main.DELIMITER.length());
            Map<String, Set<String>> connections = castConnectionList.get(fromActor);
            Set<String> messages = connections.get(toActor);
            for (String msg : messages) {
                buffer.append("<p>").append(getClassName(msg));
            }
            buffer.append("</html>");
            return buffer.toString();
        }
    });
    ToolTipManager.sharedInstance().setDismissDelay(60000);

    final DefaultModalGraphMouse<String, String> graphMouse = new DefaultModalGraphMouse<String, String>();
    graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
    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<String, String> layout = vv.getGraphLayout();
            layout.initialize();
            Relaxer relaxer = vv.getModel().getRelaxer();
            if (relaxer != null) {
                //            if(layout instanceof IterativeContext) {
                relaxer.stop();
                relaxer.prerelax();
                relaxer.relax();
            }
        }
    });

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

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