Example usage for java.awt Component LEFT_ALIGNMENT

List of usage examples for java.awt Component LEFT_ALIGNMENT

Introduction

In this page you can find the example usage for java.awt Component LEFT_ALIGNMENT.

Prototype

float LEFT_ALIGNMENT

To view the source code for java.awt Component LEFT_ALIGNMENT.

Click Source Link

Document

Ease-of-use constant for getAlignmentX .

Usage

From source file:lol.search.RankedStatsPage.java

private JPanel headerPanel() {
    //init spacers for header
    for (int i = 0; i < 10; i++) {
        JLabel label = new JLabel("--");
        label.setForeground(new Color(0, 0, 0, 0));
        spacers.add(label);// w  ww. ja  va  2  s  .c  om
    }
    //header -- to set this semi-transparent i had to remove setOpaque and replace with setBackground(...)
    JPanel headerPanel = new JPanel();
    headerPanel.setLayout(new BorderLayout());
    //headerPanel.setBorder(BorderFactory.createLineBorder(Color.WHITE));
    headerPanel.setBackground(backgroundColor);
    headerPanel.setPreferredSize(headerDimension);
    //back button
    JPanel buttonHolder = new JPanel();
    ImageIcon buttonImage = new ImageIcon("assets\\other\\button.png");
    ImageIcon buttonPressedImage = new ImageIcon("assets\\other\\buttonPressed.png");
    Image tempImage = buttonImage.getImage();
    Image newTempImg = tempImage.getScaledInstance(75, 35, Image.SCALE_SMOOTH);
    buttonImage = new ImageIcon(newTempImg);
    JButton backButton = new JButton("BACK");
    backButton.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 10)); //custom font
    backButton.setForeground(Color.WHITE); //text color
    backButton.setBackground(new Color(0, 0, 0, 0));
    backButton.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    backButton.setHorizontalTextPosition(AbstractButton.CENTER);
    backButton.setPreferredSize(new Dimension(75, 35));
    //pressed button
    Image tempImage2 = buttonPressedImage.getImage();
    Image newTempImg2 = tempImage2.getScaledInstance(75, 35, Image.SCALE_SMOOTH);
    buttonPressedImage = new ImageIcon(newTempImg2);
    backButton.setIcon(buttonImage);
    backButton.setRolloverIcon(buttonPressedImage);
    backButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) { //button pressed
            System.out.println("Going back...\n");
            masterFrame.getContentPane().removeAll();
            masterFrame.revalidate();
            masterFrame.repaint();
            MainPage MAIN_PAGE = new MainPage(masterFrame, summonerName);
        }
    });
    buttonHolder.add(backButton);
    buttonHolder.setOpaque(false);
    headerPanel.add(buttonHolder, BorderLayout.LINE_START);
    //centerpanel
    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new GridLayout(1, 2));
    centerPanel.setOpaque(false);
    //centerPanel.setBorder(BorderFactory.createLineBorder(Color.WHITE));
    //rightcenter
    JPanel rightCenter = new JPanel();
    rightCenter.setOpaque(false);
    rightCenter.setLayout(new GridLayout(2, 1));
    //top center panel
    JPanel topCenter = new JPanel();
    topCenter.setOpaque(false);
    topCenter.setLayout(new BoxLayout(topCenter, BoxLayout.X_AXIS));
    //profile icon
    JPanel proIconPanel = new JPanel();
    proIconPanel.setOpaque(false);
    proIconPanel.setLayout(new BoxLayout(proIconPanel, BoxLayout.Y_AXIS));
    JLabel profileIconLabel = new JLabel(this.profileIcon);
    //profileIconLabel.setBorder(BorderFactory.createLineBorder(Color.WHITE));
    profileIconLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
    proIconPanel.add(profileIconLabel);
    centerPanel.add(proIconPanel);
    //empty spacer
    topCenter.add(spacers.get(0));
    //summoner name
    JLabel summonerNameLabel = new JLabel(this.summonerName);
    summonerNameLabel.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 15)); //custom font
    summonerNameLabel.setForeground(Color.WHITE); //text color
    summonerNameLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    topCenter.add(summonerNameLabel);
    //empty spacer
    topCenter.add(spacers.get(1));
    //tier
    JLabel tierLabel = new JLabel(this.tier);
    tierLabel.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 13)); //custom font
    tierLabel.setForeground(new Color(219, 219, 219)); //text color
    tierLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    topCenter.add(tierLabel);
    //empty spacer
    topCenter.add(spacers.get(2));
    //division
    JLabel divisionLabel = new JLabel(this.division);
    divisionLabel.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 13)); //custom font
    divisionLabel.setForeground(new Color(219, 219, 219)); //text color
    divisionLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    topCenter.add(divisionLabel);
    //bottom center panel
    JPanel bottomCenter = new JPanel();
    bottomCenter.setOpaque(false);
    bottomCenter.setLayout(new BoxLayout(bottomCenter, BoxLayout.X_AXIS));
    //empty spacer
    bottomCenter.add(spacers.get(3));
    //season
    JLabel winsLabel = new JLabel(this.season);
    winsLabel.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 14)); //custom font
    winsLabel.setForeground(new Color(219, 219, 219)); //text color
    winsLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    bottomCenter.add(winsLabel);

    rightCenter.add(topCenter);
    rightCenter.add(bottomCenter);
    centerPanel.add(rightCenter);
    headerPanel.add(centerPanel, BorderLayout.CENTER);
    //empty panel to balance right side
    JPanel ee = new JPanel();
    ee.setOpaque(false);
    ee.setPreferredSize(new Dimension(260, 50));
    headerPanel.add(ee, BorderLayout.LINE_END);
    return headerPanel;
}

From source file:org.obiba.onyx.jade.instrument.ricelake.RiceLakeWeightInstrumentRunner.java

/**
 * Build action buttons sub panel/*from   w w w .  j  av a  2s .c  o m*/
 */
protected JPanel buildActionButtonSubPanel() {
    JPanel panel = new JPanel();

    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));

    panel.add(Box.createHorizontalGlue());
    panel.add(saveButton);

    JButton resetButton = new JButton(resourceBundle.getString("Reset"));
    resetButton.setMnemonic('R');
    resetButton.setToolTipText(resourceBundle.getString("ToolTip.Reset_measurement"));
    panel.add(Box.createRigidArea(new Dimension(10, 0)));
    panel.add(resetButton);

    JButton cancelButton = new JButton(resourceBundle.getString("Cancel"));
    cancelButton.setMnemonic('A');
    cancelButton.setToolTipText(resourceBundle.getString("ToolTip.Cancel_measurement"));
    panel.add(Box.createRigidArea(new Dimension(10, 0)));
    panel.add(cancelButton);

    JButton configureButton = new JButton(resourceBundle.getString("Configure"));
    configureButton.setMnemonic('C');
    configureButton.setToolTipText(resourceBundle.getString("ToolTip.Configure"));
    panel.add(Box.createRigidArea(new Dimension(10, 0)));
    panel.add(configureButton);

    // Configure button listener
    configureButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            configure();
        }
    });

    // Reset button listener
    resetButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            clearData();
        }
    });

    // Save button listener.
    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            sendOutputToServer();
        }
    });

    // Cancel button listener.
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            confirmOnExit();
        }
    });

    panel.setAlignmentX(Component.LEFT_ALIGNMENT);

    return (panel);
}

From source file:FileChooserDemo.java

public FileChooserDemo() {
    UIManager.LookAndFeelInfo[] installedLafs = UIManager.getInstalledLookAndFeels();
    for (UIManager.LookAndFeelInfo lafInfo : installedLafs) {
        try {/*from   ww w .  j  a  v  a  2  s  .co  m*/
            Class lnfClass = Class.forName(lafInfo.getClassName());
            LookAndFeel laf = (LookAndFeel) (lnfClass.newInstance());
            if (laf.isSupportedLookAndFeel()) {
                String name = lafInfo.getName();
                supportedLaFs.add(new SupportedLaF(name, laf));
            }
        } catch (Exception e) { // If ANYTHING weird happens, don't add it
            continue;
        }
    }

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    chooser = new JFileChooser();
    previewer = new FilePreviewer(chooser);

    // Create Custom FileView
    fileView = new ExampleFileView();
    //    fileView.putIcon("jpg", new ImageIcon(getClass().getResource("/resources/images/jpgIcon.jpg")));
    //  fileView.putIcon("gif", new ImageIcon(getClass().getResource("/resources/images/gifIcon.gif")));

    // create a radio listener to listen to option changes
    OptionListener optionListener = new OptionListener();

    // Create options
    openRadioButton = new JRadioButton("Open");
    openRadioButton.setSelected(true);
    openRadioButton.addActionListener(optionListener);

    saveRadioButton = new JRadioButton("Save");
    saveRadioButton.addActionListener(optionListener);

    customButton = new JRadioButton("Custom");
    customButton.addActionListener(optionListener);

    customField = new JTextField(8) {
        public Dimension getMaximumSize() {
            return new Dimension(getPreferredSize().width, getPreferredSize().height);
        }
    };
    customField.setText("Doit");
    customField.setAlignmentY(JComponent.TOP_ALIGNMENT);
    customField.setEnabled(false);
    customField.addActionListener(optionListener);

    ButtonGroup group1 = new ButtonGroup();
    group1.add(openRadioButton);
    group1.add(saveRadioButton);
    group1.add(customButton);

    // filter buttons
    showAllFilesFilterCheckBox = new JCheckBox("Show \"All Files\" Filter");
    showAllFilesFilterCheckBox.addActionListener(optionListener);
    showAllFilesFilterCheckBox.setSelected(true);

    showImageFilesFilterCheckBox = new JCheckBox("Show JPG and GIF Filters");
    showImageFilesFilterCheckBox.addActionListener(optionListener);
    showImageFilesFilterCheckBox.setSelected(false);

    accessoryCheckBox = new JCheckBox("Show Preview");
    accessoryCheckBox.addActionListener(optionListener);
    accessoryCheckBox.setSelected(false);

    // more options
    setHiddenCheckBox = new JCheckBox("Show Hidden Files");
    setHiddenCheckBox.addActionListener(optionListener);

    showFullDescriptionCheckBox = new JCheckBox("With File Extensions");
    showFullDescriptionCheckBox.addActionListener(optionListener);
    showFullDescriptionCheckBox.setSelected(true);
    showFullDescriptionCheckBox.setEnabled(false);

    useFileViewCheckBox = new JCheckBox("Use FileView");
    useFileViewCheckBox.addActionListener(optionListener);
    useFileViewCheckBox.setSelected(false);

    useEmbedInWizardCheckBox = new JCheckBox("Embed in Wizard");
    useEmbedInWizardCheckBox.addActionListener(optionListener);
    useEmbedInWizardCheckBox.setSelected(false);

    useControlsCheckBox = new JCheckBox("Show Control Buttons");
    useControlsCheckBox.addActionListener(optionListener);
    useControlsCheckBox.setSelected(true);

    enableDragCheckBox = new JCheckBox("Enable Dragging");
    enableDragCheckBox.addActionListener(optionListener);

    // File or Directory chooser options
    ButtonGroup group3 = new ButtonGroup();
    justFilesRadioButton = new JRadioButton("Just Select Files");
    justFilesRadioButton.setSelected(true);
    group3.add(justFilesRadioButton);
    justFilesRadioButton.addActionListener(optionListener);

    justDirectoriesRadioButton = new JRadioButton("Just Select Directories");
    group3.add(justDirectoriesRadioButton);
    justDirectoriesRadioButton.addActionListener(optionListener);

    bothFilesAndDirectoriesRadioButton = new JRadioButton("Select Files or Directories");
    group3.add(bothFilesAndDirectoriesRadioButton);
    bothFilesAndDirectoriesRadioButton.addActionListener(optionListener);

    singleSelectionRadioButton = new JRadioButton("Single Selection", true);
    singleSelectionRadioButton.addActionListener(optionListener);

    multiSelectionRadioButton = new JRadioButton("Multi Selection");
    multiSelectionRadioButton.addActionListener(optionListener);

    ButtonGroup group4 = new ButtonGroup();
    group4.add(singleSelectionRadioButton);
    group4.add(multiSelectionRadioButton);

    // Create show button
    showButton = new JButton("Show FileChooser");
    showButton.addActionListener(this);
    showButton.setMnemonic('s');

    // Create laf combo box

    lafComboBox = new JComboBox(supportedLaFs);
    lafComboBox.setEditable(false);
    lafComboBox.addActionListener(optionListener);

    // ********************************************************
    // ******************** Dialog Type ***********************
    // ********************************************************
    JPanel control1 = new InsetPanel(insets);
    control1.setBorder(BorderFactory.createTitledBorder("Dialog Type"));

    control1.setLayout(new BoxLayout(control1, BoxLayout.Y_AXIS));
    control1.add(Box.createRigidArea(vpad20));
    control1.add(openRadioButton);
    control1.add(Box.createRigidArea(vpad7));
    control1.add(saveRadioButton);
    control1.add(Box.createRigidArea(vpad7));
    control1.add(customButton);
    control1.add(Box.createRigidArea(vpad4));
    JPanel fieldWrapper = new JPanel();
    fieldWrapper.setLayout(new BoxLayout(fieldWrapper, BoxLayout.X_AXIS));
    fieldWrapper.setAlignmentX(Component.LEFT_ALIGNMENT);
    fieldWrapper.add(Box.createRigidArea(hpad10));
    fieldWrapper.add(Box.createRigidArea(hpad10));
    fieldWrapper.add(customField);
    control1.add(fieldWrapper);
    control1.add(Box.createRigidArea(vpad20));
    control1.add(Box.createGlue());

    // ********************************************************
    // ***************** Filter Controls **********************
    // ********************************************************
    JPanel control2 = new InsetPanel(insets);
    control2.setBorder(BorderFactory.createTitledBorder("Filter Controls"));
    control2.setLayout(new BoxLayout(control2, BoxLayout.Y_AXIS));
    control2.add(Box.createRigidArea(vpad20));
    control2.add(showAllFilesFilterCheckBox);
    control2.add(Box.createRigidArea(vpad7));
    control2.add(showImageFilesFilterCheckBox);
    control2.add(Box.createRigidArea(vpad4));
    JPanel checkWrapper = new JPanel();
    checkWrapper.setLayout(new BoxLayout(checkWrapper, BoxLayout.X_AXIS));
    checkWrapper.setAlignmentX(Component.LEFT_ALIGNMENT);
    checkWrapper.add(Box.createRigidArea(hpad10));
    checkWrapper.add(Box.createRigidArea(hpad10));
    checkWrapper.add(showFullDescriptionCheckBox);
    control2.add(checkWrapper);
    control2.add(Box.createRigidArea(vpad20));
    control2.add(Box.createGlue());

    // ********************************************************
    // ****************** Display Options *********************
    // ********************************************************
    JPanel control3 = new InsetPanel(insets);
    control3.setBorder(BorderFactory.createTitledBorder("Display Options"));
    control3.setLayout(new BoxLayout(control3, BoxLayout.Y_AXIS));
    control3.add(Box.createRigidArea(vpad20));
    control3.add(setHiddenCheckBox);
    control3.add(Box.createRigidArea(vpad7));
    control3.add(useFileViewCheckBox);
    control3.add(Box.createRigidArea(vpad7));
    control3.add(accessoryCheckBox);
    control3.add(Box.createRigidArea(vpad7));
    control3.add(useEmbedInWizardCheckBox);
    control3.add(Box.createRigidArea(vpad7));
    control3.add(useControlsCheckBox);
    control3.add(Box.createRigidArea(vpad7));
    control3.add(enableDragCheckBox);
    control3.add(Box.createRigidArea(vpad20));
    control3.add(Box.createGlue());

    // ********************************************************
    // ************* File & Directory Options *****************
    // ********************************************************
    JPanel control4 = new InsetPanel(insets);
    control4.setBorder(BorderFactory.createTitledBorder("File and Directory Options"));
    control4.setLayout(new BoxLayout(control4, BoxLayout.Y_AXIS));
    control4.add(Box.createRigidArea(vpad20));
    control4.add(justFilesRadioButton);
    control4.add(Box.createRigidArea(vpad7));
    control4.add(justDirectoriesRadioButton);
    control4.add(Box.createRigidArea(vpad7));
    control4.add(bothFilesAndDirectoriesRadioButton);
    control4.add(Box.createRigidArea(vpad20));
    control4.add(singleSelectionRadioButton);
    control4.add(Box.createRigidArea(vpad7));
    control4.add(multiSelectionRadioButton);
    control4.add(Box.createRigidArea(vpad20));
    control4.add(Box.createGlue());

    // ********************************************************
    // **************** Look & Feel Switch ********************
    // ********************************************************
    JPanel panel = new JPanel();
    panel.add(new JLabel("Look and Feel: "));
    panel.add(lafComboBox);
    panel.add(showButton);

    // ********************************************************
    // ****************** Wrap 'em all up *********************
    // ********************************************************
    JPanel wrapper = new JPanel();
    wrapper.setLayout(new BoxLayout(wrapper, BoxLayout.X_AXIS));

    add(Box.createRigidArea(vpad20));

    wrapper.add(Box.createRigidArea(hpad10));
    wrapper.add(Box.createRigidArea(hpad10));
    wrapper.add(control1);
    wrapper.add(Box.createRigidArea(hpad10));
    wrapper.add(control2);
    wrapper.add(Box.createRigidArea(hpad10));
    wrapper.add(control3);
    wrapper.add(Box.createRigidArea(hpad10));
    wrapper.add(control4);
    wrapper.add(Box.createRigidArea(hpad10));
    wrapper.add(Box.createRigidArea(hpad10));

    add(wrapper);
    add(Box.createRigidArea(vpad20));
    add(panel);
    add(Box.createRigidArea(vpad20));
}

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

private void initContentSearchPanel(SwingConfig config, ComponentRepository componentRepository) {

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));

    String title = localizer.localize("label.content-pattern");
    contentSearchPanel = new ContentSearchPanel(title, dataModel, config, componentRepository);
    contentSearchPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    browseButtonListener.addComponentToBeDisabledForSingleFiles(contentSearchPanel);
    componentRepository.getSearchBaseListener().addToBeEnabled(contentSearchPanel);
    componentRepository.getResetDispatcher().addToBeEnabled(contentSearchPanel);
    this.add(contentSearchPanel);

    inversionFlag = new JCheckBox(localizer.localize("label.exclude-matches"));
    inversionFlag.setAlignmentX(Component.LEFT_ALIGNMENT);
    inversionFlag.setSelected(dataModel.isInvertContentFilter());
    inversionFlag.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setInvertContentFilter((ItemEvent.SELECTED == event.getStateChange()));
        }/*  w w  w  . j  a va 2s .c o  m*/
    });
    browseButtonListener.addComponentToBeDisabledForSingleFiles(inversionFlag);
    componentRepository.getSearchBaseListener().addToBeEnabled(inversionFlag);
    componentRepository.getResetDispatcher().addToBeEnabled(inversionFlag);
    contentSearchPanel.addFlag(inversionFlag);

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));
    this.add(Box.createVerticalGlue());

}

From source file:lol.search.RankedStatsPage.java

private JPanel bodyPanel(JPanel body) {
    body.setLayout(new BoxLayout(body, BoxLayout.X_AXIS));
    body.setBackground(backgroundColor);
    body.setPreferredSize(new Dimension(1200, 530));

    //load art /*  w ww.j  av a  2  s .  co m*/
    this.loadArtLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.loadArtLabel.setPreferredSize(new Dimension(290, 504));
    this.loadArtLabel.setIcon(OBJ_GAME_STATIC_DATA.initLoadingArt(champKeyList.get(0)));
    body.add(this.loadArtLabel);

    JPanel rightPanel = new JPanel(new FlowLayout());
    rightPanel.setPreferredSize(new Dimension(800, 514));
    rightPanel.setOpaque(false);
    //rightPanel.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));

    JPanel headerPanel = new JPanel();
    headerPanel.setLayout(new BoxLayout(headerPanel, BoxLayout.X_AXIS));
    headerPanel.setPreferredSize(new Dimension(910, 55));
    headerPanel.setOpaque(false);
    //headerPanel.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    this.defaultHeader.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 40)); //custom font
    this.defaultHeader.setForeground(Color.WHITE);
    this.defaultHeader.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.defaultHeader.setText(" Season Totals: ");
    this.nameHeader.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 40)); //custom font
    this.nameHeader.setForeground(valueOrange);
    this.nameHeader.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.nameHeader.setText("Overall");
    this.titleHeader.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 16)); //custom font
    this.titleHeader.setForeground(new Color(255, 128, 0));
    this.titleHeader.setAlignmentX(Component.LEFT_ALIGNMENT);
    //nameHeader.setAlignmentY(Component.TOP_ALIGNMENT);
    titleHeader.setAlignmentY(Component.TOP_ALIGNMENT);
    headerPanel.add(defaultHeader);
    headerPanel.add(nameHeader);
    headerPanel.add(titleHeader);
    rightPanel.add(headerPanel);
    rightPanel.add(statsPanel());
    body.add(rightPanel);

    return body;
}

From source file:org.omegat.gui.scripting.ScriptingWindow.java

private void setupRunButtons(JPanel panel) {
    m_btnRunScript = new JButton();
    Mnemonics.setLocalizedText(m_btnRunScript, OStrings.getString("SCW_RUN_SCRIPT"));
    m_btnRunScript.setAlignmentX(Component.LEFT_ALIGNMENT);
    m_btnRunScript.setHorizontalAlignment(SwingConstants.LEFT);
    m_btnRunScript.addActionListener(new ActionListener() {
        @Override//from  w w  w  .  j a v  a 2s  .  c o  m
        public void actionPerformed(ActionEvent a) {
            runScript();
        }
    });
    panel.add(m_btnRunScript);

    m_btnCancelScript = new JButton();
    Mnemonics.setLocalizedText(m_btnCancelScript, OStrings.getString("SCW_CANCEL_SCRIPT"));
    m_btnCancelScript.setToolTipText(OStrings.getString("SCW_CANCEL_BUTTON_TOOLTIP"));
    m_btnCancelScript.setAlignmentX(Component.LEFT_ALIGNMENT);
    m_btnCancelScript.setHorizontalAlignment(SwingConstants.LEFT);
    m_btnCancelScript.addActionListener(e -> cancelCurrentScript());
    panel.add(m_btnCancelScript);

    for (int i = 0; i < NUMBERS_OF_QUICK_SCRIPTS; i++) {
        final int index = i;
        final int scriptKey = scriptKey(index);
        m_quickScriptButtons[i] = new JButton(String.valueOf(scriptKey));

        // Run a script from the quick button bar
        m_quickScriptButtons[i].addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent a) {
                if (Preferences.existsPreference(Preferences.SCRIPTS_QUICK_PREFIX + scriptKey)) {
                    runQuickScript(index);
                } else {
                    logResult(StringUtil.format(OStrings.getString("SCW_NO_SCRIPT_BOUND"), scriptKey));
                }
            }
        });

        JPopupMenu quickScriptPopup = new JPopupMenu();

        // Add a script to the quick script button bar
        final JMenuItem addQuickScriptMenuItem = new JMenuItem(OStrings.getString("SCW_ADD_SCRIPT"));
        addQuickScriptMenuItem.addActionListener(new QuickScriptUpdater(index));
        quickScriptPopup.add(addQuickScriptMenuItem);

        // Remove a script from the button bar
        final JMenuItem removeQuickScriptMenuItem = new JMenuItem(OStrings.getString("SCW_REMOVE_SCRIPT"));
        removeQuickScriptMenuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                String scriptName = Preferences
                        .getPreferenceDefault(Preferences.SCRIPTS_QUICK_PREFIX + scriptKey, "(unknown)");
                logResult(StringUtil.format(OStrings.getString("SCW_REMOVED_QUICK_SCRIPT"), scriptName,
                        scriptKey));
                Preferences.setPreference(Preferences.SCRIPTS_QUICK_PREFIX + scriptKey, "");
                m_quickScriptButtons[index].setToolTipText(OStrings.getString("SCW_NO_SCRIPT_SET"));
                m_quickScriptButtons[index].setText(" " + scriptKey + " ");

                unsetQuickScriptMenu(index);
            }
        });
        quickScriptPopup.add(removeQuickScriptMenuItem);

        quickScriptPopup.addPopupMenuListener(new PopupMenuListener() {
            @Override
            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                // Disable add a script command if script selection empty
                addQuickScriptMenuItem.setEnabled(!m_scriptList.isSelectionEmpty());

                // Disable remove a script command if the quick run button is not bounded
                String scriptName = Preferences
                        .getPreferenceDefault(Preferences.SCRIPTS_QUICK_PREFIX + scriptKey, null);
                removeQuickScriptMenuItem.setEnabled(!StringUtil.isEmpty(scriptName));
            }

            @Override
            public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                // do nothing
            }

            @Override
            public void popupMenuCanceled(PopupMenuEvent e) {
                // do nothing
            }
        });

        m_quickScriptButtons[i].setComponentPopupMenu(quickScriptPopup);

        panel.add(m_quickScriptButtons[i]);
    }
}

From source file:lol.search.RankedStatsPage.java

private JPanel statsPanel() {
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    panel.setOpaque(false);//ww w  .  j a  va2  s  .  c  o m
    panel.setLayout(new FlowLayout());
    panel.setPreferredSize(new Dimension(910, 464));
    JPanel statsPanelTotals = new JPanel();
    statsPanelTotals.setLayout(new BoxLayout(statsPanelTotals, BoxLayout.X_AXIS));
    statsPanelTotals.setOpaque(false);
    //statsPanelTotals.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    //totals
    statsPanelTotals.setPreferredSize(new Dimension(910, 45));
    totalJLabel(winsLabel, "   W: ", Color.WHITE);
    winsLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    totalJLabel(totalWins, "" + this.wins, valueOrange);
    totalJLabel(lossesLabel, "   L: ", Color.WHITE);
    totalJLabel(totalLosses, "" + this.losses, valueOrange);
    totalJLabel(winPercentLabel, "   Win Ratio: ", Color.WHITE);
    totalJLabel(winPercent, winPercentage + "%", valueOrange);
    totalJLabel(totalGames, "   Total Games Played: ", Color.WHITE);
    totalJLabel(this.totalGamesPlayed, String.valueOf(totalGamesInt), valueOrange);
    statsPanelTotals.add(winsLabel);
    statsPanelTotals.add(totalWins);
    statsPanelTotals.add(lossesLabel);
    statsPanelTotals.add(totalLosses);
    statsPanelTotals.add(winPercentLabel);
    statsPanelTotals.add(winPercent);
    statsPanelTotals.add(totalGames);
    statsPanelTotals.add(totalGamesPlayed);
    JPanel totalsAndAverages = new JPanel();
    totalsAndAverages.setOpaque(false);
    totalsAndAverages.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    totalsAndAverages.setPreferredSize(new Dimension(910, 405));
    totalsAndAverages.setLayout(new GridLayout());
    JPanel leftSide = new JPanel();
    leftSide.setOpaque(false);
    leftSide.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    JPanel leftSideHeader = new JPanel();
    leftSideHeader.setOpaque(false);
    leftSideHeader.setLayout(new FlowLayout());
    leftSideHeader.setPreferredSize(new Dimension(455, 35));
    //leftSideHeader.setBorder(BorderFactory.createLineBorder(Color.CYAN));
    totalJLabel(this.leftSideHeaderLabel, "   Per Game Averages:", Color.WHITE);
    leftSideHeader.add(this.leftSideHeaderLabel);
    JPanel leftSideBody = new JPanel();
    leftSideBody.setOpaque(false);
    leftSideBody.setLayout(new FlowLayout(FlowLayout.LEFT));
    leftSideBody.setPreferredSize(new Dimension(250, 360));
    //leftSideBody.setBorder(BorderFactory.createLineBorder(Color.RED));
    JPanel avgKillsPanel = new JPanel();
    avgKillsPanel.setOpaque(false);
    //avgKillsPanel.setBorder(BorderFactory.createLineBorder(Color.CYAN));
    JPanel avgDeathsPanel = new JPanel();
    avgDeathsPanel.setOpaque(false);
    JPanel avgAssistsPanel = new JPanel();
    avgAssistsPanel.setOpaque(false);
    JPanel avgMinionsPanel = new JPanel();
    avgMinionsPanel.setOpaque(false);
    JPanel avgDoubleKillsPanel = new JPanel();
    avgDoubleKillsPanel.setOpaque(false);
    JPanel avgTripleKillsPanel = new JPanel();
    avgTripleKillsPanel.setOpaque(false);
    JPanel avgQuadKillsPanel = new JPanel();
    avgQuadKillsPanel.setOpaque(false);
    JPanel avgPentaKillsPanel = new JPanel();
    avgPentaKillsPanel.setOpaque(false);
    totalJLabel(this.avgKillsLabel, "   Avg. Kills: ", Color.WHITE);
    totalJLabel(this.avgDeathsLabel, "   Avg. Deaths: ", Color.WHITE);
    totalJLabel(this.avgAssistsLabel, "   Avg. Assists: ", Color.WHITE);
    totalJLabel(this.avgMinionKillsLabel, "   Avg. Minion Kills: ", Color.WHITE);
    totalJLabel(this.avgDoubleKillsLabel, "   Avg. Double Kills: ", Color.WHITE);
    totalJLabel(this.avgTripleKillsLabel, "   Avg. Triple Kills: ", Color.WHITE);
    totalJLabel(this.avgQuadKillsLabel, "   Avg. Quadra Kills: ", Color.WHITE);
    totalJLabel(this.avgPentaKillsLabel, "   Avg. Penta Kills: ", Color.WHITE);
    double totalKills = 00000;
    double totalDeaths = 00000;
    double totalAssists = 00000;
    double totalMinions = 00000;
    double totalDoubleKills = 00000;
    double totalTripleKills = 00000;
    double totalQuadraKills = 00000;
    double totalPentaKills = 00000;
    double avgKills = 99999;
    double avgAssists = 99999;
    double avgDeaths = 99999;
    double avgMinions = 99999;
    double avgDoubleKills = 99999;
    double avgTripleKills = 99999;
    double avgQuadraKills = 99999;
    double avgPentaKills = 99999;
    try {
        double totalGamesPlayed = this.objChampRankedList.get(0).getJSONObject("stats")
                .getInt("totalSessionsPlayed");
        //operations
        totalKills = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalChampionKills");
        avgKills = totalKills / totalGamesPlayed;
        totalDeaths = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalDeathsPerSession");
        avgDeaths = totalDeaths / totalGamesPlayed;
        totalAssists = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalAssists");
        avgAssists = totalAssists / totalGamesPlayed;
        totalMinions = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalMinionKills");
        avgMinions = totalMinions / totalGamesPlayed;
        totalDoubleKills = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalDoubleKills");
        avgDoubleKills = totalDoubleKills / totalGamesPlayed;
        totalTripleKills = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalTripleKills");
        avgTripleKills = totalTripleKills / totalGamesPlayed;
        totalQuadraKills = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalQuadraKills");
        avgQuadraKills = totalQuadraKills / totalGamesPlayed;
        totalPentaKills = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalPentaKills");
        avgPentaKills = totalPentaKills / totalGamesPlayed;
    } catch (JSONException ex) {
        Logger.getLogger(RankedStatsPage.class.getName()).log(Level.SEVERE, null, ex);
    }
    String avgKillsString = new DecimalFormat("##.##").format(avgKills);
    String avgDeathsString = new DecimalFormat("##.##").format(avgDeaths);
    String avgAssistsString = new DecimalFormat("##.##").format(avgAssists);
    String avgMinionsString = new DecimalFormat("##.##").format(avgMinions);
    String avgDoubleKillsString = new DecimalFormat("##.##").format(avgDoubleKills);
    String avgTripleKillsString = new DecimalFormat("##.##").format(avgTripleKills);
    String avgQuadraKillsString = new DecimalFormat("##.##").format(avgQuadraKills);
    String avgPentaKillsString = new DecimalFormat("##.##").format(avgPentaKills);
    totalJLabel(this.avgKillsLabelValue, avgKillsString, valueOrange);
    totalJLabel(this.avgDeathsLabelValue, avgDeathsString, valueOrange);
    totalJLabel(this.avgAssistsLabelValue, avgAssistsString, valueOrange);
    totalJLabel(this.avgMinionKillsLabelValue, avgMinionsString, valueOrange);
    totalJLabel(this.avgDoubleKillsLabelValue, avgDoubleKillsString, valueOrange);
    totalJLabel(this.avgTripleKillsLabelValue, avgTripleKillsString, valueOrange);
    totalJLabel(this.avgQuadKillsLabelValue, avgQuadraKillsString, valueOrange);
    totalJLabel(this.avgPentaKillsLabelValue, avgPentaKillsString, valueOrange);
    avgKillsPanel.add(avgKillsLabel);
    avgKillsPanel.add(avgKillsLabelValue);
    avgDeathsPanel.add(avgDeathsLabel);
    avgDeathsPanel.add(avgDeathsLabelValue);
    avgAssistsPanel.add(avgAssistsLabel);
    avgAssistsPanel.add(avgAssistsLabelValue);
    avgMinionsPanel.add(avgMinionKillsLabel);
    avgMinionsPanel.add(avgMinionKillsLabelValue);
    avgDoubleKillsPanel.add(avgDoubleKillsLabel);
    avgDoubleKillsPanel.add(avgDoubleKillsLabelValue);
    avgTripleKillsPanel.add(avgTripleKillsLabel);
    avgTripleKillsPanel.add(avgTripleKillsLabelValue);
    avgQuadKillsPanel.add(avgQuadKillsLabel);
    avgQuadKillsPanel.add(avgQuadKillsLabelValue);
    avgPentaKillsPanel.add(avgPentaKillsLabel);
    avgPentaKillsPanel.add(avgPentaKillsLabelValue);
    leftSideBody.add(avgKillsPanel);
    leftSideBody.add(avgDeathsPanel);
    leftSideBody.add(avgAssistsPanel);
    leftSideBody.add(avgMinionsPanel);
    leftSideBody.add(avgDoubleKillsPanel);
    leftSideBody.add(avgTripleKillsPanel);
    leftSideBody.add(avgQuadKillsPanel);
    leftSideBody.add(avgPentaKillsPanel);
    leftSide.add(leftSideHeader);
    leftSide.add(leftSideBody);
    JPanel rightSide = new JPanel();
    /**/
    rightSide.setOpaque(false);
    rightSide.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    JPanel rightSideHeader = new JPanel();
    rightSideHeader.setOpaque(false);
    rightSideHeader.setLayout(new FlowLayout());
    rightSideHeader.setPreferredSize(new Dimension(455, 35));
    //rightSideHeader.setBorder(BorderFactory.createLineBorder(Color.MAGENTA));
    totalJLabel(this.rightSideHeaderLabel, "   Season Totals:", Color.WHITE);
    rightSideHeader.add(this.rightSideHeaderLabel);
    JPanel rightSideBody = new JPanel();
    rightSideBody.setOpaque(false);
    rightSideBody.setLayout(new FlowLayout(FlowLayout.LEFT));
    rightSideBody.setPreferredSize(new Dimension(270, 360));
    //rightSideBody.setBorder(BorderFactory.createLineBorder(Color.MAGENTA));
    JPanel totalKillsPanel = new JPanel();
    totalKillsPanel.setOpaque(false);
    JPanel totalDeathsPanel = new JPanel();
    totalDeathsPanel.setOpaque(false);
    JPanel totalAssistsPanel = new JPanel();
    totalAssistsPanel.setOpaque(false);
    JPanel totalMinionsPanel = new JPanel();
    totalMinionsPanel.setOpaque(false);
    JPanel totalDoubleKillsPanel = new JPanel();
    totalDoubleKillsPanel.setOpaque(false);
    JPanel totalTripleKillsPanel = new JPanel();
    totalTripleKillsPanel.setOpaque(false);
    JPanel totalQuadKillsPanel = new JPanel();
    totalQuadKillsPanel.setOpaque(false);
    JPanel totalPentaKillsPanel = new JPanel();
    totalPentaKillsPanel.setOpaque(false);
    totalJLabel(this.totalKillsLabel, "   Total Kills: ", Color.WHITE);
    totalJLabel(this.totalKillsLabelValue, new DecimalFormat("#######").format(totalKills), valueOrange);
    totalJLabel(this.totalDeathsLabel, "   Total Deaths: ", Color.WHITE);
    totalJLabel(this.totalDeathsLabelValue, new DecimalFormat("#######").format(totalDeaths), valueOrange);
    totalJLabel(this.totalAssistsLabel, "   Total Assists: ", Color.WHITE);
    totalJLabel(this.totalAssistsLabelValue, new DecimalFormat("#######").format(totalAssists), valueOrange);
    totalJLabel(this.totalMinionsLabel, "   Total Minion Kills: ", Color.WHITE);
    totalJLabel(this.totalMinionsLabelValue, new DecimalFormat("#######").format(totalMinions), valueOrange);
    totalJLabel(this.totalDoubleKillsLabel, "   Total Double Kills: ", Color.WHITE);
    totalJLabel(this.totalDoubleKillsLabelValue, new DecimalFormat("#######").format(totalDoubleKills),
            valueOrange);
    totalJLabel(this.totalTripleKillsLabel, "   Total Triple Kills: ", Color.WHITE);
    totalJLabel(this.totalTripleKillsLabelValue, new DecimalFormat("#######").format(totalTripleKills),
            valueOrange);
    totalJLabel(this.totalQuadKillsLabel, "   Total Quadra Kills: ", Color.WHITE);
    totalJLabel(this.totalQuadKillsLabelValue, new DecimalFormat("#######").format(totalQuadraKills),
            valueOrange);
    totalJLabel(this.totalPentaKillsLabel, "   Total Penta Kills: ", Color.WHITE);
    totalJLabel(this.totalPentaKillsLabelValue, new DecimalFormat("#######").format(totalPentaKills),
            valueOrange);
    totalKillsPanel.add(totalKillsLabel);
    totalKillsPanel.add(totalKillsLabelValue);
    totalDeathsPanel.add(totalDeathsLabel);
    totalDeathsPanel.add(totalDeathsLabelValue);
    totalAssistsPanel.add(totalAssistsLabel);
    totalAssistsPanel.add(totalAssistsLabelValue);
    totalMinionsPanel.add(totalMinionsLabel);
    totalMinionsPanel.add(totalMinionsLabelValue);
    totalDoubleKillsPanel.add(totalDoubleKillsLabel);
    totalDoubleKillsPanel.add(totalDoubleKillsLabelValue);
    totalTripleKillsPanel.add(totalTripleKillsLabel);
    totalTripleKillsPanel.add(totalTripleKillsLabelValue);
    totalQuadKillsPanel.add(totalQuadKillsLabel);
    totalQuadKillsPanel.add(totalQuadKillsLabelValue);
    totalPentaKillsPanel.add(totalPentaKillsLabel);
    totalPentaKillsPanel.add(totalPentaKillsLabelValue);
    rightSideBody.add(totalKillsPanel);
    rightSideBody.add(totalDeathsPanel);
    rightSideBody.add(totalAssistsPanel);
    rightSideBody.add(totalMinionsPanel);
    rightSideBody.add(totalDoubleKillsPanel);
    rightSideBody.add(totalTripleKillsPanel);
    rightSideBody.add(totalQuadKillsPanel);
    rightSideBody.add(totalPentaKillsPanel);
    //rightSideBody.setBorder(BorderFactory.createLineBorder(Color.RED));
    rightSide.add(rightSideHeader);
    rightSide.add(rightSideBody);
    totalsAndAverages.add(rightSide);
    totalsAndAverages.add(leftSide);
    panel.add(statsPanelTotals);
    panel.add(totalsAndAverages);
    return panel;
}

From source file:metdemo.Finance.SHNetworks.java

/**
 * /* w ww  .  ja  v a2s .c  om*/
 * @param jp
 * @param usersarray
 * @param viphm_hashmap
 */
protected void addBottomControls(final JPanel jp, String[] usersarray) {
    // create the control panel which will hold settings and picked list
    final JPanel control_panel = new JPanel();
    jp.add(control_panel, BorderLayout.SOUTH);
    control_panel.setLayout(new BorderLayout());

    // create the settings panel which will hold all of the settings
    Box settings_box = Box.createVerticalBox();
    settings_box.setBorder(BorderFactory.createTitledBorder("Display Settings"));
    control_panel.add(settings_box, BorderLayout.NORTH);
    JPanel settings_panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));

    // add the zoom controls to the settings panel
    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // call listener in GraphMouse instead of manipulating vv scale
            // directly
            // this is so the crossover from zoom to scale works with the
            // buttons
            // as well as with the mouse wheel
            Dimension d = m_visualizationview.getSize();
            m_graphmouse.mouseWheelMoved(
                    new MouseWheelEvent(m_visualizationview, MouseEvent.MOUSE_WHEEL, System.currentTimeMillis(),
                            0, d.width / 2, d.height / 2, 1, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, 1));
        }
    });
    JButton minus = new JButton(" - ");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // call listener in GraphMouse instead of manipulating vv scale
            // directly
            // this is so the crossover from zoom to scale works with the
            // buttons
            // as well as with the mouse wheel
            Dimension d = m_visualizationview.getSize();
            m_graphmouse.mouseWheelMoved(
                    new MouseWheelEvent(m_visualizationview, MouseEvent.MOUSE_WHEEL, System.currentTimeMillis(),
                            0, d.width / 2, d.height / 2, 1, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, -1));
        }
    });
    Box zoomPanel = Box.createHorizontalBox();
    zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom"));
    minus.setAlignmentX(Component.LEFT_ALIGNMENT);
    plus.setAlignmentX(Component.RIGHT_ALIGNMENT);
    zoomPanel.add(minus);
    zoomPanel.add(plus);
    settings_panel.add(zoomPanel);

    // add the mouse mode combo box to the settings panel
    JComboBox modeBox = m_graphmouse.getModeComboBox();
    modeBox.setAlignmentX(Component.CENTER_ALIGNMENT);
    m_graphmouse.setMode(ModalGraphMouse.Mode.PICKING);
    JPanel modePanel = new JPanel(new BorderLayout()) {
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(modeBox);
    settings_panel.add(modePanel);

    // add the display type combo box to the settings panel
    String[] layoutTypeStrings = { "OrgChart Layout", "FR Layout" };
    layoutTypeBox = new JComboBox(layoutTypeStrings);
    layoutTypeBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (layoutTypeBox.getSelectedIndex() == 0)
                moveVertices();//viphm_hashmap);
            else
                m_visualizationview.restart();
        }
    });
    layoutTypeBox.setAlignmentX(Component.CENTER_ALIGNMENT);
    JPanel displayTypePanel = new JPanel(new BorderLayout()) {
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    displayTypePanel.setBorder(BorderFactory.createTitledBorder("Display Type"));
    displayTypePanel.add(layoutTypeBox);
    settings_panel.add(displayTypePanel);

    // add user search to the panel - SHLOMO
    JPanel searchPanel = new JPanel(new BorderLayout()) {
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    // take the users and organize it sorted
    /*
     * ArrayList<String> ta = new ArrayList<String>(userlist); String []
     * usersarray = (String[]) ta.toArray(new String[ta.size()]);
     */Arrays.sort(usersarray);
    usercombolist = new JComboBox(usersarray);

    usercombolist.insertItemAt("Anyone", 0);
    usercombolist.setSelectedIndex(0);// show only anyone choice
    // lets add all current users to the list

    searchPanel.setBorder(BorderFactory.createTitledBorder("Search User"));
    searchPanel.add(usercombolist);

    //add a check box to show not show labels on all vertices
    m_showLabels = new JCheckBox("Show name?", false);
    settings_panel.add(m_showLabels);

    settings_panel.add(searchPanel);

    usercombolist.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            // will need to react to the choice list
            if (usercombolist.getSelectedIndex() == 0) {
                // might have to reset something in case they move back
                PickedState picked_state = m_visualizationview.getPickedState();
                picked_state.clearPickedVertices();

                return;
            }
            String username = (String) usercombolist.getSelectedItem();

            for (Iterator walker = m_layout.getVertexIterator(); walker.hasNext();) {
                VIPVertex V = (VIPVertex) walker.next();

                // Integer indexNum = (Integer)index.getNumber(V);
                String seeName = V.getAcct();// accounts_arraylist.get(indexNum);
                if (username.equals(seeName)) {
                    PickedState picked_state = m_visualizationview.getPickedState();
                    picked_state.clearPickedVertices();
                    picked_state.pick(V, true);
                    /*
                     * int x= (int)m_layout.getX(V); int y=
                     * (int)m_layout.getY(V); //lets trigger the event
                     * m_graphmouse.mousePressed(new
                     * MouseEvent(m_visualizationview,MouseEvent.MOUSE_CLICKED,System.currentTimeMillis(),0,x,y,2,false));
                     */return;
                }
            }

        }
    });

    // add the settings panel to the settings box
    settings_box.add(settings_panel);

    // add the vip table to the control panel
    SortTableModel model = new SortTableModel();
    model.addColumn("Account");
    model.addColumn("ResponseScore");
    model.addColumn("SocialScore");
    m_timeTable = new JTable(model);
    model.addMouseListenerToHeaderInTable(m_timeTable);
    m_timeTable.setRowSelectionAllowed(true);
    m_timeTable.setColumnSelectionAllowed(false);
    m_timeTable.getTableHeader().setReorderingAllowed(false);
    m_timeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m_timeTable.setDefaultRenderer(model.getColumnClass(1), md5Renderer);
    tablePane = new JScrollPane(m_timeTable);
    tablePane.setPreferredSize(new Dimension(300, 150));
    control_panel.add(tablePane, BorderLayout.SOUTH);
}

From source file:ca.uhn.hl7v2.testpanel.ui.TestPanelWindow.java

/**
 * Initialize the contents of the frame.
 *///from  w  w  w  .jav a2 s  .c o m
private void initialize() {
    myframe = new JFrame();
    myframe.setVisible(false);

    List<Image> l = new ArrayList<Image>();
    l.add(Toolkit.getDefaultToolkit()
            .getImage(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_16.png")));
    l.add(Toolkit.getDefaultToolkit()
            .getImage(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_64.png")));

    myframe.setIconImages(l);
    myframe.setTitle("HAPI TestPanel");
    myframe.setBounds(100, 100, 796, 603);
    myframe.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    myframe.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent theE) {
            myController.close();
        }
    });

    JMenuBar menuBar = new JMenuBar();
    myframe.setJMenuBar(menuBar);

    JMenu mnFile = new JMenu("File");
    mnFile.setMnemonic('f');
    menuBar.add(mnFile);

    JMenuItem mntmExit = new JMenuItem("Exit");
    mntmExit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            myController.close();
        }
    });

    JMenuItem mntmNewMessage = new JMenuItem("New Message...");
    mntmNewMessage.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.addMessage();
        }
    });
    mntmNewMessage.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/message_hl7.png")));
    mnFile.add(mntmNewMessage);

    mySaveMenuItem = new JMenuItem("Save");
    mySaveMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mySaveMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doSaveMessages();
        }
    });
    mnFile.add(mySaveMenuItem);

    mySaveAsMenuItem = new JMenuItem("Save As...");
    mySaveAsMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doSaveMessagesAs();
        }
    });
    mnFile.add(mySaveAsMenuItem);

    mymenuItem_3 = new JMenuItem("Open");
    mymenuItem_3.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mymenuItem_3.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.openMessages();
        }
    });

    myRevertToSavedMenuItem = new JMenuItem("Revert to Saved");
    myRevertToSavedMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.revertMessage((Hl7V2MessageCollection) myController.getLeftSelectedItem());
        }
    });
    mnFile.add(myRevertToSavedMenuItem);
    mnFile.add(mymenuItem_3);

    myRecentFilesMenu = new JMenu("Open Recent");
    mnFile.add(myRecentFilesMenu);

    JSeparator separator = new JSeparator();
    mnFile.add(separator);
    mnFile.add(mntmExit);

    JMenu mnNewMenu = new JMenu("View");
    mnNewMenu.setMnemonic('v');
    menuBar.add(mnNewMenu);

    myShowLogConsoleMenuItem = new JMenuItem("Show Log Console");
    myShowLogConsoleMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Prefs.getInstance().setShowLogConsole(!Prefs.getInstance().getShowLogConsole());
            updateLogScrollPaneVisibility();
            myframe.validate();
        }
    });
    mnNewMenu.add(myShowLogConsoleMenuItem);

    mymenu_1 = new JMenu("Test");
    menuBar.add(mymenu_1);

    mymenuItem_1 = new JMenuItem("Populate TestPanel with Sample Message and Connections...");
    mymenuItem_1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.populateWithSampleMessageAndConnections();
        }
    });
    mymenu_1.add(mymenuItem_1);

    mymenu_3 = new JMenu("Tools");
    menuBar.add(mymenu_3);

    mnHl7V2FileDiff = new JMenuItem("HL7 v2 File Diff...");
    mnHl7V2FileDiff.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (myHl7V2FileDiff == null) {
                myHl7V2FileDiff = new Hl7V2FileDiffController(myController);
            }
            myHl7V2FileDiff.show();
        }
    });
    mymenu_3.add(mnHl7V2FileDiff);

    mymenuItem_5 = new JMenuItem("HL7 v2 File Sort...");
    mymenuItem_5.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (myHl7V2FileSort == null) {
                myHl7V2FileSort = new Hl7V2FileSortController(myController);
            }
            myHl7V2FileSort.show();
        }
    });
    mymenu_3.add(mymenuItem_5);

    mymenu_2 = new JMenu("Conformance");
    menuBar.add(mymenu_2);

    mymenuItem_2 = new JMenuItem("Profiles and Tables...");
    mymenuItem_2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.showProfilesAndTablesEditor();
        }
    });
    mymenu_2.add(mymenuItem_2);

    mymenu = new JMenu("Help");
    mymenu.setMnemonic('H');
    menuBar.add(mymenu);

    mymenuItem = new JMenuItem("About HAPI TestPanel...");
    mymenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            showAboutDialog();
        }
    });
    mymenuItem.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_16.png")));
    mymenu.add(mymenuItem);

    mymenuItem_4 = new JMenuItem("Licenses...");
    mymenuItem_4.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new LicensesDialog().setVisible(true);
        }
    });
    mymenu.add(mymenuItem_4);
    myframe.getContentPane().setLayout(new BorderLayout(0, 0));

    JSplitPane outerSplitPane = new JSplitPane();
    outerSplitPane.setBorder(null);
    myframe.getContentPane().add(outerSplitPane);

    JSplitPane leftSplitPane = new JSplitPane();
    leftSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    outerSplitPane.setLeftComponent(leftSplitPane);

    JPanel messagesPanel = new JPanel();
    leftSplitPane.setLeftComponent(messagesPanel);
    GridBagLayout gbl_messagesPanel = new GridBagLayout();
    gbl_messagesPanel.columnWidths = new int[] { 110, 0 };
    gbl_messagesPanel.rowHeights = new int[] { 20, 30, 118, 0, 0 };
    gbl_messagesPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_messagesPanel.rowWeights = new double[] { 0.0, 0.0, 100.0, 1.0, Double.MIN_VALUE };
    messagesPanel.setLayout(gbl_messagesPanel);

    JLabel lblMessages = new JLabel("Messages");
    GridBagConstraints gbc_lblMessages = new GridBagConstraints();
    gbc_lblMessages.insets = new Insets(0, 0, 5, 0);
    gbc_lblMessages.gridx = 0;
    gbc_lblMessages.gridy = 0;
    messagesPanel.add(lblMessages, gbc_lblMessages);

    JToolBar messagesToolBar = new JToolBar();
    messagesToolBar.setFloatable(false);
    messagesToolBar.setRollover(true);
    messagesToolBar.setAlignmentX(Component.LEFT_ALIGNMENT);
    GridBagConstraints gbc_messagesToolBar = new GridBagConstraints();
    gbc_messagesToolBar.insets = new Insets(0, 0, 5, 0);
    gbc_messagesToolBar.weightx = 1.0;
    gbc_messagesToolBar.anchor = GridBagConstraints.NORTHWEST;
    gbc_messagesToolBar.gridx = 0;
    gbc_messagesToolBar.gridy = 1;
    messagesPanel.add(messagesToolBar, gbc_messagesToolBar);

    JButton msgOpenButton = new JButton("");
    msgOpenButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.openMessages();
        }
    });

    myAddMessageButton = new JButton("");
    myAddMessageButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.addMessage();
        }
    });
    myAddMessageButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/add.png")));
    myAddMessageButton.setToolTipText("New Message");
    myAddMessageButton.setBorderPainted(false);
    myAddMessageButton.addMouseListener(new HoverButtonMouseAdapter(myAddMessageButton));
    messagesToolBar.add(myAddMessageButton);

    myDeleteMessageButton = new JButton("");
    myDeleteMessageButton.setToolTipText("Close Selected Message");
    myDeleteMessageButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.closeMessage((Hl7V2MessageCollection) myController.getLeftSelectedItem());
        }
    });
    myDeleteMessageButton.setBorderPainted(false);
    myDeleteMessageButton.addMouseListener(new HoverButtonMouseAdapter(myDeleteMessageButton));
    myDeleteMessageButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/close.png")));
    messagesToolBar.add(myDeleteMessageButton);
    msgOpenButton.setBorderPainted(false);
    msgOpenButton.setToolTipText("Open Messages from File");
    msgOpenButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/open.png")));
    msgOpenButton.addMouseListener(new HoverButtonMouseAdapter(msgOpenButton));
    messagesToolBar.add(msgOpenButton);

    myMsgSaveButton = new JButton("");
    myMsgSaveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doSaveMessages();
        }
    });
    myMsgSaveButton.setBorderPainted(false);
    myMsgSaveButton.setToolTipText("Save Selected Messages to File");
    myMsgSaveButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/save.png")));
    myMsgSaveButton.addMouseListener(new HoverButtonMouseAdapter(myMsgSaveButton));
    messagesToolBar.add(myMsgSaveButton);

    myMessagesList = new JList();
    myMessagesList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (myMessagesList.getSelectedIndex() >= 0) {
                ourLog.debug("New messages selection " + myMessagesList.getSelectedIndex());
                myController.setLeftSelectedItem(myMessagesList.getSelectedValue());
                myOutboundConnectionsList.clearSelection();
                myOutboundConnectionsList.repaint();
                myInboundConnectionsList.clearSelection();
                myInboundConnectionsList.repaint();
            }
            updateLeftToolbarButtons();
        }
    });
    GridBagConstraints gbc_MessagesList = new GridBagConstraints();
    gbc_MessagesList.gridheight = 2;
    gbc_MessagesList.weightx = 1.0;
    gbc_MessagesList.weighty = 1.0;
    gbc_MessagesList.fill = GridBagConstraints.BOTH;
    gbc_MessagesList.gridx = 0;
    gbc_MessagesList.gridy = 2;
    messagesPanel.add(myMessagesList, gbc_MessagesList);

    JPanel connectionsPanel = new JPanel();
    leftSplitPane.setRightComponent(connectionsPanel);
    GridBagLayout gbl_connectionsPanel = new GridBagLayout();
    gbl_connectionsPanel.columnWidths = new int[] { 194, 0 };
    gbl_connectionsPanel.rowHeights = new int[] { 0, 30, 0, 0, 0, 0, 0 };
    gbl_connectionsPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_connectionsPanel.rowWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, Double.MIN_VALUE };
    connectionsPanel.setLayout(gbl_connectionsPanel);

    JLabel lblConnections = new JLabel("Sending Connections");
    lblConnections.setHorizontalAlignment(SwingConstants.CENTER);
    GridBagConstraints gbc_lblConnections = new GridBagConstraints();
    gbc_lblConnections.insets = new Insets(0, 0, 5, 0);
    gbc_lblConnections.anchor = GridBagConstraints.NORTH;
    gbc_lblConnections.fill = GridBagConstraints.HORIZONTAL;
    gbc_lblConnections.gridx = 0;
    gbc_lblConnections.gridy = 0;
    connectionsPanel.add(lblConnections, gbc_lblConnections);

    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    GridBagConstraints gbc_toolBar = new GridBagConstraints();
    gbc_toolBar.insets = new Insets(0, 0, 5, 0);
    gbc_toolBar.anchor = GridBagConstraints.NORTH;
    gbc_toolBar.fill = GridBagConstraints.HORIZONTAL;
    gbc_toolBar.gridx = 0;
    gbc_toolBar.gridy = 1;
    connectionsPanel.add(toolBar, gbc_toolBar);

    myAddConnectionButton = new JButton("");
    myAddConnectionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.addOutboundConnection();
        }
    });
    myAddConnectionButton.setBorderPainted(false);
    myAddConnectionButton.addMouseListener(new HoverButtonMouseAdapter(myAddConnectionButton));
    myAddConnectionButton.setBorder(null);
    myAddConnectionButton.setToolTipText("New Connection");
    myAddConnectionButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/add.png")));
    toolBar.add(myAddConnectionButton);

    myDeleteOutboundConnectionButton = new JButton("");
    myDeleteOutboundConnectionButton.setToolTipText("Delete Selected Connection");
    myDeleteOutboundConnectionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (myController.getLeftSelectedItem() instanceof OutboundConnection) {
                myController.removeOutboundConnection((OutboundConnection) myController.getLeftSelectedItem());
            }
        }
    });
    myDeleteOutboundConnectionButton.setBorderPainted(false);
    myDeleteOutboundConnectionButton
            .addMouseListener(new HoverButtonMouseAdapter(myDeleteOutboundConnectionButton));
    myDeleteOutboundConnectionButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/delete.png")));
    toolBar.add(myDeleteOutboundConnectionButton);

    myStartOneOutboundButton = new JButton("");
    myStartOneOutboundButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (myController.getLeftSelectedItem() instanceof OutboundConnection) {
                myController.startOutboundConnection((OutboundConnection) myController.getLeftSelectedItem());
            }
        }
    });
    myStartOneOutboundButton.setBorderPainted(false);
    myStartOneOutboundButton.setToolTipText("Start selected connection");
    myStartOneOutboundButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_one.png")));
    myStartOneOutboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartOneOutboundButton));
    toolBar.add(myStartOneOutboundButton);

    myStartAllOutboundButton = new JButton("");
    myStartAllOutboundButton.setBorderPainted(false);
    myStartAllOutboundButton.setToolTipText("Start all sending connections");
    myStartAllOutboundButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_all.png")));
    myStartAllOutboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartAllOutboundButton));
    myStartAllOutboundButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent theE) {
            myController.startAllOutboundConnections();
        }
    });
    toolBar.add(myStartAllOutboundButton);

    myStopAllOutboundButton = new JButton("");
    myStopAllOutboundButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.stopAllOutboundConnections();
        }
    });
    myStopAllOutboundButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/stop_all.png")));
    myStopAllOutboundButton.setToolTipText("Stop all sending connections");
    myStopAllOutboundButton.setBorderPainted(false);
    myStopAllOutboundButton.addMouseListener(new HoverButtonMouseAdapter(myStopAllOutboundButton));
    toolBar.add(myStopAllOutboundButton);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBorder(null);
    GridBagConstraints gbc_scrollPane = new GridBagConstraints();
    gbc_scrollPane.fill = GridBagConstraints.BOTH;
    gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
    gbc_scrollPane.gridx = 0;
    gbc_scrollPane.gridy = 2;
    connectionsPanel.add(scrollPane, gbc_scrollPane);

    myOutboundConnectionsList = new JList();
    myOutboundConnectionsList.setBorder(null);
    myOutboundConnectionsList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (myOutboundConnectionsList.getSelectedIndex() >= 0) {
                ourLog.debug(
                        "New outbound connection selection " + myOutboundConnectionsList.getSelectedIndex());
                myController.setLeftSelectedItem(myOutboundConnectionsList.getSelectedValue());
                myMessagesList.clearSelection();
                myMessagesList.repaint();
                myInboundConnectionsList.clearSelection();
                myInboundConnectionsList.repaint();
            }
            updateLeftToolbarButtons();
        }
    });
    scrollPane.setViewportView(myOutboundConnectionsList);

    JLabel lblReceivingConnections = new JLabel("Receiving Connections");
    lblReceivingConnections.setHorizontalAlignment(SwingConstants.CENTER);
    GridBagConstraints gbc_lblReceivingConnections = new GridBagConstraints();
    gbc_lblReceivingConnections.insets = new Insets(0, 0, 5, 0);
    gbc_lblReceivingConnections.gridx = 0;
    gbc_lblReceivingConnections.gridy = 3;
    connectionsPanel.add(lblReceivingConnections, gbc_lblReceivingConnections);

    JToolBar toolBar_1 = new JToolBar();
    toolBar_1.setFloatable(false);
    GridBagConstraints gbc_toolBar_1 = new GridBagConstraints();
    gbc_toolBar_1.anchor = GridBagConstraints.WEST;
    gbc_toolBar_1.insets = new Insets(0, 0, 5, 0);
    gbc_toolBar_1.gridx = 0;
    gbc_toolBar_1.gridy = 4;
    connectionsPanel.add(toolBar_1, gbc_toolBar_1);

    myAddInboundConnectionButton = new JButton("");
    myAddInboundConnectionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.addInboundConnection();
        }
    });
    myAddInboundConnectionButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/add.png")));
    myAddInboundConnectionButton.setToolTipText("New Connection");
    myAddInboundConnectionButton.setBorderPainted(false);
    myAddInboundConnectionButton.addMouseListener(new HoverButtonMouseAdapter(myAddInboundConnectionButton));
    toolBar_1.add(myAddInboundConnectionButton);

    myDeleteInboundConnectionButton = new JButton("");
    myDeleteInboundConnectionButton.setToolTipText("Delete Selected Connection");
    myDeleteInboundConnectionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (myController.getLeftSelectedItem() instanceof InboundConnection) {
                myController.removeInboundConnection((InboundConnection) myController.getLeftSelectedItem());
            }
        }
    });
    myDeleteInboundConnectionButton.setBorderPainted(false);
    myDeleteInboundConnectionButton
            .addMouseListener(new HoverButtonMouseAdapter(myDeleteInboundConnectionButton));
    myDeleteInboundConnectionButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/delete.png")));
    toolBar_1.add(myDeleteInboundConnectionButton);

    myStartOneInboundButton = new JButton("");
    myStartOneInboundButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (myController.getLeftSelectedItem() instanceof InboundConnection) {
                myController.startInboundConnection((InboundConnection) myController.getLeftSelectedItem());
            }
        }
    });
    myStartOneInboundButton.setBorderPainted(false);
    myStartOneInboundButton.setToolTipText("Start selected connection");
    myStartOneInboundButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_one.png")));
    myStartOneInboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartOneInboundButton));
    toolBar_1.add(myStartOneInboundButton);

    myStartAllInboundButton = new JButton("");
    myStartAllInboundButton.setBorderPainted(false);
    myStartAllInboundButton.setToolTipText("Start all receiving connections");
    myStartAllInboundButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_all.png")));
    myStartAllInboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartAllInboundButton));
    myStartAllInboundButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent theE) {
            myController.startAllInboundConnections();
        }
    });
    toolBar_1.add(myStartAllInboundButton);

    myStopAllInboundButton = new JButton("");
    myStopAllInboundButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.stopAllInboundConnections();
        }
    });
    myStopAllInboundButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/stop_all.png")));
    myStopAllInboundButton.setToolTipText("Stop all receiving connections");
    myStopAllInboundButton.setBorderPainted(false);
    myStopAllInboundButton.addMouseListener(new HoverButtonMouseAdapter(myStopAllInboundButton));
    toolBar_1.add(myStopAllInboundButton);

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setBorder(null);
    GridBagConstraints gbc_scrollPane_1 = new GridBagConstraints();
    gbc_scrollPane_1.fill = GridBagConstraints.BOTH;
    gbc_scrollPane_1.gridx = 0;
    gbc_scrollPane_1.gridy = 5;
    connectionsPanel.add(scrollPane_1, gbc_scrollPane_1);

    myInboundConnectionsList = new JList();
    myInboundConnectionsList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (myInboundConnectionsList.getSelectedIndex() >= 0) {
                ourLog.debug("New inbound connection selection " + myInboundConnectionsList.getSelectedIndex());
                myController.setLeftSelectedItem(myInboundConnectionsList.getSelectedValue());
                myMessagesList.clearSelection();
                myMessagesList.repaint();
                myOutboundConnectionsList.clearSelection();
                myOutboundConnectionsList.repaint();
                myInboundConnectionsList.repaint();
            }
            updateLeftToolbarButtons();
        }
    });
    scrollPane_1.setViewportView(myInboundConnectionsList);
    leftSplitPane.setDividerLocation(200);

    myWorkspacePanel = new JPanel();
    myWorkspacePanel.setBorder(null);
    outerSplitPane.setRightComponent(myWorkspacePanel);
    myWorkspacePanel.setLayout(new BorderLayout(0, 0));
    outerSplitPane.setDividerLocation(200);

    myLogScrollPane = new LogTable();
    myLogScrollPane.setPreferredSize(new Dimension(454, 120));
    myLogScrollPane.setMaximumSize(new Dimension(32767, 120));
    myframe.getContentPane().add(myLogScrollPane, BorderLayout.SOUTH);

    updateLogScrollPaneVisibility();

    updateLeftToolbarButtons();
}

From source file:samples.graph.PluggableRendererDemo.java

/**
 * @param jp    panel to which controls will be added
 *//*from w  w w  . j  a  v a2  s .  c  o m*/
protected void addBottomControls(final JPanel jp) {
    final JPanel control_panel = new JPanel();
    jp.add(control_panel, BorderLayout.SOUTH);
    control_panel.setLayout(new BorderLayout());
    final Box vertex_panel = Box.createVerticalBox();
    vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices"));
    final Box edge_panel = Box.createVerticalBox();
    edge_panel.setBorder(BorderFactory.createTitledBorder("Edges"));
    final Box both_panel = Box.createVerticalBox();

    control_panel.add(vertex_panel, BorderLayout.WEST);
    control_panel.add(edge_panel, BorderLayout.EAST);
    control_panel.add(both_panel, BorderLayout.CENTER);

    // set up vertex controls
    v_color = new JCheckBox("vertex seed coloring");
    v_color.addActionListener(this);
    v_stroke = new JCheckBox("<html>vertex selection<p>stroke highlighting</html>");
    v_stroke.addActionListener(this);
    v_labels = new JCheckBox("show vertex ranks (voltages)");
    v_labels.addActionListener(this);
    v_shape = new JCheckBox("vertex degree shapes");
    v_shape.addActionListener(this);
    v_size = new JCheckBox("vertex voltage size");
    v_size.addActionListener(this);
    v_size.setSelected(true);
    v_aspect = new JCheckBox("vertex degree ratio stretch");
    v_aspect.addActionListener(this);
    v_small = new JCheckBox("filter vertices of degree < " + VertexDisplayPredicate.MIN_DEGREE);
    v_small.addActionListener(this);

    vertex_panel.add(v_color);
    vertex_panel.add(v_stroke);
    vertex_panel.add(v_labels);
    vertex_panel.add(v_shape);
    vertex_panel.add(v_size);
    vertex_panel.add(v_aspect);
    vertex_panel.add(v_small);

    // set up edge controls
    JPanel gradient_panel = new JPanel(new GridLayout(1, 0));
    gradient_panel.setBorder(BorderFactory.createTitledBorder("Edge paint"));
    no_gradient = new JRadioButton("Solid color");
    no_gradient.addActionListener(this);
    no_gradient.setSelected(true);
    //      gradient_absolute = new JRadioButton("Absolute gradient");
    //      gradient_absolute.addActionListener(this);
    gradient_relative = new JRadioButton("Gradient");
    gradient_relative.addActionListener(this);
    ButtonGroup bg_grad = new ButtonGroup();
    bg_grad.add(no_gradient);
    bg_grad.add(gradient_relative);
    //bg_grad.add(gradient_absolute);
    gradient_panel.add(no_gradient);
    //gradientGrid.add(gradient_absolute);
    gradient_panel.add(gradient_relative);

    JPanel shape_panel = new JPanel(new GridLayout(3, 2));
    shape_panel.setBorder(BorderFactory.createTitledBorder("Edge shape"));
    e_line = new JRadioButton("line");
    e_line.addActionListener(this);
    e_line.setSelected(true);
    //        e_bent = new JRadioButton("bent line");
    //        e_bent.addActionListener(this);
    e_wedge = new JRadioButton("wedge");
    e_wedge.addActionListener(this);
    e_quad = new JRadioButton("quad curve");
    e_quad.addActionListener(this);
    e_cubic = new JRadioButton("cubic curve");
    e_cubic.addActionListener(this);
    ButtonGroup bg_shape = new ButtonGroup();
    bg_shape.add(e_line);
    //        bg.add(e_bent);
    bg_shape.add(e_wedge);
    bg_shape.add(e_quad);
    bg_shape.add(e_cubic);
    shape_panel.add(e_line);
    //        shape_panel.add(e_bent);
    shape_panel.add(e_wedge);
    shape_panel.add(e_quad);
    shape_panel.add(e_cubic);
    fill_edges = new JCheckBox("fill edge shapes");
    fill_edges.setSelected(false);
    fill_edges.addActionListener(this);
    shape_panel.add(fill_edges);
    shape_panel.setOpaque(true);
    e_color = new JCheckBox("edge weight highlighting");
    e_color.addActionListener(this);
    e_labels = new JCheckBox("show edge weights");
    e_labels.addActionListener(this);
    e_uarrow_pred = new JCheckBox("undirected");
    e_uarrow_pred.addActionListener(this);
    e_darrow_pred = new JCheckBox("directed");
    e_darrow_pred.addActionListener(this);
    e_darrow_pred.setSelected(true);
    JPanel arrow_panel = new JPanel(new GridLayout(1, 0));
    arrow_panel.setBorder(BorderFactory.createTitledBorder("Show arrows"));
    arrow_panel.add(e_uarrow_pred);
    arrow_panel.add(e_darrow_pred);

    e_show_d = new JCheckBox("directed");
    e_show_d.addActionListener(this);
    e_show_d.setSelected(true);
    e_show_u = new JCheckBox("undirected");
    e_show_u.addActionListener(this);
    e_show_u.setSelected(true);
    JPanel show_edge_panel = new JPanel(new GridLayout(1, 0));
    show_edge_panel.setBorder(BorderFactory.createTitledBorder("Show edges"));
    show_edge_panel.add(e_show_u);
    show_edge_panel.add(e_show_d);

    shape_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(shape_panel);
    gradient_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(gradient_panel);
    show_edge_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(show_edge_panel);
    arrow_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(arrow_panel);

    e_color.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(e_color);
    e_labels.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(e_labels);

    // set up zoom controls
    zoom_at_mouse = new JCheckBox("<html><center>zoom at mouse<p>(wheel only)</center></html>");
    zoom_at_mouse.addActionListener(this);

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

    Box zoomPanel = Box.createVerticalBox();
    zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom"));
    plus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(plus);
    minus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(minus);
    zoom_at_mouse.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(zoom_at_mouse);

    // add font and zoom controls to center panel
    font = new JCheckBox("bold text");
    font.addActionListener(this);
    font.setAlignmentX(Component.CENTER_ALIGNMENT);

    both_panel.add(zoomPanel);
    both_panel.add(font);

    JComboBox modeBox = gm.getModeComboBox();
    modeBox.setAlignmentX(Component.CENTER_ALIGNMENT);
    JPanel modePanel = new JPanel(new BorderLayout()) {
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(modeBox);
    both_panel.add(modePanel);
}