Example usage for javax.swing JButton getPreferredSize

List of usage examples for javax.swing JButton getPreferredSize

Introduction

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

Prototype

@Transient
public Dimension getPreferredSize() 

Source Link

Document

If the preferredSize has been set to a non-null value just returns it.

Usage

From source file:Main.java

public static void main(String[] args) {
    final JFrame frame = new JFrame(Main.class.getSimpleName());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel btmPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weighty = 1.0;/*from   w ww  .  ja  va  2s.c om*/
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(5, 5, 5, 5);
    gbc.anchor = GridBagConstraints.NORTH;
    JButton comp = new JButton("Panel-1");
    btmPanel.add(comp, gbc);
    JButton comp2 = new JButton("Panel-2");
    btmPanel.add(comp2, gbc);
    JButton comp3 = new JButton("Panel-3");
    comp3.setPreferredSize(new Dimension(comp.getPreferredSize().width, comp.getPreferredSize().height + 10));
    btmPanel.add(comp3, gbc);
    frame.add(btmPanel);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

/**
 * Ensures that all buttons are the same size, and that the chosen size is sufficient to contain the content of any.
 *///from ww w  . j a  v a2  s.c om
public static void tieButtonSizes(List<JButton> buttons) {
    int maxWidth = 0;
    int maxHeight = 0;
    for (JButton button : buttons) {
        Dimension buttonSize = button.getPreferredSize();
        maxWidth = (int) Math.max(buttonSize.getWidth(), maxWidth);
        maxHeight = (int) Math.max(buttonSize.getHeight(), maxHeight);
    }
    Dimension maxButtonSize = new Dimension(maxWidth, maxHeight);
    for (JButton button : buttons) {
        // Seemingly, to get the GTK+ LAF to behave when there are buttons with and without icons, we need to set every size.
        button.setPreferredSize(maxButtonSize);
        button.setMinimumSize(maxButtonSize);
        button.setMaximumSize(maxButtonSize);
        button.setSize(maxButtonSize);
    }
}

From source file:Main.java

/**
 * Sets the JButtons inside a JPanelto be the same size.
 * This is done dynamically by setting each button's preferred and maximum
 * sizes after the buttons are created. This way, the layout automatically
 * adjusts to the locale-specific strings.
 *
 * @param jPanelButtons JPanel containing buttons
 *///from  w  w  w.  j a v a  2  s  .  c  o  m
public static void equalizeButtonSizes(JPanel jPanelButtons) {
    ArrayList<JButton> lbuttons = new ArrayList<JButton>();
    for (int i = 0; i < jPanelButtons.getComponentCount(); i++) {
        Component c = jPanelButtons.getComponent(i);
        if (c instanceof JButton) {
            lbuttons.add((JButton) c);
        }
    }

    // Get the largest width and height
    Dimension maxSize = new Dimension(0, 0);
    for (JButton lbutton : lbuttons) {
        Dimension d = lbutton.getPreferredSize();
        maxSize.width = Math.max(maxSize.width, d.width);
        maxSize.height = Math.max(maxSize.height, d.height);
    }

    for (JButton btn : lbuttons) {
        btn.setPreferredSize(maxSize);
        btn.setMinimumSize(maxSize);
        btn.setMaximumSize(maxSize);
    }
}

From source file:BoxSample.java

private static void tweak(Vector buttons) {
    // calc max preferred width
    JButton button;
    Dimension dim;//  w ww  . j ava 2s. c o m
    int maxWidth = 0;
    Enumeration e = buttons.elements();
    while (e.hasMoreElements()) {
        button = (JButton) e.nextElement();
        dim = button.getPreferredSize();
        if (dim.width > maxWidth)
            maxWidth = dim.width;
    }
    // set max preferred width
    e = buttons.elements();
    while (e.hasMoreElements()) {
        button = (JButton) e.nextElement();
        dim = button.getPreferredSize();
        dim.width = maxWidth;
        button.setPreferredSize(dim);
    }
}

From source file:AbsoluteLayoutDemo.java

public static void addComponentsToPane(Container pane) {
    pane.setLayout(null);// w  w  w  .j av a 2s . co m

    JButton b1 = new JButton("one");
    JButton b2 = new JButton("two");
    JButton b3 = new JButton("three");

    pane.add(b1);
    pane.add(b2);
    pane.add(b3);

    Insets insets = pane.getInsets();
    Dimension size = b1.getPreferredSize();
    b1.setBounds(25 + insets.left, 5 + insets.top, size.width, size.height);
    size = b2.getPreferredSize();
    b2.setBounds(55 + insets.left, 40 + insets.top, size.width, size.height);
    size = b3.getPreferredSize();
    b3.setBounds(150 + insets.left, 15 + insets.top, size.width + 50, size.height + 20);
}

From source file:layout.GridLayoutDemo.java

public void addComponentsToPane(final Container pane) {
    initGaps();//from   www . j  a v a  2s.c  o  m
    final JPanel compsToExperiment = new JPanel();
    compsToExperiment.setLayout(experimentLayout);
    JPanel controls = new JPanel();
    controls.setLayout(new GridLayout(2, 3));

    //Set up components preferred size
    JButton b = new JButton("Just fake button");
    Dimension buttonSize = b.getPreferredSize();
    compsToExperiment.setPreferredSize(new Dimension((int) (buttonSize.getWidth() * 2.5) + maxGap,
            (int) (buttonSize.getHeight() * 3.5) + maxGap * 2));

    //Add buttons to experiment with Grid Layout
    compsToExperiment.add(new JButton("Button 1"));
    compsToExperiment.add(new JButton("Button 2"));
    compsToExperiment.add(new JButton("Button 3"));
    compsToExperiment.add(new JButton("Long-Named Button 4"));
    compsToExperiment.add(new JButton("5"));

    //Add controls to set up horizontal and vertical gaps
    controls.add(new Label("Horizontal gap:"));
    controls.add(new Label("Vertical gap:"));
    controls.add(new Label(" "));
    controls.add(horGapComboBox);
    controls.add(verGapComboBox);
    controls.add(applyButton);

    //Process the Apply gaps button press
    applyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //Get the horizontal gap value
            String horGap = (String) horGapComboBox.getSelectedItem();
            //Get the vertical gap value
            String verGap = (String) verGapComboBox.getSelectedItem();
            //Set up the horizontal gap value
            experimentLayout.setHgap(Integer.parseInt(horGap));
            //Set up the vertical gap value
            experimentLayout.setVgap(Integer.parseInt(verGap));
            //Set up the layout of the buttons
            experimentLayout.layoutContainer(compsToExperiment);
        }
    });
    pane.add(compsToExperiment, BorderLayout.NORTH);
    pane.add(new JSeparator(), BorderLayout.CENTER);
    pane.add(controls, BorderLayout.SOUTH);
}

From source file:net.pandoragames.far.ui.swing.FindAndReplace.java

/**
 * User preferences.// w  w w  . ja v  a2  s.c o  m
 */
private void configure() {
    logger.debug("Configuration...");
    try {
        config = new SwingConfig();
        configFactory = new FARConfigurationFactory();
        configFactory.loadConfig(config);
        // localizer
        File localizerProperties = new File(
                this.getClass().getClassLoader().getResource("fartext.properties").toURI());
        Localizer loco = new DefaultLocalizer(localizerProperties, Locale.ENGLISH);
        JComponent.setDefaultLocale(loco.getLocale());
        config.setLocalizer(loco);
    } catch (Exception x) {
        logger.error(x.getClass().getName() + ": " + x.getMessage(), x);
        throw new ConfigurationException(x.getClass().getName() + ": " + x.getMessage());
    }

    // standard component hight
    JButton testButton = new JButton("TEST");
    config.setStandardComponentHight(testButton.getPreferredSize().height);

    // screen center
    Rectangle screen = getGraphicsConfiguration().getBounds();
    config.setScreenCenter(new Point((screen.width - screen.x) / 2, (screen.height - screen.y) / 2));

}

From source file:cool.pandora.modeller.ui.jpanel.base.BagInfoForm.java

private void createFormFieldsFromMap(final BagTableFormBuilder formBuilder) {
    int rowCount = 0;
    final int index = 2;

    final Set<String> keys = fieldMap.keySet();
    for (final BagInfoField field : fieldMap.values()) {
        formBuilder.row();/*from  ww  w  . j  a va  2s. c  o m*/
        rowCount++;
        final ImageIcon imageIcon = bagView.getPropertyImage("bag.delete.image");
        JButton removeButton = new JButton(imageIcon);
        final Dimension dimension = removeButton.getPreferredSize();
        dimension.width = imageIcon.getIconWidth();
        removeButton.setMaximumSize(dimension);
        removeButton.setOpaque(false);
        removeButton.setBorderPainted(false);
        removeButton.setContentAreaFilled(false);
        removeButton.addActionListener(new RemoveFieldHandler());
        logger.debug("OrganizationInfoForm add: " + field);
        if (field.getValue() != null && field.getValue().length() > 60) {
            field.setComponentType(BagInfoField.TEXTAREA_COMPONENT);
        }
        if (field.isRequired()) {
            removeButton = new JButton();
            removeButton.setOpaque(false);
            removeButton.setBorderPainted(false);
            removeButton.setContentAreaFilled(false);
        }
        switch (field.getComponentType()) {
        case BagInfoField.TEXTAREA_COMPONENT:
            final JComponent[] tlist = formBuilder.addTextArea(field.isRequired(), field.getLabel(),
                    removeButton);
            final JComponent textarea = tlist[index];
            textarea.setEnabled(field.isEnabled());
            textarea.addFocusListener(this);
            ((NoTabTextArea) textarea).setText(field.getValue());
            textarea.setBorder(new EmptyBorder(1, 1, 1, 1));
            ((NoTabTextArea) textarea).setLineWrap(true);
            if (rowCount == 1) {
                focusField = textarea;
            }
            break;
        case BagInfoField.TEXTFIELD_COMPONENT:
            final JComponent[] flist = formBuilder.add(field.isRequired(), field.getLabel(), removeButton);
            final JComponent comp = flist[index];
            comp.setEnabled(field.isEnabled());
            comp.addFocusListener(this);
            ((JTextField) comp).setText(field.getValue());
            if (rowCount == 1) {
                focusField = comp;
            }
            break;
        case BagInfoField.LIST_COMPONENT:
            final List<String> elements = field.getElements();
            final JComponent[] llist = formBuilder.addList(field.isRequired(), field.getLabel(), elements,
                    field.getValue(), removeButton);
            final JComponent lcomp = llist[index];
            lcomp.setEnabled(field.isEnabled());
            lcomp.addFocusListener(this);
            if (field.getValue() != null) {
                ((JComboBox<?>) lcomp).setSelectedItem(field.getValue().trim());
            }
            if (rowCount == 1) {
                focusField = lcomp;
            }
            break;
        default:
        }
    }
    if (focusField != null) {
        focusField.requestFocus();
    }

}

From source file:com.willwinder.universalgcodesender.uielements.macros.MacroActionPanel.java

@Override
public void doLayout() {
    Settings s = backend.getSettings();//from   w  w w .j  a  v a2  s . c  om

    // Lookup macros.
    if (macrosDirty) {
        Integer lastMacroIndex = s.getLastMacroIndex() + 1;
        macros.clear();
        for (int i = 0; i < lastMacroIndex; i++) {
            Macro m = s.getMacro(i);
            if (StringUtils.isNotEmpty(m.getGcode())) {
                macros.add(s.getMacro(i));
            }
        }
    }

    // Cache the largest width amongst the buttons.
    int maxWidth = 0;
    int maxHeight = 0;

    // Create buttons.
    for (int i = 0; i < macros.size(); i++) {
        final int index = i;
        Macro macro = macros.get(i);
        JButton button;
        if (customGcodeButtons.size() <= i) {
            button = new JButton(i + "");
            button.setEnabled(false);
            customGcodeButtons.add(button);
            // Add action listener
            button.addActionListener((ActionEvent evt) -> {
                customGcodeButtonActionPerformed(index);
            });
        } else {
            button = customGcodeButtons.get(i);
        }

        if (!StringUtils.isEmpty(macro.getName())) {
            button.setText(macro.getName());
        } else if (!StringUtils.isEmpty(macro.getDescription())) {
            button.setText(macro.getDescription());
        }

        if (!StringUtils.isEmpty(macro.getDescription())) {
            button.setToolTipText(macro.getDescription());
        }

        if (button.getPreferredSize().width > maxWidth)
            maxWidth = button.getPreferredSize().width;
        if (button.getPreferredSize().height > maxHeight)
            maxHeight = button.getPreferredSize().height;
    }

    // If button count was reduced, clear out any extras.
    if (customGcodeButtons.size() > macros.size()) {
        this.macroPanel.removeAll();
        this.macroPanel.repaint();
        for (int i = customGcodeButtons.size(); i > macros.size(); i--) {
            JButton b = customGcodeButtons.remove(i - 1);
        }
    }

    // Calculate columns/rows which can fit in the space we have.
    int columns = (getWidth() - (2 * INSET)) / (maxWidth + PADDING);
    int rows = (getHeight() - (2 * INSET)) / (maxHeight + PADDING);

    // At least one column.
    columns = Math.max(columns, 1);

    // Update number of rows if more are needed.
    if (columns * rows < customGcodeButtons.size()) {
        rows = customGcodeButtons.size() / columns;
        if (customGcodeButtons.size() % columns != 0)
            rows++;
    }

    // Layout for buttons.
    StringBuilder columnConstraint = new StringBuilder();
    for (int i = 0; i < columns; i++) {
        if (i > 0) {
            columnConstraint.append("unrelated");
        }
        columnConstraint.append("[fill, sg 1]");
    }
    MigLayout layout = new MigLayout("fillx, wrap " + columns + ", inset " + INSET,
            columnConstraint.toString());
    macroPanel.setLayout(layout);

    // Put buttons in grid.
    int x = 0;
    int y = 0;
    for (JButton button : customGcodeButtons) {
        macroPanel.add(button, "cell " + x + " " + y);
        y++;
        if (y == rows) {
            x++;
            y = 0;
        }
    }

    super.doLayout();
}

From source file:ffx.ui.ModelingPanel.java

private void loadCommand() {
    synchronized (this) {
        // Force Field X Command
        Element command;//from   w ww .  j  av  a  2 s . c o  m
        // Command Options
        NodeList options;
        Element option;
        // Option Values
        NodeList values;
        Element value;
        // Options may be Conditional based on previous Option values (not
        // always supplied)
        NodeList conditionalList;
        Element conditional;
        // JobPanel GUI Components that change based on command
        JPanel optionPanel;
        // Clear the previous components
        commandPanel.removeAll();
        optionsTabbedPane.removeAll();
        conditionals.clear();
        String currentCommand = (String) currentCommandBox.getSelectedItem();
        if (currentCommand == null) {
            commandPanel.validate();
            commandPanel.repaint();
            return;
        }
        command = null;
        for (int i = 0; i < commandList.getLength(); i++) {
            command = (Element) commandList.item(i);
            String name = command.getAttribute("name");
            if (name.equalsIgnoreCase(currentCommand)) {
                break;
            }
        }
        int div = splitPane.getDividerLocation();
        descriptTextArea.setText(currentCommand.toUpperCase() + ": " + command.getAttribute("description"));
        splitPane.setBottomComponent(descriptScrollPane);
        splitPane.setDividerLocation(div);
        // The "action" tells Force Field X what to do when the
        // command finishes
        commandActions = command.getAttribute("action").trim();
        // The "fileType" specifies what file types this command can execute
        // on
        String string = command.getAttribute("fileType").trim();
        String[] types = string.split(" +");
        commandFileTypes.clear();
        for (String type : types) {
            if (type.contains("XYZ")) {
                commandFileTypes.add(FileType.XYZ);
            }
            if (type.contains("INT")) {
                commandFileTypes.add(FileType.INT);
            }
            if (type.contains("ARC")) {
                commandFileTypes.add(FileType.ARC);
            }
            if (type.contains("PDB")) {
                commandFileTypes.add(FileType.PDB);
            }
            if (type.contains("ANY")) {
                commandFileTypes.add(FileType.ANY);
            }
        }
        // Determine what options are available for this command
        options = command.getElementsByTagName("Option");
        int length = options.getLength();
        for (int i = 0; i < length; i++) {
            // This Option will be enabled (isEnabled = true) unless a
            // Conditional disables it
            boolean isEnabled = true;
            option = (Element) options.item(i);
            conditionalList = option.getElementsByTagName("Conditional");
            /*
             * Currently, there can only be 0 or 1 Conditionals per Option
             * There are three types of Conditionals implemented. 1.)
             * Conditional on a previous Option, this option may be
             * available 2.) Conditional on input for this option, a
             * sub-option may be available 3.) Conditional on the presence
             * of keywords, this option may be available
             */
            if (conditionalList != null) {
                conditional = (Element) conditionalList.item(0);
            } else {
                conditional = null;
            }
            // Get the command line flag
            String flag = option.getAttribute("flag").trim();
            // Get the description
            String optionDescript = option.getAttribute("description");
            JTextArea optionTextArea = new JTextArea("  " + optionDescript.trim());
            optionTextArea.setEditable(false);
            optionTextArea.setLineWrap(true);
            optionTextArea.setWrapStyleWord(true);
            optionTextArea.setBorder(etchedBorder);
            // Get the default for this Option (if one exists)
            String defaultOption = option.getAttribute("default");
            // Option Panel
            optionPanel = new JPanel(new BorderLayout());
            optionPanel.add(optionTextArea, BorderLayout.NORTH);
            String swing = option.getAttribute("gui");
            JPanel optionValuesPanel = new JPanel(new FlowLayout());
            optionValuesPanel.setBorder(etchedBorder);
            ButtonGroup bg = null;
            if (swing.equalsIgnoreCase("CHECKBOXES")) {
                // CHECKBOXES allows selection of 1 or more values from a
                // predefined set (Analyze, for example)
                values = option.getElementsByTagName("Value");
                for (int j = 0; j < values.getLength(); j++) {
                    value = (Element) values.item(j);
                    JCheckBox jcb = new JCheckBox(value.getAttribute("name"));
                    jcb.addMouseListener(this);
                    jcb.setName(flag);
                    if (defaultOption != null && jcb.getActionCommand().equalsIgnoreCase(defaultOption)) {
                        jcb.setSelected(true);
                    }
                    optionValuesPanel.add(jcb);
                }
            } else if (swing.equalsIgnoreCase("TEXTFIELD")) {
                // TEXTFIELD takes an arbitrary String as input
                JTextField jtf = new JTextField(20);
                jtf.addMouseListener(this);
                jtf.setName(flag);
                if (defaultOption != null && defaultOption.equals("ATOMS")) {
                    FFXSystem sys = mainPanel.getHierarchy().getActive();
                    if (sys != null) {
                        jtf.setText("" + sys.getAtomList().size());
                    }
                } else if (defaultOption != null) {
                    jtf.setText(defaultOption);
                }
                optionValuesPanel.add(jtf);
            } else if (swing.equalsIgnoreCase("RADIOBUTTONS")) {
                // RADIOBUTTONS allows one choice from a set of predifined
                // values
                bg = new ButtonGroup();
                values = option.getElementsByTagName("Value");
                for (int j = 0; j < values.getLength(); j++) {
                    value = (Element) values.item(j);
                    JRadioButton jrb = new JRadioButton(value.getAttribute("name"));
                    jrb.addMouseListener(this);
                    jrb.setName(flag);
                    bg.add(jrb);
                    if (defaultOption != null && jrb.getActionCommand().equalsIgnoreCase(defaultOption)) {
                        jrb.setSelected(true);
                    }
                    optionValuesPanel.add(jrb);
                }
            } else if (swing.equalsIgnoreCase("PROTEIN")) {
                // Protein allows selection of amino acids for the protein
                // builder
                optionValuesPanel.setLayout(new BoxLayout(optionValuesPanel, BoxLayout.Y_AXIS));
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                optionValuesPanel.add(getAminoAcidPanel());
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                acidComboBox.removeAllItems();
                JButton add = new JButton("Edit");
                add.setActionCommand("PROTEIN");
                add.addActionListener(this);
                add.setAlignmentX(Button.CENTER_ALIGNMENT);
                JPanel comboPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
                comboPanel.add(acidTextField);
                comboPanel.add(add);
                optionValuesPanel.add(comboPanel);
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                JButton remove = new JButton("Remove");
                add.setMinimumSize(remove.getPreferredSize());
                add.setPreferredSize(remove.getPreferredSize());
                remove.setActionCommand("PROTEIN");
                remove.addActionListener(this);
                remove.setAlignmentX(Button.CENTER_ALIGNMENT);
                comboPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
                comboPanel.add(acidComboBox);
                comboPanel.add(remove);
                optionValuesPanel.add(comboPanel);
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                optionValuesPanel.add(acidScrollPane);
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                JButton reset = new JButton("Reset");
                reset.setActionCommand("PROTEIN");
                reset.addActionListener(this);
                reset.setAlignmentX(Button.CENTER_ALIGNMENT);
                optionValuesPanel.add(reset);
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                acidTextArea.setText("");
                acidTextField.setText("");
            } else if (swing.equalsIgnoreCase("NUCLEIC")) {
                // Nucleic allows selection of nucleic acids for the nucleic
                // acid builder
                optionValuesPanel.setLayout(new BoxLayout(optionValuesPanel, BoxLayout.Y_AXIS));
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                optionValuesPanel.add(getNucleicAcidPanel());
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                acidComboBox.removeAllItems();
                JButton add = new JButton("Edit");
                add.setActionCommand("NUCLEIC");
                add.addActionListener(this);
                add.setAlignmentX(Button.CENTER_ALIGNMENT);
                JPanel comboPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
                comboPanel.add(acidTextField);
                comboPanel.add(add);
                optionValuesPanel.add(comboPanel);
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                JButton remove = new JButton("Remove");
                add.setMinimumSize(remove.getPreferredSize());
                add.setPreferredSize(remove.getPreferredSize());
                remove.setActionCommand("NUCLEIC");
                remove.addActionListener(this);
                remove.setAlignmentX(Button.CENTER_ALIGNMENT);
                comboPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
                comboPanel.add(acidComboBox);
                comboPanel.add(remove);
                optionValuesPanel.add(comboPanel);
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                optionValuesPanel.add(acidScrollPane);
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                JButton button = new JButton("Reset");
                button.setActionCommand("NUCLEIC");
                button.addActionListener(this);
                button.setAlignmentX(Button.CENTER_ALIGNMENT);
                optionValuesPanel.add(button);
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                acidTextArea.setText("");
                acidTextField.setText("");
            } else if (swing.equalsIgnoreCase("SYSTEMS")) {
                // SYSTEMS allows selection of an open system
                JComboBox<FFXSystem> jcb = new JComboBox<>(mainPanel.getHierarchy().getNonActiveSystems());
                jcb.setSize(jcb.getMaximumSize());
                jcb.addActionListener(this);
                optionValuesPanel.add(jcb);
            }
            // Set up a Conditional for this Option
            if (conditional != null) {
                isEnabled = false;
                String conditionalName = conditional.getAttribute("name");
                String conditionalValues = conditional.getAttribute("value");
                String cDescription = conditional.getAttribute("description");
                String cpostProcess = conditional.getAttribute("postProcess");
                if (conditionalName.toUpperCase().startsWith("KEYWORD")) {
                    optionPanel.setName(conditionalName);
                    String keywords[] = conditionalValues.split(" +");
                    if (activeSystem != null) {
                        Hashtable<String, Keyword> systemKeywords = activeSystem.getKeywords();
                        for (String key : keywords) {
                            if (systemKeywords.containsKey(key.toUpperCase())) {
                                isEnabled = true;
                            }
                        }
                    }
                } else if (conditionalName.toUpperCase().startsWith("VALUE")) {
                    isEnabled = true;
                    // Add listeners to the values of this option so
                    // the conditional options can be disabled/enabled.
                    for (int j = 0; j < optionValuesPanel.getComponentCount(); j++) {
                        JToggleButton jtb = (JToggleButton) optionValuesPanel.getComponent(j);
                        jtb.addActionListener(this);
                        jtb.setActionCommand("Conditional");
                    }
                    JPanel condpanel = new JPanel();
                    condpanel.setBorder(etchedBorder);
                    JLabel condlabel = new JLabel(cDescription);
                    condlabel.setEnabled(false);
                    condlabel.setName(conditionalValues);
                    JTextField condtext = new JTextField(10);
                    condlabel.setLabelFor(condtext);
                    if (cpostProcess != null) {
                        condtext.setName(cpostProcess);
                    }
                    condtext.setEnabled(false);
                    condpanel.add(condlabel);
                    condpanel.add(condtext);
                    conditionals.add(condlabel);
                    optionPanel.add(condpanel, BorderLayout.SOUTH);
                } else if (conditionalName.toUpperCase().startsWith("REFLECTION")) {
                    String[] condModifiers;
                    if (conditionalValues.equalsIgnoreCase("AltLoc")) {
                        condModifiers = activeSystem.getAltLocations();
                        if (condModifiers != null && condModifiers.length > 1) {
                            isEnabled = true;
                            bg = new ButtonGroup();
                            for (int j = 0; j < condModifiers.length; j++) {
                                JRadioButton jrbmi = new JRadioButton(condModifiers[j]);
                                jrbmi.addMouseListener(this);
                                bg.add(jrbmi);
                                optionValuesPanel.add(jrbmi);
                                if (j == 0) {
                                    jrbmi.setSelected(true);
                                }
                            }
                        }
                    } else if (conditionalValues.equalsIgnoreCase("Chains")) {
                        condModifiers = activeSystem.getChainNames();
                        if (condModifiers != null && condModifiers.length > 0) {
                            isEnabled = true;
                            for (int j = 0; j < condModifiers.length; j++) {
                                JRadioButton jrbmi = new JRadioButton(condModifiers[j]);
                                jrbmi.addMouseListener(this);
                                bg.add(jrbmi);
                                optionValuesPanel.add(jrbmi, j);
                            }
                        }
                    }
                }
            }
            optionPanel.add(optionValuesPanel, BorderLayout.CENTER);
            optionPanel.setPreferredSize(optionPanel.getPreferredSize());
            optionsTabbedPane.addTab(option.getAttribute("name"), optionPanel);
            optionsTabbedPane.setEnabledAt(optionsTabbedPane.getTabCount() - 1, isEnabled);
        }
    }
    optionsTabbedPane.setPreferredSize(optionsTabbedPane.getPreferredSize());
    commandPanel.setLayout(borderLayout);
    commandPanel.add(optionsTabbedPane, BorderLayout.CENTER);
    commandPanel.validate();
    commandPanel.repaint();
    loadLogSettings();
    statusLabel.setText("  " + createCommandInput());
}