Example usage for java.awt BorderLayout WEST

List of usage examples for java.awt BorderLayout WEST

Introduction

In this page you can find the example usage for java.awt BorderLayout WEST.

Prototype

String WEST

To view the source code for java.awt BorderLayout WEST.

Click Source Link

Document

The west layout constraint (left side of container).

Usage

From source file:com.openbravo.pos.sales.JRetailTicketPreviewTicket.java

/** This method is called from within the constructor to
 * initialize the form.//  w  w w  . ja v a  2s . co  m
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    buttonGroup1 = new javax.swing.ButtonGroup();
    m_jOptions = new javax.swing.JPanel();
    m_jButtons = new javax.swing.JPanel();
    m_jTicketId = new javax.swing.JLabel();
    jButtonSearch = new javax.swing.JButton();
    //    m_jEdit = new javax.swing.JButton();
    m_jRefund = new javax.swing.JButton();
    m_jPrint = new javax.swing.JButton();
    jPanel2 = new javax.swing.JPanel();
    m_jPanelTicket = new javax.swing.JPanel();
    jPanel3 = new javax.swing.JPanel();
    jPanel4 = new javax.swing.JPanel();
    // m_jKeys = new com.openbravo.editor.JEditorKeys();
    //        jPanel5 = new javax.swing.JPanel();
    jButton1 = new javax.swing.JButton();
    //        m_jTicketEditor = new com.openbravo.editor.JEditorIntegerPositive();
    jPanel1 = new javax.swing.JPanel();
    //        jrbSales = new javax.swing.JRadioButton();
    //     jrbRefunds = new javax.swing.JRadioButton();

    setLayout(new java.awt.BorderLayout());

    m_jOptions.setLayout(new java.awt.BorderLayout());

    m_jButtons.setPreferredSize(new java.awt.Dimension(506, 56));
    m_jButtons.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

    m_jTicketId.setBackground(java.awt.Color.white);
    m_jTicketId.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    m_jTicketId.setBorder(javax.swing.BorderFactory.createCompoundBorder(
            javax.swing.BorderFactory
                    .createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")),
            javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4)));
    m_jTicketId.setOpaque(true);
    m_jTicketId.setPreferredSize(new java.awt.Dimension(160, 25));
    m_jTicketId.setRequestFocusEnabled(false);
    m_jButtons.add(m_jTicketId, new org.netbeans.lib.awtextra.AbsoluteConstraints(5, 15, -1, 30));

    jButtonSearch.setBackground(new java.awt.Color(255, 255, 255));
    jButtonSearch
            .setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/search.png"))); // NOI18N
    jButtonSearch.setText(AppLocal.getIntString("label.search")); // NOI18N
    jButtonSearch.setFocusPainted(false);
    jButtonSearch.setFocusable(false);
    jButtonSearch.setMargin(new java.awt.Insets(0, 0, 0, 0));
    jButtonSearch.setRequestFocusEnabled(false);
    jButtonSearch.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonSearchActionPerformed(evt);
        }
    });
    m_jButtons.add(jButtonSearch, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 12, 85, 35));

    //        m_jEdit.setBackground(new java.awt.Color(255, 255, 255));
    //        m_jEdit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/edit.png"))); // NOI18N
    //        m_jEdit.setText(AppLocal.getIntString("button.edit")); // NOI18N
    //        m_jEdit.setFocusPainted(false);
    //        m_jEdit.setFocusable(false);
    //        m_jEdit.setMargin(new java.awt.Insets(8, 14, 8, 14));
    //        m_jEdit.setRequestFocusEnabled(false);
    //        m_jEdit.addActionListener(new java.awt.event.ActionListener() {
    //            public void actionPerformed(java.awt.event.ActionEvent evt) {
    //                m_jEditActionPerformed(evt);
    //            }
    //        });
    //        m_jButtons.add(m_jEdit, new org.netbeans.lib.awtextra.AbsoluteConstraints(258, 12, 85, 35));

    //        m_jRefund.setBackground(new java.awt.Color(255, 255, 255));
    //        m_jRefund.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/inbox.png"))); // NOI18N
    //        m_jRefund.setText(AppLocal.getIntString("button.refund")); // NOI18N
    //        m_jRefund.setFocusPainted(false);
    //        m_jRefund.setFocusable(false);
    //        m_jRefund.setMargin(new java.awt.Insets(8, 14, 8, 14));
    //        m_jRefund.setRequestFocusEnabled(false);
    //        m_jRefund.addActionListener(new java.awt.event.ActionListener() {
    //            public void actionPerformed(java.awt.event.ActionEvent evt) {
    //                m_jRefundActionPerformed(evt);
    //            }
    //        });
    //        m_jButtons.add(m_jRefund, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 10, 50, 35));

    m_jPrint.setBackground(new java.awt.Color(255, 255, 255));
    m_jPrint.setIcon(
            new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/yast_printer.png"))); // NOI18N
    m_jPrint.setText(AppLocal.getIntString("button.print")); // NOI18N
    m_jPrint.setFocusPainted(false);
    m_jPrint.setFocusable(false);
    m_jPrint.setMargin(new java.awt.Insets(0, 0, 0, 0));
    m_jPrint.setRequestFocusEnabled(false);
    m_jPrint.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            m_jPrintActionPerformed(evt);
        }
    });
    m_jButtons.add(m_jPrint, new org.netbeans.lib.awtextra.AbsoluteConstraints(258, 12, 85, 35));

    m_jOptions.add(m_jButtons, java.awt.BorderLayout.WEST);

    jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
    m_jOptions.add(jPanel2, java.awt.BorderLayout.CENTER);

    add(m_jOptions, java.awt.BorderLayout.NORTH);

    m_jPanelTicket.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    m_jPanelTicket.setLayout(new java.awt.BorderLayout());
    add(m_jPanelTicket, java.awt.BorderLayout.CENTER);

    jPanel3.setLayout(new java.awt.BorderLayout());

    jPanel4.setPreferredSize(new java.awt.Dimension(175, 276));
    jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS));

    //        m_jKeys.addActionListener(new java.awt.event.ActionListener() {
    //            public void actionPerformed(java.awt.event.ActionEvent evt) {
    //                m_jKeysActionPerformed(evt);
    //            }
    //        });
    //        jPanel4.add(m_jKeys);

    //  jPanel5.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    //  jPanel5.setPreferredSize(new java.awt.Dimension(201, 60));
    //  jPanel5.setLayout(new java.awt.GridBagLayout());

    //        jButton1.setBackground(new java.awt.Color(255, 255, 255));
    //        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/button_ok.png"))); // NOI18N
    //        jButton1.setFocusPainted(false);
    //        jButton1.setFocusable(false);
    //        jButton1.setMargin(new java.awt.Insets(8, 14, 8, 14));
    //        jButton1.setRequestFocusEnabled(false);
    //        jButton1.addActionListener(new java.awt.event.ActionListener() {
    //            public void actionPerformed(java.awt.event.ActionEvent evt) {
    //                jButton1ActionPerformed(evt);
    //            }
    //        });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
    //        jPanel5.add(jButton1, gridBagConstraints);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    //   jPanel5.add(m_jTicketEditor, gridBagConstraints);

    //  jPanel4.add(jPanel5);

    jPanel3.add(jPanel4, java.awt.BorderLayout.NORTH);

    jPanel1.setPreferredSize(new java.awt.Dimension(130, 25));

    //        buttonGroup1.add(jrbSales);
    //        jrbSales.setText(AppLocal.getIntString("label.sales")); // NOI18N
    //        jrbSales.setFocusPainted(false);
    //        jrbSales.setFocusable(false);
    //        jrbSales.setRequestFocusEnabled(false);
    //        jPanel1.add(jrbSales);

    //        buttonGroup1.add(jrbRefunds);
    //        jrbRefunds.setText(AppLocal.getIntString("label.refunds")); // NOI18N
    //        jrbRefunds.setFocusPainted(false);
    //        jrbRefunds.setFocusable(false);
    //        jrbRefunds.setRequestFocusEnabled(false);
    //        jPanel1.add(jrbRefunds);

    jPanel3.add(jPanel1, java.awt.BorderLayout.CENTER);

    add(jPanel3, java.awt.BorderLayout.EAST);
}

From source file:org.esa.snap.rcp.statistics.ScatterPlotPanel.java

private JPanel createInputParameterPanel() {
    final PropertyDescriptor boxSizeDescriptor = bindingContext.getPropertySet()
            .getDescriptor(PROPERTY_NAME_BOX_SIZE);
    boxSizeDescriptor.setValueRange(new ValueRange(1, 101));
    boxSizeDescriptor.setAttribute("stepSize", 2);
    boxSizeDescriptor.setValidator((property, value) -> {
        if (((Number) value).intValue() % 2 == 0) {
            throw new ValidationException("Only odd values allowed as box size.");
        }/*from  w  w w . ja  va 2  s  . c  o  m*/
    });
    final JSpinner boxSizeSpinner = new JSpinner();
    bindingContext.bind(PROPERTY_NAME_BOX_SIZE, boxSizeSpinner);

    final JPanel boxSizePanel = new JPanel(new BorderLayout(5, 3));
    boxSizePanel.add(new JLabel("Box size:"), BorderLayout.WEST);
    boxSizePanel.add(boxSizeSpinner);

    correlativeFieldSelector = new CorrelativeFieldSelector(bindingContext);

    final JPanel pointDataSourcePanel = new JPanel(new BorderLayout(5, 3));
    pointDataSourcePanel.add(correlativeFieldSelector.pointDataSourceLabel, BorderLayout.NORTH);
    pointDataSourcePanel.add(correlativeFieldSelector.pointDataSourceList);

    final JPanel pointDataFieldPanel = new JPanel(new BorderLayout(5, 3));
    pointDataFieldPanel.add(correlativeFieldSelector.dataFieldLabel, BorderLayout.NORTH);
    pointDataFieldPanel.add(correlativeFieldSelector.dataFieldList);

    final JCheckBox xLogCheck = new JCheckBox("Log10 scaled");
    bindingContext.bind(PROPERTY_NAME_X_AXIS_LOG_SCALED, xLogCheck);
    final JPanel xAxisOptionPanel = new JPanel(new BorderLayout());
    xAxisOptionPanel.add(xAxisRangeControl.getPanel());
    xAxisOptionPanel.add(xLogCheck, BorderLayout.SOUTH);

    final JCheckBox yLogCheck = new JCheckBox("Log10 scaled");
    bindingContext.bind(PROPERTY_NAME_Y_AXIS_LOG_SCALED, yLogCheck);
    final JPanel yAxisOptionPanel = new JPanel(new BorderLayout());
    yAxisOptionPanel.add(yAxisRangeControl.getPanel());
    yAxisOptionPanel.add(yLogCheck, BorderLayout.SOUTH);

    final JCheckBox acceptableCheck = new JCheckBox("Show tolerance range");
    JLabel fieldPrefix = new JLabel("+/-");
    final JTextField acceptableField = new JTextField();
    acceptableField.setPreferredSize(new Dimension(40, acceptableField.getPreferredSize().height));
    acceptableField.setHorizontalAlignment(JTextField.RIGHT);
    final JLabel percentLabel = new JLabel(" %");
    bindingContext.bind(PROPERTY_NAME_SHOW_ACCEPTABLE_DEVIATION, acceptableCheck);
    bindingContext.bind(PROPERTY_NAME_ACCEPTABLE_DEVIATION, acceptableField);
    bindingContext.getBinding(PROPERTY_NAME_ACCEPTABLE_DEVIATION).addComponent(percentLabel);
    bindingContext.getBinding(PROPERTY_NAME_ACCEPTABLE_DEVIATION).addComponent(fieldPrefix);
    bindingContext.bindEnabledState(PROPERTY_NAME_ACCEPTABLE_DEVIATION, true,
            PROPERTY_NAME_SHOW_ACCEPTABLE_DEVIATION, true);

    final JPanel confidencePanel = GridBagUtils.createPanel();
    GridBagConstraints confidencePanelConstraints = GridBagUtils
            .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=5,weighty=0,weightx=1");
    GridBagUtils.addToPanel(confidencePanel, acceptableCheck, confidencePanelConstraints,
            "gridy=0,gridwidth=3");
    GridBagUtils.addToPanel(confidencePanel, fieldPrefix, confidencePanelConstraints,
            "weightx=0,insets.left=22,gridy=1,gridx=0,insets.top=4,gridwidth=1");
    GridBagUtils.addToPanel(confidencePanel, acceptableField, confidencePanelConstraints,
            "weightx=1,gridx=1,insets.left=2,insets.top=2");
    GridBagUtils.addToPanel(confidencePanel, percentLabel, confidencePanelConstraints,
            "weightx=0,gridx=2,insets.left=0,insets.top=4");

    final JCheckBox regressionCheck = new JCheckBox("Show regression line");
    bindingContext.bind(PROPERTY_NAME_SHOW_REGRESSION_LINE, regressionCheck);

    // UI arrangement

    JPanel middlePanel = GridBagUtils.createPanel();
    GridBagConstraints middlePanelConstraints = GridBagUtils
            .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=6,weighty=0,weightx=1");
    GridBagUtils.addToPanel(middlePanel, boxSizePanel, middlePanelConstraints, "gridy=0,insets.left=6");
    GridBagUtils.addToPanel(middlePanel, pointDataSourcePanel, middlePanelConstraints, "gridy=1");
    GridBagUtils.addToPanel(middlePanel, pointDataFieldPanel, middlePanelConstraints, "gridy=2");
    GridBagUtils.addToPanel(middlePanel, xAxisOptionPanel, middlePanelConstraints, "gridy=3,insets.left=0");
    GridBagUtils.addToPanel(middlePanel, yAxisOptionPanel, middlePanelConstraints, "gridy=4");
    GridBagUtils.addToPanel(middlePanel, new JSeparator(), middlePanelConstraints, "gridy=5,insets.left=4");
    GridBagUtils.addToPanel(middlePanel, confidencePanel, middlePanelConstraints,
            "gridy=6,fill=HORIZONTAL,insets.left=-4");
    GridBagUtils.addToPanel(middlePanel, regressionCheck, middlePanelConstraints,
            "gridy=7,insets.left=-4,insets.top=8");

    return middlePanel;
}

From source file:userinterface.graph.Histogram.java

/**
 * Generates the property dialog for a Histogram. Allows the user to select either a new or an exisitng Histogram
 * to plot data on/* w w w  . j a  va  2  s  . co m*/
 * 
 * @param defaultSeriesName
 * @param handler instance of {@link GUIGraphHandler}
 * @param minVal the min value in data cache
 * @param maxVal the max value in data cache
 * @return Either a new instance of a Histogram or an old one depending on what the user selects
 */

public static Pair<Histogram, SeriesKey> showPropertiesDialog(String defaultSeriesName, GUIGraphHandler handler,
        double minVal, double maxVal) {

    // make sure that the probabilities are valid
    if (maxVal > 1.0)
        maxVal = 1.0;
    if (minVal < 0.0)
        minVal = 0.0;

    // set properties for the dialog
    JDialog dialog = new JDialog(GUIPrism.getGUI(), "Histogram properties", true);
    dialog.setLayout(new BorderLayout());

    JPanel p1 = new JPanel(new FlowLayout());
    p1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
            "Number of buckets"));

    JPanel p2 = new JPanel(new FlowLayout());
    p2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
            "Series name"));

    JSpinner buckets = new JSpinner(new SpinnerNumberModel(10, 5, Integer.MAX_VALUE, 1));
    buckets.setToolTipText("Select the number of buckets for this Histogram");

    // provides the ability to select a new or an old histogram to plot the series on
    JTextField seriesName = new JTextField(defaultSeriesName);
    JRadioButton newSeries = new JRadioButton("New Histogram");
    JRadioButton existing = new JRadioButton("Existing Histogram");
    newSeries.setSelected(true);
    JPanel seriesSelectPanel = new JPanel();
    seriesSelectPanel.setLayout(new BoxLayout(seriesSelectPanel, BoxLayout.Y_AXIS));
    JPanel seriesTypeSelect = new JPanel(new FlowLayout());
    JPanel seriesOptionsPanel = new JPanel(new FlowLayout());
    seriesTypeSelect.add(newSeries);
    seriesTypeSelect.add(existing);
    JComboBox<String> seriesOptions = new JComboBox<>();
    seriesOptionsPanel.add(seriesOptions);
    seriesSelectPanel.add(seriesTypeSelect);
    seriesSelectPanel.add(seriesOptionsPanel);
    seriesSelectPanel.setBorder(BorderFactory
            .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Add series to"));

    // provides ability to select the min/max range of the plot
    JLabel minValsLabel = new JLabel("Min range:");
    JSpinner minVals = new JSpinner(new SpinnerNumberModel(0.0, 0.0, minVal, 0.01));
    minVals.setToolTipText("Does not allow value more than the min value in the probabilities");
    JLabel maxValsLabel = new JLabel("Max range:");
    JSpinner maxVals = new JSpinner(new SpinnerNumberModel(1.0, maxVal, 1.0, 0.01));
    maxVals.setToolTipText("Does not allow value less than the max value in the probabilities");
    JPanel minMaxPanel = new JPanel();
    minMaxPanel.setLayout(new BoxLayout(minMaxPanel, BoxLayout.X_AXIS));
    JPanel leftValsPanel = new JPanel(new BorderLayout());
    JPanel rightValsPanel = new JPanel(new BorderLayout());
    minMaxPanel.setBorder(
            BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Range"));
    leftValsPanel.add(minValsLabel, BorderLayout.WEST);
    leftValsPanel.add(minVals, BorderLayout.CENTER);
    rightValsPanel.add(maxValsLabel, BorderLayout.WEST);
    rightValsPanel.add(maxVals, BorderLayout.CENTER);
    minMaxPanel.add(leftValsPanel);
    minMaxPanel.add(rightValsPanel);

    // fill the old histograms in the property dialog

    boolean found = false;
    for (int i = 0; i < handler.getNumModels(); i++) {

        if (handler.getModel(i) instanceof Histogram) {

            seriesOptions.addItem(handler.getGraphName(i));
            found = true;
        }

    }

    existing.setEnabled(found);
    seriesOptions.setEnabled(false);

    // the bottom panel
    JPanel options = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    JButton ok = new JButton("Plot");
    JButton cancel = new JButton("Cancel");

    // bind keyboard keys to plot and cancel buttons to improve usability

    ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok");
    ok.getActionMap().put("ok", new AbstractAction() {

        private static final long serialVersionUID = -7324877661936685228L;

        @Override
        public void actionPerformed(ActionEvent e) {

            ok.doClick();

        }
    });

    cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            "ok");
    cancel.getActionMap().put("ok", new AbstractAction() {

        private static final long serialVersionUID = 2642213543774356676L;

        @Override
        public void actionPerformed(ActionEvent e) {

            cancel.doClick();

        }
    });

    //Action listener for the new series radio button
    newSeries.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (newSeries.isSelected()) {

                existing.setSelected(false);
                seriesOptions.setEnabled(false);
                buckets.setEnabled(true);
                buckets.setToolTipText("Select the number of buckets for this Histogram");
                minVals.setEnabled(true);
                maxVals.setEnabled(true);
            }
        }
    });

    //Action listener for the existing series radio button
    existing.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            if (existing.isSelected()) {

                newSeries.setSelected(false);
                seriesOptions.setEnabled(true);
                buckets.setEnabled(false);
                minVals.setEnabled(false);
                maxVals.setEnabled(false);
                buckets.setToolTipText("Number of buckets can't be changed on an existing Histogram");
            }

        }
    });

    //Action listener for the plot button
    ok.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            dialog.dispose();

            if (newSeries.isSelected()) {

                hist = new Histogram();
                hist.setNumOfBuckets((int) buckets.getValue());
                hist.setIsNew(true);

            } else if (existing.isSelected()) {

                String HistName = (String) seriesOptions.getSelectedItem();
                hist = (Histogram) handler.getModel(HistName);
                hist.setIsNew(false);

            }

            key = hist.addSeries(seriesName.getText());

            if (minVals.isEnabled() && maxVals.isEnabled()) {

                hist.setMinProb((double) minVals.getValue());
                hist.setMaxProb((double) maxVals.getValue());

            }
        }
    });

    //Action listener for the cancel button
    cancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
            hist = null;
        }
    });

    dialog.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosed(WindowEvent e) {

            hist = null;
        }
    });

    p1.add(buckets, BorderLayout.CENTER);

    p2.add(seriesName, BorderLayout.CENTER);

    options.add(ok);
    options.add(cancel);

    // add everything to the main panel of the dialog
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(seriesSelectPanel);
    mainPanel.add(p1);
    mainPanel.add(p2);
    mainPanel.add(minMaxPanel);

    // add main panel to the dialog
    dialog.add(mainPanel, BorderLayout.CENTER);
    dialog.add(options, BorderLayout.SOUTH);

    // set dialog properties
    dialog.setSize(320, 290);
    dialog.setLocationRelativeTo(GUIPrism.getGUI());
    dialog.setVisible(true);

    // return the user selected Histogram with the properties set
    return new Pair<Histogram, SeriesKey>(hist, key);
}

From source file:org.apache.jmeter.protocol.http.config.gui.UrlConfigGuiClassifier.java

/**
 * This method defines the Panel for the HTTP path, 'Follow Redirects'
 * 'Use KeepAlive', and 'Use multipart for HTTP POST' elements.
 *
 * @return JPanel The Panel for the path, 'Follow Redirects' and 'Use
 *         KeepAlive' elements.//w  ww  .j  a v a2  s  .  co m
 */
protected Component getPathPanel() {
    path = new JTextField(15);

    JLabel label = new JLabel(JMeterUtils.getResString("path")); //$NON-NLS-1$
    label.setLabelFor(path);

    if (notConfigOnly) {
        followRedirects = new JCheckBox(JMeterUtils.getResString("follow_redirects")); // $NON-NLS-1$
        followRedirects.setSelected(true);
        followRedirects.addChangeListener(this);

        autoRedirects = new JCheckBox(JMeterUtils.getResString("follow_redirects_auto")); //$NON-NLS-1$
        autoRedirects.addChangeListener(this);
        autoRedirects.setSelected(false);// Default changed in 2.3 and again in 2.4

        useKeepAlive = new JCheckBox(JMeterUtils.getResString("use_keepalive")); // $NON-NLS-1$
        useKeepAlive.setSelected(true);

        useMultipartForPost = new JCheckBox(JMeterUtils.getResString("use_multipart_for_http_post")); // $NON-NLS-1$
        useMultipartForPost.setSelected(false);

        useBrowserCompatibleMultipartMode = new JCheckBox(
                JMeterUtils.getResString("use_multipart_mode_browser")); // $NON-NLS-1$
        useBrowserCompatibleMultipartMode
                .setSelected(HTTPSamplerBase.BROWSER_COMPATIBLE_MULTIPART_MODE_DEFAULT);

    }

    JPanel pathPanel = new JPanel(new BorderLayout(5, 0));
    pathPanel.add(label, BorderLayout.WEST);
    pathPanel.add(path, BorderLayout.CENTER);
    pathPanel.setMinimumSize(pathPanel.getPreferredSize());

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(pathPanel);
    if (notConfigOnly) {
        JPanel optionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        optionPanel.add(autoRedirects);
        optionPanel.add(followRedirects);
        optionPanel.add(useKeepAlive);
        optionPanel.add(useMultipartForPost);
        optionPanel.add(useBrowserCompatibleMultipartMode);
        optionPanel.setMinimumSize(optionPanel.getPreferredSize());
        panel.add(optionPanel);
    }

    return panel;
}

From source file:ch.fork.AdHocRailway.ui.AdHocRailway.java

private void initToolbar() {
    /* FILE *//*  w  w  w.  ja  va  2s.  c  o  m*/
    final JToolBar fileToolBar = new JToolBar();

    final JButton newFileToolBarButton = new SmallToolbarButton(new NewFileAction());
    final JButton openFileToolBarButton = new SmallToolbarButton(new OpenFileAction());
    final JButton openDatabaseToolBarButton = new SmallToolbarButton(new OpenDatabaseAction());
    final JButton saveToolBarButton = new SmallToolbarButton(new SaveAction());
    final JButton exitToolBarButton = new SmallToolbarButton(new ExitAction());

    fileToolBar.add(newFileToolBarButton);
    fileToolBar.add(openFileToolBarButton);
    fileToolBar.add(openDatabaseToolBarButton);
    fileToolBar.add(saveToolBarButton);
    fileToolBar.add(exitToolBarButton);

    /* DIGITAL */
    final JToolBar digitalToolBar = new JToolBar();
    turnoutsToolBarButton = new SmallToolbarButton(new TurnoutAction());
    routesToolBarButton = new SmallToolbarButton(new RoutesAction());
    locomotivesToolBarButton = new SmallToolbarButton(new LocomotivesAction());
    preferencesToolBarButton = new SmallToolbarButton(new PreferencesAction());

    digitalToolBar.add(turnoutsToolBarButton);
    digitalToolBar.add(routesToolBarButton);
    digitalToolBar.add(locomotivesToolBarButton);
    digitalToolBar.add(preferencesToolBarButton);

    /* SRCP / AdHoc-Brain */
    final JToolBar daemonToolBar = new JToolBar();
    railwayDeviceLabelLabel = new JLabel();

    setRailwayDeviceLabelText();
    connectToolBarButton = new SmallToolbarButton(new ConnectAction());
    disconnectToolBarButton = new SmallToolbarButton(new DisconnectAction());
    disconnectToolBarButton.setEnabled(false);

    daemonToolBar.add(railwayDeviceLabelLabel);
    daemonToolBar.addSeparator();
    daemonToolBar.add(connectToolBarButton);
    daemonToolBar.add(disconnectToolBarButton);

    /* VIEWS */
    final JToolBar viewToolBar = new JToolBar();
    final JButton refreshButton = new SmallToolbarButton(new RefreshAction());
    toggleFullscreenButton = new SmallToolbarButton(new ToggleFullscreenAction());

    viewToolBar.add(refreshButton);
    viewToolBar.add(toggleFullscreenButton);

    /* ERROR */
    final ErrorPanel errorPanel = new ErrorPanel();
    ExceptionProcessor.getInstance(errorPanel);

    toolbarPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
    addToolBar(fileToolBar);
    addToolBar(digitalToolBar);
    addToolBar(daemonToolBar);
    addToolBar(viewToolBar);

    final JPanel toolbarErrorPanel = new JPanel(new BorderLayout(10, 10));
    toolbarErrorPanel.add(toolbarPanel, BorderLayout.WEST);
    toolbarErrorPanel.add(errorPanel, BorderLayout.EAST);

    add(toolbarErrorPanel, BorderLayout.PAGE_START);
}

From source file:edu.purdue.cc.bionet.ui.CorrelationDisplayPanel.java

/**
 * Adds all of the necessary Components to this Component.
 */// www. jav  a  2 s.c o m
private void buildPanel() {

    Language language = Settings.getLanguage();
    this.correlationMethodMenu = new JMenu(language.get("Correlation Method"));
    this.correlationMethodMenuButtonGroup = new ButtonGroup();
    this.pearsonCalculationMenuItem = new JRadioButtonMenuItem(language.get("Pearson"), true);
    this.spearmanCalculationMenuItem = new JRadioButtonMenuItem(language.get("Spearman"));
    this.kendallCalculationMenuItem = new JRadioButtonMenuItem(language.get("Kendall"));

    // layout menu itmes
    this.layoutMenu = new JMenu(language.get("Layout"));
    this.layoutMenuButtonGroup = new ButtonGroup();
    this.multipleCirclesLayoutMenuItem = new JRadioButtonMenuItem(language.get("Multiple Circles"));
    this.singleCircleLayoutMenuItem = new JRadioButtonMenuItem(language.get("Single Circle"), true);
    this.randomLayoutMenuItem = new JRadioButtonMenuItem(language.get("Random"));
    this.heatMapLayoutMenuItem = new JRadioButtonMenuItem(language.get("Heat Map"));
    this.kkLayoutMenuItem = new JRadioButtonMenuItem(language.get("Kamada-Kawai"));
    //      this.frLayoutMenuItem = 
    //            new JRadioButtonMenuItem( language.get( "Fruchterman-Reingold" ));
    //      this.springLayoutMenuItem = 
    //               new JRadioButtonMenuItem( language.get( "Spring Layout" ));
    this.frSpringLayoutMenuItem = new JRadioButtonMenuItem(language.get("Spring Layout"));
    //      this.animatedLayoutMenuItem = new JCheckBoxMenuItem( 
    //         language.get( "Fruchterman-Reingold Spring Embedding" ));

    // view menu items
    this.viewMenu = new JMenu(language.get("View"));
    this.zoomInViewMenuItem = new JMenuItem(language.get("Zoom In"), KeyEvent.VK_I);
    this.zoomOutViewMenuItem = new JMenuItem(language.get("Zoom Out"), KeyEvent.VK_O);
    this.fitToWindowViewMenuItem = new JMenuItem(language.get("Fit to Window"), KeyEvent.VK_F);
    this.selectAllViewMenuItem = new JMenuItem(language.get("Select All"), KeyEvent.VK_A);
    this.clearSelectionViewMenuItem = new JMenuItem(language.get("Clear Selection"), KeyEvent.VK_C);
    this.invertSelectionViewMenuItem = new JMenuItem(language.get("Invert Selection"), KeyEvent.VK_I);
    this.selectCorrelatedViewMenuItem = new JMenuItem(language.get("Select Correlated to Selection"),
            KeyEvent.VK_R);
    this.hideSelectedViewMenuItem = new JMenuItem(language.get("Hide Selected"), KeyEvent.VK_H);
    this.hideUnselectedViewMenuItem = new JMenuItem(language.get("Hide Unselected"), KeyEvent.VK_U);
    this.hideUncorrelatedViewMenuItem = new JMenuItem(language.get("Hide Uncorrelated to Selection"),
            KeyEvent.VK_L);
    this.hideOrphansViewMenuItem = new JMenuItem(language.get("Hide Orphans"), KeyEvent.VK_P);
    this.showCorrelatedViewMenuItem = new JMenuItem(language.get("Show All Correlated to Visible"),
            KeyEvent.VK_S);
    this.saveImageAction = new SaveImageAction(language.get("Save Main Graph Image") + "...", null);

    // groups menu items
    this.groupsMenu = new JMenu(language.get("Groups"));
    this.resetSampleGroupsMenuItem = new JMenuItem(language.get("Reset Sample Groups"), KeyEvent.VK_R);
    this.chooseSampleGroupsMenuItem = new JMenuItem(language.get("Choose Sample Groups") + "...",
            KeyEvent.VK_C);

    // color menu items
    this.colorMenu = new JMenu(language.get("Color"));
    this.colorMenuButtonGroup = new ButtonGroup();
    this.normalColorMenuItem = new JRadioButtonMenuItem(language.get("Normal Color"), true);
    this.highContrastColorMenuItem = new JRadioButtonMenuItem(language.get("High Contrast Color"));

    // CORRELATION FILTER ELEMENTS
    JPanel leftPanel = new JPanel(new BorderLayout());
    this.moleculeFilterPanel = new MoleculeFilterPanel();
    leftPanel.add(moleculeFilterPanel, BorderLayout.CENTER);
    this.correlationFilterPanel = new CorrelationFilterPanel();
    leftPanel.add(this.correlationFilterPanel, BorderLayout.SOUTH);

    //CALCULATION MENU
    this.correlationMethodMenu.setMnemonic(KeyEvent.VK_C);
    this.correlationMethodMenu.getAccessibleContext()
            .setAccessibleDescription(language.get("Perform Data Calculations"));
    this.correlationMethodMenuButtonGroup.add(this.pearsonCalculationMenuItem);
    this.correlationMethodMenuButtonGroup.add(this.spearmanCalculationMenuItem);
    this.correlationMethodMenuButtonGroup.add(this.kendallCalculationMenuItem);
    this.pearsonCalculationMenuItem.setMnemonic(KeyEvent.VK_P);
    this.spearmanCalculationMenuItem.setMnemonic(KeyEvent.VK_S);
    this.kendallCalculationMenuItem.setMnemonic(KeyEvent.VK_K);
    this.correlationMethodMenu.add(this.pearsonCalculationMenuItem);
    this.correlationMethodMenu.add(this.spearmanCalculationMenuItem);
    this.correlationMethodMenu.add(this.kendallCalculationMenuItem);
    this.pearsonCalculationMenuItem.addItemListener(this);
    this.spearmanCalculationMenuItem.addItemListener(this);
    this.kendallCalculationMenuItem.addItemListener(this);

    //LAYOUT MENU
    LayoutChangeListener lcl = new LayoutChangeListener();
    this.layoutMenu.setMnemonic(KeyEvent.VK_L);
    this.layoutMenu.getAccessibleContext()
            .setAccessibleDescription(language.get("Change the layout of the graph"));
    this.layoutMenuButtonGroup.add(this.multipleCirclesLayoutMenuItem);
    this.layoutMenuButtonGroup.add(this.singleCircleLayoutMenuItem);
    this.layoutMenuButtonGroup.add(this.randomLayoutMenuItem);
    this.layoutMenuButtonGroup.add(this.kkLayoutMenuItem);
    //      this.layoutMenuButtonGroup.add( this.frLayoutMenuItem );
    //      this.layoutMenuButtonGroup.add( this.springLayoutMenuItem );
    this.layoutMenuButtonGroup.add(this.frSpringLayoutMenuItem);
    this.layoutMenuButtonGroup.add(this.heatMapLayoutMenuItem);

    Enumeration<AbstractButton> e = this.layoutMenuButtonGroup.getElements();
    this.layoutMenu.add(this.multipleCirclesLayoutMenuItem);
    this.layoutMenu.add(this.singleCircleLayoutMenuItem);
    this.layoutMenu.add(this.randomLayoutMenuItem);
    this.layoutMenu.add(this.kkLayoutMenuItem);
    //      this.layoutMenu.add( this.frLayoutMenuItem );
    //      this.layoutMenu.add( this.springLayoutMenuItem );
    this.layoutMenu.add(this.frSpringLayoutMenuItem);
    this.layoutMenu.add(this.heatMapLayoutMenuItem);
    //      this.layoutMenu.addSeparator( );
    //      this.layoutMenu.add( this.animatedLayoutMenuItem );
    this.multipleCirclesLayoutMenuItem.addActionListener(lcl);
    this.multipleCirclesLayoutMenuItem.setEnabled(false);
    this.singleCircleLayoutMenuItem.addActionListener(lcl);
    this.randomLayoutMenuItem.addActionListener(lcl);
    this.kkLayoutMenuItem.addActionListener(lcl);
    //      this.frLayoutMenuItem.addActionListener( lcl );
    this.frSpringLayoutMenuItem.addActionListener(lcl);
    this.heatMapLayoutMenuItem.addActionListener(lcl);
    //      this.animatedLayoutMenuItem.addActionListener( lcl );

    //VIEW MENU
    this.viewMenu.add(this.colorMenu);
    this.viewMenu.addSeparator();
    this.viewMenu.setMnemonic(KeyEvent.VK_V);
    this.viewMenu.getAccessibleContext()
            .setAccessibleDescription(language.get("Change the data view settings"));
    this.viewMenu.add(this.zoomOutViewMenuItem);
    this.viewMenu.add(this.zoomInViewMenuItem);
    this.viewMenu.add(this.fitToWindowViewMenuItem);
    this.viewMenu.addSeparator();
    this.viewMenu.add(this.selectAllViewMenuItem);
    this.viewMenu.add(this.clearSelectionViewMenuItem);
    this.viewMenu.add(this.invertSelectionViewMenuItem);
    this.viewMenu.add(this.selectCorrelatedViewMenuItem);
    this.viewMenu.addSeparator();
    this.viewMenu.add(this.hideSelectedViewMenuItem);
    this.viewMenu.add(this.hideUnselectedViewMenuItem);
    this.viewMenu.add(this.hideUncorrelatedViewMenuItem);
    this.viewMenu.add(this.hideOrphansViewMenuItem);
    this.viewMenu.add(this.showCorrelatedViewMenuItem);
    this.viewMenu.addSeparator();
    this.viewMenu.add(this.saveImageAction);
    this.resetSampleGroupsMenuItem.addActionListener(this);
    this.chooseSampleGroupsMenuItem.addActionListener(this);
    this.zoomOutViewMenuItem.addActionListener(this);
    this.zoomInViewMenuItem.addActionListener(this);
    this.fitToWindowViewMenuItem.addActionListener(this);
    this.selectAllViewMenuItem.addActionListener(this);
    this.clearSelectionViewMenuItem.addActionListener(this);
    this.invertSelectionViewMenuItem.addActionListener(this);
    this.selectCorrelatedViewMenuItem.addActionListener(this);
    this.hideSelectedViewMenuItem.addActionListener(this);
    this.hideUnselectedViewMenuItem.addActionListener(this);
    this.hideUncorrelatedViewMenuItem.addActionListener(this);
    this.hideOrphansViewMenuItem.addActionListener(this);
    this.showCorrelatedViewMenuItem.addActionListener(this);
    this.selectAllViewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK));
    this.clearSelectionViewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));

    // GROUPS MENU
    this.groupsMenu.setMnemonic(KeyEvent.VK_G);
    this.groupsMenu.add(this.resetSampleGroupsMenuItem);
    this.groupsMenu.add(this.chooseSampleGroupsMenuItem);

    this.zoomOutViewMenuItem
            .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, InputEvent.CTRL_DOWN_MASK));
    this.zoomInViewMenuItem
            .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.CTRL_DOWN_MASK));
    this.fitToWindowViewMenuItem
            .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_0, InputEvent.CTRL_DOWN_MASK));
    this.hideSelectedViewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));

    //COLOR MENU
    this.colorMenu.setMnemonic(KeyEvent.VK_R);
    this.colorMenu.getAccessibleContext()
            .setAccessibleDescription(language.get("Change the color of the graph"));
    this.colorMenuButtonGroup.add(this.normalColorMenuItem);
    this.colorMenuButtonGroup.add(this.highContrastColorMenuItem);
    this.colorMenu.add(this.normalColorMenuItem);
    this.colorMenu.add(this.highContrastColorMenuItem);
    this.normalColorMenuItem.addItemListener(this);
    this.highContrastColorMenuItem.addItemListener(this);

    this.menuBar.add(this.correlationMethodMenu);
    this.menuBar.add(this.layoutMenu);
    this.menuBar.add(this.viewMenu);
    this.menuBar.add(this.groupsMenu);

    // Add the panels to the main panel
    this.add(menuBar, BorderLayout.NORTH);
    //      this.add( this.correlationViewPanel, BorderLayout.CENTER );
    this.add(leftPanel, BorderLayout.WEST);
}

From source file:op.controlling.PnlControlling.java

private JPanel createContentPanel4Pain() {
    JPanel pnlContent = new JPanel(new VerticalLayout());

    JPanel pnlPainDossier = new JPanel(new BorderLayout());
    final JButton btnBVActivities = GUITools.createHyperlinkButton("opde.controlling.orga.paindossier", null,
            null);//from  w w  w. j a  va 2s. c  o  m
    int monthsBack;
    try {
        monthsBack = Integer.parseInt(OPDE.getProps().getProperty("opde.controlling::paindossiermonthsback"));
    } catch (NumberFormatException nfe) {
        monthsBack = 1;
    }
    final JTextField txtPainMonthsBack = GUITools.createIntegerTextField(1, 52, monthsBack);
    txtPainMonthsBack.setToolTipText(SYSTools.xx("misc.msg.monthsback"));
    btnBVActivities.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            OPDE.getMainframe().setBlocked(true);
            SwingWorker worker = new SwingWorker() {
                @Override
                protected Object doInBackground() throws Exception {
                    SYSPropsTools.storeProp("opde.controlling::paindossiermonthsback",
                            txtPainMonthsBack.getText(), OPDE.getLogin().getUser());
                    SYSFilesTools.print(ControllingTools.getPainDossierAsHTML(
                            new LocalDate().minusMonths(Integer.parseInt(txtPainMonthsBack.getText())),
                            new LocalDate(), progressClosure), false);
                    return null;
                }

                @Override
                protected void done() {
                    OPDE.getDisplayManager().setProgressBarMessage(null);
                    OPDE.getMainframe().setBlocked(false);
                }
            };
            worker.execute();
        }
    });
    pnlPainDossier.add(btnBVActivities, BorderLayout.WEST);
    pnlPainDossier.add(txtPainMonthsBack, BorderLayout.EAST);
    pnlContent.add(pnlPainDossier);

    return pnlContent;
}

From source file:com.att.aro.main.GraphPanel.java

/**
 * Initializes a new instance of the GraphPanel class.
 *//*from w w w. j  av  a2 s  . c  o m*/
public GraphPanel() {

    subplotMap.put(ChartPlotOptions.GPS,
            new GraphPanelPlotLabels(rb.getString("chart.gps"), createBarPlot(Color.gray), 1));
    subplotMap.put(ChartPlotOptions.RADIO,
            new GraphPanelPlotLabels(rb.getString("chart.radio"), createRadioPlot(), 2));
    subplotMap.put(ChartPlotOptions.BLUETOOTH,
            new GraphPanelPlotLabels(rb.getString("chart.bluetooth"), createBarPlot(Color.gray), 1));
    subplotMap.put(ChartPlotOptions.CAMERA,
            new GraphPanelPlotLabels(rb.getString("chart.camera"), createBarPlot(Color.gray), 1));
    subplotMap.put(ChartPlotOptions.SCREEN,
            new GraphPanelPlotLabels(rb.getString("chart.screen"), createBarPlot(new Color(34, 177, 76)), 1));
    subplotMap.put(ChartPlotOptions.BATTERY,
            new GraphPanelPlotLabels(rb.getString("chart.battery"), createBatteryPlot(), 2));
    subplotMap.put(ChartPlotOptions.WIFI,
            new GraphPanelPlotLabels(rb.getString("chart.wifi"), createBarPlot(Color.gray), 1));
    subplotMap.put(ChartPlotOptions.NETWORK_TYPE,
            new GraphPanelPlotLabels(rb.getString("chart.networkType"), createBarPlot(Color.gray), 1));
    subplotMap.put(ChartPlotOptions.THROUGHPUT,
            new GraphPanelPlotLabels(rb.getString("chart.throughput"), createThroughputPlot(), 2));
    subplotMap.put(ChartPlotOptions.BURSTS,
            new GraphPanelPlotLabels(rb.getString("chart.bursts"), createBurstPlot(), 1));
    subplotMap.put(ChartPlotOptions.USER_INPUT,
            new GraphPanelPlotLabels(rb.getString("chart.userInput"), createUserEventPlot(), 1));
    subplotMap.put(ChartPlotOptions.RRC,
            new GraphPanelPlotLabels(rb.getString("chart.rrc"), createRrcPlot(), 1));
    subplotMap.put(ChartPlotOptions.CPU,
            new GraphPanelPlotLabels(rb.getString("chart.cpu"), createCpuPlot(), 1));

    this.pp = new PacketPlots();
    subplotMap.put(ChartPlotOptions.UL_PACKETS,
            new GraphPanelPlotLabels(rb.getString("chart.ul"), pp.getUlPlot(), 1));
    subplotMap.put(ChartPlotOptions.DL_PACKETS,
            new GraphPanelPlotLabels(rb.getString("chart.dl"), pp.getDlPlot(), 1));

    this.axis = new NumberAxis();
    this.axis.setStandardTickUnits(UNITS);
    this.axis.setRange(new Range(0, DEFAULT_TIMELINE));
    this.axis.setLowerBound(0);

    this.axis.setAutoTickUnitSelection(true);
    this.axis.setTickMarkInsideLength(1);
    this.axis.setTickMarkOutsideLength(1);

    this.axis.setMinorTickMarksVisible(true);
    this.axis.setMinorTickMarkInsideLength(2f);
    this.axis.setMinorTickMarkOutsideLength(2f);
    this.axis.setTickMarkInsideLength(4f);
    this.axis.setTickMarkOutsideLength(4f);

    this.axisLabel = new JLabel(rb.getString("chart.timeline"));
    this.axisLabel.setHorizontalAlignment(SwingConstants.CENTER);

    this.setLayout(new BorderLayout());
    this.setPreferredSize(new Dimension(200, 310));
    this.add(getZoomSavePanel(), BorderLayout.EAST);
    this.add(getPane(), BorderLayout.CENTER);
    this.add(getLabelsPanel(), BorderLayout.WEST);

    setChartOptions(UserPreferences.getInstance().getChartPlotOptions());
}

From source file:org.executequery.base.DockedTabContainer.java

/**
 * Minimises the tab from the panel at the specified index.
 *
 * @param the index to be removed//from   w ww  . j a  v a  2  s .com
 */
protected void minimiseComponent(TabComponent tabComponent) {

    if (minimisedComponents == null) {
        minimisedComponents = new ArrayList<TabComponent>();
    }

    // add the component to the minimised cache
    minimisedComponents.add(tabComponent);

    if (buttonPanel == null) {
        buttonPanel = new ButtonPanel();

        // add the button panel in the required position
        switch (orientation) {
        case WEST:
            add(buttonPanel, BorderLayout.WEST);
            break;
        case CENTER:
            add(buttonPanel, BorderLayout.SOUTH);
            break;
        case EAST:
            add(buttonPanel, BorderLayout.EAST);
            break;
        }

    }
    buttonPanel.addButton(tabComponent);
    validate();
    repaint();
}

From source file:tvbrowser.ui.mainframe.MainFrame.java

/**
 * Switch the fullscreen mode of TV-Browser
 *///from   ww  w .ja v  a  2s .  co  m
public void switchFullscreenMode() {
    dispose();

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();

            if (isFullScreenMode()) {
                // switch back from fullscreen
                device.setFullScreenWindow(null);
                setUndecorated(false);
                setBounds(mXPos, mYPos, mWidth, mHeight);

                if (mMenuBar != null) {
                    mMenuBar.setFullscreenItemChecked(false);
                    mMenuBar.setVisible(true);
                }

                if (mToolBarPanel != null) {
                    mToolBarPanel.setVisible(Settings.propIsToolbarVisible.getBoolean());
                }

                if (mStatusBar != null) {
                    mStatusBar.setVisible(Settings.propIsStatusbarVisible.getBoolean());
                }

                if (mChannelChooser != null) {
                    mChannelChooser.setVisible(Settings.propShowChannels.getBoolean());
                }

                if (mFinderPanel != null) {
                    mFinderPanel.getComponent().setVisible(Settings.propShowDatelist.getBoolean());
                }

                setVisible(true);

                setShowPluginOverview(Settings.propShowPluginView.getBoolean(), false);
                setShowTimeButtons(Settings.propShowTimeButtons.getBoolean(), false);
                setShowDatelist(Settings.propShowDatelist.getBoolean(), false);
                setShowChannellist(Settings.propShowChannels.getBoolean(), false);
            } else {
                // switch into fullscreen
                mXPos = getX();
                mYPos = getY();
                mWidth = getWidth();
                mHeight = getHeight();

                setShowPluginOverview(false, false);
                setShowTimeButtons(false, false);
                setShowDatelist(false, false);
                setShowChannellist(false, false);

                if (mStatusBar != null) {
                    mMenuBar.setFullscreenItemChecked(true);
                    mStatusBar.setVisible(false);
                }

                if (mChannelChooser != null) {
                    mChannelChooser.setVisible(false);
                }

                if (mMenuBar != null) {
                    mMenuBar.setVisible(false);
                }

                if (mToolBarPanel != null) {
                    mToolBarPanel.setVisible(false);
                }

                if (mFinderPanel != null) {
                    mFinderPanel.getComponent().setVisible(false);
                }

                setUndecorated(true);
                final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();

                if (device.isFullScreenSupported() && OperatingSystem.isMacOs()) {
                    device.setFullScreenWindow(MainFrame.getInstance());
                } else {
                    setLocation(0, 0);
                    setSize(screen);
                }

                setVisible(true);
                mProgramTableScrollPane.requestFocusInWindow();

                new Thread("Fullscreen border detection") {
                    public void run() {
                        setPriority(Thread.MIN_PRIORITY);

                        while (isFullScreenMode()) {
                            final Point p = MouseInfo.getPointerInfo().getLocation();
                            SwingUtilities.convertPointFromScreen(p, MainFrame.this);

                            if (isActive()) {

                                // mouse pointer is at top
                                if (p.y <= 10) {
                                    if (mToolBarPanel != null && mToolBar.getToolbarLocation()
                                            .compareTo(BorderLayout.NORTH) == 0) {
                                        if (!mToolBarPanel.isVisible()) {
                                            mToolBarPanel
                                                    .setVisible(Settings.propIsToolbarVisible.getBoolean());
                                        }
                                    }

                                    if (p.y <= 0) {
                                        mMenuBar.setVisible(true);
                                    }
                                } else if (p.y > (mMenuBar != null && mMenuBar.isVisible()
                                        ? mMenuBar.getHeight()
                                        : 0)
                                        + (Settings.propIsToolbarVisible.getBoolean()
                                                ? mToolBarPanel.getHeight()
                                                : 0)) {
                                    if (mMenuBar.isVisible()) {
                                        mMenuBar.setVisible(!isFullScreenMode());
                                    }

                                    if (mToolBarPanel != null && mToolBarPanel.isVisible() && mToolBar
                                            .getToolbarLocation().compareTo(BorderLayout.NORTH) == 0) {
                                        mToolBarPanel.setVisible(!isFullScreenMode());
                                    }
                                }

                                // mouse pointer is at the bottom
                                if (p.y >= screen.height - 1) {
                                    if (mStatusBar != null && !mStatusBar.isVisible()) {
                                        mStatusBar.setVisible(Settings.propIsStatusbarVisible.getBoolean());
                                    }
                                } else if (mStatusBar != null && mStatusBar.isVisible()
                                        && p.y < screen.height - mStatusBar.getHeight()) {
                                    mStatusBar.setVisible(!isFullScreenMode());
                                }

                                // mouse pointer is on the left side
                                if (p.x <= 5) {
                                    if (p.x == 0 && mToolBarPanel != null && mToolBar.getToolbarLocation()
                                            .compareTo(BorderLayout.WEST) == 0) {
                                        if (!mToolBarPanel.isVisible()) {
                                            mToolBarPanel
                                                    .setVisible(Settings.propIsToolbarVisible.getBoolean());
                                        }
                                    }

                                    if (Settings.propPluginViewIsLeft.getBoolean()) {
                                        if (Settings.propShowPluginView.getBoolean()) {
                                            SwingUtilities.invokeLater(new Runnable() {
                                                public void run() {
                                                    setShowPluginOverview(true, false);
                                                }
                                            });
                                        }
                                    } else {
                                        checkIfToShowTimeDateChannelList();
                                    }
                                } else {
                                    int toolBarWidth = (mToolBarPanel != null && mToolBarPanel.isVisible()
                                            && mToolBar.getToolbarLocation().compareTo(BorderLayout.WEST) == 0)
                                                    ? mToolBarPanel.getWidth()
                                                    : 0;

                                    if (p.x > toolBarWidth && toolBarWidth != 0) {
                                        mToolBarPanel.setVisible(!isFullScreenMode());
                                    }

                                    if (Settings.propPluginViewIsLeft.getBoolean()) {
                                        if (Settings.propShowPluginView.getBoolean() && mPluginView != null
                                                && mPluginView.isVisible()
                                                && p.x > mPluginView.getWidth() + toolBarWidth + 25) {
                                            SwingUtilities.invokeLater(new Runnable() {
                                                public void run() {
                                                    setShowPluginOverview(!isFullScreenMode(), false);
                                                }
                                            });
                                        }
                                    } else if (Settings.propShowChannels.getBoolean()
                                            || Settings.propShowDatelist.getBoolean()
                                            || Settings.propShowTimeButtons.getBoolean()) {
                                        SwingUtilities.invokeLater(new Runnable() {
                                            public void run() {
                                                if (mChannelChooser != null && mChannelChooser.isVisible()
                                                        && p.x > mChannelChooser.getWidth()) {
                                                    setShowChannellist(!isFullScreenMode(), false);
                                                }

                                                if (mFinderPanel != null
                                                        && mFinderPanel.getComponent().isVisible()
                                                        && p.x > mFinderPanel.getComponent().getWidth()) {
                                                    setShowDatelist(!isFullScreenMode(), false);
                                                }

                                                if (mTimeChooserPanel != null && mTimeChooserPanel.isVisible()
                                                        && p.x > mTimeChooserPanel.getWidth()) {
                                                    setShowTimeButtons(!isFullScreenMode(), false);
                                                }
                                            }
                                        });
                                    }
                                }

                                // mouse pointer is on the right side
                                if (p.x >= screen.width - 1) {
                                    if (!Settings.propPluginViewIsLeft.getBoolean()) {
                                        if (Settings.propShowPluginView.getBoolean()) {
                                            SwingUtilities.invokeLater(new Runnable() {
                                                public void run() {
                                                    setShowPluginOverview(true, false);
                                                }
                                            });
                                        }
                                    } else {
                                        checkIfToShowTimeDateChannelList();
                                    }
                                } else {
                                    if (!Settings.propPluginViewIsLeft.getBoolean()) {
                                        if (Settings.propShowPluginView.getBoolean() && mPluginView != null
                                                && mPluginView.isVisible()
                                                && p.x < screen.width - mPluginView.getWidth()) {
                                            SwingUtilities.invokeLater(new Runnable() {
                                                public void run() {
                                                    setShowPluginOverview(!isFullScreenMode(), false);
                                                }
                                            });
                                        }
                                    } else if (Settings.propShowChannels.getBoolean()
                                            || Settings.propShowDatelist.getBoolean()
                                            || Settings.propShowTimeButtons.getBoolean()) {
                                        SwingUtilities.invokeLater(new Runnable() {
                                            public void run() {
                                                if (mChannelChooser != null && mChannelChooser.isVisible()
                                                        && p.x < screen.width - mChannelChooser.getWidth()) {
                                                    setShowChannellist(!isFullScreenMode(), false);
                                                }

                                                if (mFinderPanel != null
                                                        && mFinderPanel.getComponent().isVisible()
                                                        && p.x < screen.width
                                                                - mFinderPanel.getComponent().getWidth()) {
                                                    setShowDatelist(!isFullScreenMode(), false);
                                                }

                                                if (mTimeChooserPanel != null && mTimeChooserPanel.isVisible()
                                                        && p.x < screen.width - mTimeChooserPanel.getWidth()) {
                                                    setShowTimeButtons(!isFullScreenMode(), false);
                                                }
                                            }
                                        });
                                    }
                                }
                            }
                            try {
                                Thread.sleep(200);
                            } catch (Exception e) {
                            }
                        }
                    }
                }.start();
            }
        }
    });
}