Example usage for java.awt FlowLayout CENTER

List of usage examples for java.awt FlowLayout CENTER

Introduction

In this page you can find the example usage for java.awt FlowLayout CENTER.

Prototype

int CENTER

To view the source code for java.awt FlowLayout CENTER.

Click Source Link

Document

This value indicates that each row of components should be centered.

Usage

From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java

/**
 * Adds the specified {@link JComponent} to a {@link JPanel} 
 * with a right flow layout.//from   w  ww  .  jav a  2 s .co m
 * 
 * @param component The component to add.
 *  @param hgap       The horizontal gap between components and between the 
 *                components and the borders of the 
 *                <code>Container</code>.
 * @param vgap       The vertical gap between components and between the 
 *                components and the borders of the 
 *                <code>Container</code>.
 * @return See below.
 */
public static JPanel buildComponentPanelCenter(JComponent component, int hgap, int vgap) {
    JPanel p = new JPanel();
    if (component == null)
        return p;
    if (hgap < 0)
        hgap = 0;
    if (vgap < 0)
        vgap = 0;
    p.setLayout(new FlowLayout(FlowLayout.CENTER, hgap, vgap));
    p.add(component);
    return p;
}

From source file:it.iit.genomics.cru.igb.bundles.mi.business.MIWorker.java

/**
 * Adds a component to a JTabbedPane with a little close tab" button on the
 * right side of the tab./* w  ww.  j  av a 2s  .  c o  m*/
 *
 * @param tabbedPane
 *            the JTabbedPane
 * @param c
 *            any JComponent
 * @param title
 *            the title for the tab
 */
public static void addClosableTab(final JTabbedPane tabbedPane, final JComponent c, final String title) {
    // Add the tab to the pane without any label
    tabbedPane.addTab(null, c);
    int pos = tabbedPane.indexOfComponent(c);

    // Create a FlowLayout that will space things 5px apart
    FlowLayout f = new FlowLayout(FlowLayout.CENTER, 5, 0);

    // Make a small JPanel with the layout and make it non-opaque
    JPanel pnlTab = new JPanel(f);
    pnlTab.setOpaque(false);

    // Add a JLabel with title and the left-side tab icon
    JLabel lblTitle = new JLabel(title);

    // Create a JButton for the close tab button
    JButton btnClose = new JButton("x");
    // btnClose.setOpaque(false);
    int size = 17;
    btnClose.setPreferredSize(new Dimension(size, size));
    btnClose.setToolTipText("close this tab");
    // Make the button looks the same for all Laf's
    btnClose.setUI(new BasicButtonUI());
    // Make it transparent
    btnClose.setContentAreaFilled(false);
    // No need to be focusable
    btnClose.setFocusable(false);
    btnClose.setBorder(BorderFactory.createEtchedBorder());
    btnClose.setBorderPainted(false);
    // Making nice rollover effect
    // we use the same listener for all buttons
    btnClose.setRolloverEnabled(true);
    // Close the proper tab by clicking the button

    // Configure icon and rollover icon for button
    btnClose.setRolloverEnabled(true);

    // Set border null so the button doesnt make the tab too big
    btnClose.setBorder(null);
    // Make sure the button cant get focus, otherwise it looks funny
    btnClose.setFocusable(false);

    // Put the panel together
    pnlTab.add(lblTitle);
    pnlTab.add(btnClose);

    // Add a thin border to keep the image below the top edge of the tab
    // when the tab is selected
    pnlTab.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
    // Now assign the component for the tab
    tabbedPane.setTabComponentAt(pos, pnlTab);

    // Add the listener that removes the tab
    ActionListener listener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (JOptionPane.showConfirmDialog(new JFrame(),
                    "Are you sure you want to remove this tab? All results will be lost!", "Remove tab",
                    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                tabbedPane.remove(c);
            }
        }
    };
    btnClose.addActionListener(listener);

    // Optionally bring the new tab to the front
    tabbedPane.setSelectedComponent(c);

}

From source file:us.daveread.basicquery.BasicQuery.java

/**
 * Builds the GUI for the application//from w  w w  . j a  v a 2  s . c om
 */
private void setup() {
    JPanel panel;
    JPanel gridPanel;
    JPanel outerPanel;
    JPanel flowPanel;
    JPanel boxedPanel;
    ButtonGroup bGroup;
    MaxHeightJScrollPane maxHeightJScrollPane;

    setupComponents();

    getContentPane().setLayout(new BorderLayout());

    // table.getTableHeader().setFont(new Font(table.getTableHeader().getFont().
    // getName(), table.getTableHeader().getFont().getStyle(),
    // MessageStyleFactory.instance().getFontSize()));
    getContentPane().add(new JScrollPane(table), BorderLayout.CENTER);

    panel = new JPanel();
    panel.setLayout(new BorderLayout());

    outerPanel = new JPanel();
    outerPanel.setLayout(new BorderLayout());

    gridPanel = new JPanel();
    gridPanel.setLayout(new GridLayout(0, 1));

    gridPanel.add(connectString = new JComboBox());
    connectString.setEditable(true);
    gridPanel.add(querySelection = new JComboBox());
    querySelection.setEditable(false);
    querySelection.addActionListener(this);
    outerPanel.add(gridPanel, BorderLayout.NORTH);

    outerPanel.add(new JScrollPane(queryText = new JTextArea(QUERY_AREA_ROWS, QUERY_AREA_COLUMNS)),
            BorderLayout.SOUTH);
    queryText.setLineWrap(true);
    queryText.setWrapStyleWord(true);
    queryText.addKeyListener(this);

    panel.add(outerPanel, BorderLayout.CENTER);

    outerPanel = new JPanel();
    outerPanel.setLayout(new BorderLayout());

    boxedPanel = new JPanel();
    boxedPanel.setLayout(new GridLayout(0, 2));
    boxedPanel.add(new JLabel(Resources.getString("proUserId")));
    boxedPanel.add(userId = new JTextField(10));
    boxedPanel.add(new JLabel(Resources.getString("proPassword")));
    boxedPanel.add(password = new JPasswordField(10));
    outerPanel.add(boxedPanel, BorderLayout.WEST);

    // Prev/Next and the checkboxes are all on the flowPanel - Center of
    // outerPanel
    flowPanel = new JPanel();
    flowPanel.setLayout(new FlowLayout(FlowLayout.CENTER));

    // Previous/Next buttons
    boxedPanel = new JPanel();
    boxedPanel.setLayout(new FlowLayout());
    boxedPanel.add(previousQuery = new JButton(Resources.getString("ctlPrev"),
            new ImageIcon(ImageUtility.getImageAsByteArray("ArrowLeftGreen.gif"))));
    previousQuery.setToolTipText(Resources.getString("tipPrev"));
    previousQuery.addActionListener(this);
    boxedPanel.add(nextQuery = new JButton(Resources.getString("ctlNext"),
            new ImageIcon(ImageUtility.getImageAsByteArray("ArrowRightGreen.gif"))));
    nextQuery.setToolTipText(Resources.getString("tipNext"));
    nextQuery.addActionListener(this);
    flowPanel.add(boxedPanel);

    // Checkboxes: Autocommit, Read Only and Pooling
    boxedPanel = new JPanel();
    boxedPanel.setLayout(new FlowLayout());
    boxedPanel.setBorder(getStandardBorder());
    boxedPanel.add(autoCommit = new JCheckBox(Resources.getString("ctlAutoCommit"), true));
    boxedPanel.add(readOnly = new JCheckBox(Resources.getString("ctlReadOnly"), false));
    boxedPanel.add(poolConnect = new JCheckBox(Resources.getString("ctlConnPool"), false));
    poolConnect.setEnabled(false);
    flowPanel.add(boxedPanel);
    outerPanel.add(flowPanel, BorderLayout.CENTER);

    boxedPanel = new JPanel();
    boxedPanel.setLayout(new GridLayout(0, 1));
    boxedPanel.setBorder(getStandardBorder());
    boxedPanel.add(runIndicator = new JLabel(Resources.getString("ctlRunning"), JLabel.CENTER));
    runIndicator.setForeground(Color.lightGray);
    boxedPanel.add(timeIndicator = new JLabel("", JLabel.RIGHT));
    outerPanel.add(boxedPanel, BorderLayout.EAST);

    panel.add(outerPanel, BorderLayout.NORTH);

    flowPanel = new JPanel();
    flowPanel.setLayout(new FlowLayout(FlowLayout.LEFT));

    boxedPanel = new JPanel();
    boxedPanel.setLayout(new FlowLayout());
    boxedPanel.setBorder(getStandardBorder());
    boxedPanel.add(new JLabel(Resources.getString("proQueryType")));
    boxedPanel.add(asQuery = new JRadioButton(Resources.getString("ctlSelect"), true));
    boxedPanel.add(asUpdate = new JRadioButton(Resources.getString("ctlUpdate")));
    boxedPanel.add(asDescribe = new JRadioButton(Resources.getString("ctlDescribe")));
    bGroup = new ButtonGroup();
    bGroup.add(asQuery);
    bGroup.add(asUpdate);
    bGroup.add(asDescribe);
    asQuery.addActionListener(this);
    asUpdate.addActionListener(this);
    asDescribe.addActionListener(this);
    flowPanel.add(boxedPanel);

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

    boxedPanel = new JPanel();
    boxedPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    boxedPanel.setBorder(getStandardBorder());
    boxedPanel.add(new JLabel(Resources.getString("proMaxRows")));
    boxedPanel.add(maxRows);
    flowPanel.add(boxedPanel);

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

    flowPanel.add(execute = new JButton(Resources.getString("ctlExecute")));
    execute.addActionListener(this);
    flowPanel.add(remove = new JButton(Resources.getString("ctlRemove")));
    remove.addActionListener(this);
    flowPanel.add(commentToggle = new JButton(Resources.getString("ctlComment")));
    commentToggle.addActionListener(this);
    flowPanel.add(nextInList = new JButton(Resources.getString("ctlDown")));
    nextInList.addActionListener(this);

    panel.add(flowPanel, BorderLayout.SOUTH);

    getContentPane().add(panel, BorderLayout.NORTH);
    getRootPane().setDefaultButton(execute);

    messageDocument = new DefaultStyledDocument();
    getContentPane().add(
            maxHeightJScrollPane = new MaxHeightJScrollPane(message = new JTextPane(messageDocument)),
            BorderLayout.SOUTH);
    message.setEditable(false);

    loadedDBDriver = false;

    loadMenu();

    setupTextStyles();
    loadProperties();
    setupUserDefinedColoring();
    setupResultsTableColoring();
    loadConfig();
    loadConnectStrings();
    loadQueries();

    loadDrivers();

    // Check for avail of pool - enable/disable pooling option as appropriate
    // Not really useful until we get the pooling classes out of this code
    try {
        new GenericObjectPool(null);
        poolConnect.setEnabled(true);
        poolConnect.setSelected(true);
    } catch (Throwable any) {
        // No Apache Commons DB Pooling Library Found (DBCP)
        LOGGER.error(Resources.getString("errNoPoolLib"), any);
    }

    setDefaults();

    maxHeightJScrollPane.lockHeight(getHeight() / MAX_SCROLL_PANE_DIVISOR_FOR_MAX_HEIGHT);

    // Font
    setFontFromConfig(Configuration.instance());

    setVisible(true);
}

From source file:com.pironet.tda.TDA.java

private void displayTable(HistogramTableModel htm) {
    setThreadDisplay(false);//from   w  w  w  .  ja v a 2s. co  m

    htm.setFilter("");
    htm.setShowHotspotClasses(PrefManager.get().getShowHotspotClasses());

    TableSorter ts = new TableSorter(htm);
    histogramTable = new JTable(ts);
    ts.setTableHeader(histogramTable.getTableHeader());
    histogramTable.getColumnModel().getColumn(0).setPreferredWidth(700);
    final ViewScrollPane tableView = new ViewScrollPane(histogramTable, runningAsVisualVMPlugin);

    JPanel histogramView = new JPanel(new BorderLayout());
    JPanel histoStatView = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 0));

    JLabel infoLabel = new JLabel(
            NumberFormat.getInstance().format(htm.getRowCount()) + " classes and base types");
    infoLabel.setFont(SANS_SERIF);
    histoStatView.add(infoLabel);
    infoLabel = new JLabel(NumberFormat.getInstance().format(htm.getBytes()) + " bytes");
    infoLabel.setFont(SANS_SERIF);
    histoStatView.add(infoLabel);
    infoLabel = new JLabel(NumberFormat.getInstance().format(htm.getInstances()) + " live objects");
    infoLabel.setFont(SANS_SERIF);
    histoStatView.add(infoLabel);
    if (htm.isOOM()) {
        infoLabel = new JLabel("<html><b>OutOfMemory found!</b>");
        infoLabel.setFont(SANS_SERIF);
        histoStatView.add(infoLabel);
    }
    if (htm.isIncomplete()) {
        infoLabel = new JLabel("<html><b>Class Histogram is incomplete! (broken logfile?)</b>");
        infoLabel.setFont(SANS_SERIF);
        histoStatView.add(infoLabel);
    }
    JPanel filterPanel = new JPanel(new FlowLayout());
    infoLabel = new JLabel("Filter-Expression");
    infoLabel.setFont(SANS_SERIF);
    filterPanel.add(infoLabel);

    filter = new JTextField(30);
    filter.setFont(SANS_SERIF);
    filter.addCaretListener(new FilterListener(htm));
    filterPanel.add(infoLabel);
    filterPanel.add(filter);
    checkCase = new JCheckBox();
    checkCase.addChangeListener(new CheckCaseListener(htm));
    infoLabel = new JLabel("Ignore Case");
    infoLabel.setFont(SANS_SERIF);
    filterPanel.add(infoLabel);
    filterPanel.add(checkCase);
    histoStatView.add(filterPanel);
    histogramView.add(histoStatView, BorderLayout.SOUTH);
    histogramView.add(tableView, BorderLayout.CENTER);

    histogramView.setPreferredSize(splitPane.getBottomComponent().getSize());

    splitPane.setBottomComponent(histogramView);
}

From source file:ffx.ui.ModelingPanel.java

private void loadCommand() {
    synchronized (this) {
        // Force Field X Command
        Element command;//from  w  w  w .jav  a  2 s  .co 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());
}

From source file:com.nikonhacker.gui.EmulatorUI.java

private void showAboutDialog() {
    // for copying style
    JLabel label = new JLabel();
    Font font = label.getFont();/* w  w  w. j a va2s .  c  om*/

    // create some css from the label's font
    String style = "font-family:" + font.getFamily() + ";" + "font-weight:"
            + (font.isBold() ? "bold" : "normal") + ";" + "font-size:" + font.getSize() + "pt;";

    // html content
    JEditorPane editorPane = new JEditorPane("text/html", "<html><body style=\"" + style + "\">"
            + "<font size=\"+1\">" + ApplicationInfo.getNameVersion() + "</font><br/>"
            + "<i>A dual (Fujitsu FR + Toshiba TX) microcontroller emulator in Java, aimed at mimicking the behaviour of Nikon DSLRs</i><br/>"
            + "<font size=\"-2\">Built on " + ApplicationInfo.getBuildTime() + "</font><br/><br/>"
            + "This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.<br/>"
            + "This software is provided under the GNU General Public License, version 3 - "
            + makeLink("http://www.gnu.org/licenses/gpl-3.0.txt") + "<br/>"
            + "This software is based on, or makes use of, the following works:<ul>\n"
            + "<li>Simeon Pilgrim's deciphering of firmware encoding and lots of information shared on his blog - "
            + makeLink("http://simeonpilgrim.com/blog/") + "</li>"
            + "<li>Dfr Fujitsu FR diassembler Copyright (c) Kevin Schoedel - "
            + makeLink("http://scratchpad.wikia.com/wiki/Disassemblers/DFR")
            + "<br/>and its port to C# by Simeon Pilgrim</li>"
            + "<li>\"How To Write a Computer Emulator\" article by Marat Fayzullin - "
            + makeLink("http://fms.komkon.org/EMUL8/HOWTO.html") + "</li>"
            + "<li>The PearColator x86 emulator project - "
            + makeLink("http://apt.cs.man.ac.uk/projects/jamaica/tools/PearColator/") + "</li>"
            + "<li>The Jacksum checksum library Copyright (c) Dipl.-Inf. (FH) Johann Nepomuk Lfflmann  - "
            + makeLink("http://www.jonelo.de/java/jacksum/") + "</li>"
            + "<li>HexEditor & RSyntaxTextArea swing components, Copyright (c) Robert Futrell - "
            + makeLink("http://fifesoft.com/hexeditor/") + "</li>"
            + "<li>JGraphX graph drawing library, Copyright (c) JGraph Ltd - "
            + makeLink("http://www.jgraph.com/jgraph.html") + "</li>"
            + "<li>Apache commons libraries, Copyright (c) The Apache Software Foundation - "
            + makeLink("http://commons.apache.org/") + "</li>"
            + "<li>VerticalLayout, Copyright (c) Cellspark - " + makeLink("http://www.cellspark.com/vl.html")
            + "</li>" + "<li>MigLayout, Copyright (c) MigInfoCom - " + makeLink("http://www.miginfocom.com/")
            + "</li>" + "<li>Glazed Lists, Copyright (c) 2003-2006, publicobject.com, O'Dell Engineering Ltd - "
            + makeLink("http://www.glazedlists.com/") + "</li>"
            + "<li>Samples from the Java Tutorial (c) Sun Microsystems / Oracle - "
            + makeLink("http://docs.oracle.com/javase/tutorial") + "</li>"
            + "<li>MARS, MIPS Assembler and Runtime Simulator (c) 2003-2011, Pete Sanderson and Kenneth Vollmar - "
            + makeLink("http://courses.missouristate.edu/KenVollmar/MARS") + "</li>"
            + "<li>SteelSeries (and SteelCheckBox) Swing components (c) 2010, Gerrit Grunwald - "
            + makeLink("http://harmoniccode.blogspot.be/search/label/steelseries") + "</li>" + "</ul>"
            + "License terms for all included code are available in the 'licenses' folder of the distribution."
            + "<p>For more information, help or ideas, please join us at " + makeLink("http://nikonhacker.com")
            + "</p></body></html>");

    // handle link events
    editorPane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
                try {
                    Desktop.getDesktop().browse(e.getURL().toURI());
                } catch (Exception e1) {
                    // noop
                }
            }
        }
    });
    editorPane.setEditable(false);
    Color greyLayer = new Color(label.getBackground().getRed(), label.getBackground().getGreen(),
            label.getBackground().getBlue(), 192);
    editorPane.setBackground(greyLayer);
    //editorPane.setOpaque(false);

    // show
    //        JOptionPane.showMessageDialog(this, editorPane, "About", JOptionPane.PLAIN_MESSAGE);

    final JDialog dialog = new JDialog(this, "About", true);

    JPanel contentPane = new BackgroundImagePanel(new BorderLayout(),
            Toolkit.getDefaultToolkit().getImage(EmulatorUI.class.getResource("images/nh_full.jpg")));
    contentPane.add(editorPane, BorderLayout.CENTER);

    JButton okButton = new JButton("OK");
    okButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
        }
    });
    JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    bottomPanel.add(okButton);
    bottomPanel.setBackground(greyLayer);
    // bottomPanel.setOpaque(false);

    contentPane.add(bottomPanel, BorderLayout.SOUTH);

    dialog.setContentPane(contentPane);
    dialog.pack();
    dialog.setLocationRelativeTo(this);
    dialog.setResizable(false);
    dialog.setVisible(true);
}