Example usage for javax.swing BoxLayout Y_AXIS

List of usage examples for javax.swing BoxLayout Y_AXIS

Introduction

In this page you can find the example usage for javax.swing BoxLayout Y_AXIS.

Prototype

int Y_AXIS

To view the source code for javax.swing BoxLayout Y_AXIS.

Click Source Link

Document

Specifies that components should be laid out top to bottom.

Usage

From source file:sim.util.media.chart.ChartGenerator.java

/** Generates a new ChartGenerator with a blank chart.  Before anything else, buildChart() is called.  */
public ChartGenerator() {
    // create the chart
    buildChart();//from  w  w  w  . j  a v  a2 s. c  o  m
    chart.getPlot().setBackgroundPaint(Color.WHITE);
    chart.setAntiAlias(true);

    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
    split.setBorder(new EmptyBorder(0, 0, 0, 0));
    JScrollPane scroll = new JScrollPane();
    JPanel b = new JPanel();
    b.setLayout(new BorderLayout());
    b.add(seriesAttributes, BorderLayout.NORTH);
    b.add(new JPanel(), BorderLayout.CENTER);
    scroll.getViewport().setView(b);
    scroll.setBackground(getBackground());
    scroll.getViewport().setBackground(getBackground());
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());

    LabelledList list = new LabelledList("Chart Properties");
    DisclosurePanel pan1 = new DisclosurePanel("Chart Properties", list);
    globalAttributes.add(pan1);

    JLabel j = new JLabel("Right-Click or Control-Click");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);
    j = new JLabel("on Chart for More Options");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);

    titleField = new PropertyField() {
        public String newValue(String newValue) {
            setTitle(newValue);
            getChartPanel().repaint();
            return newValue;
        }
    };
    titleField.setValue(chart.getTitle().getText());

    list.add(new JLabel("Title"), titleField);

    buildGlobalAttributes(list);

    final JCheckBox legendCheck = new JCheckBox();
    ItemListener il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                LegendTitle title = new LegendTitle(chart.getPlot());
                title.setLegendItemGraphicPadding(new org.jfree.ui.RectangleInsets(0, 8, 0, 4));
                chart.addLegend(title);
            } else {
                chart.removeLegend();
            }
        }
    };
    legendCheck.addItemListener(il);
    list.add(new JLabel("Legend"), legendCheck);
    legendCheck.setSelected(true);

    /*
      final JCheckBox aliasCheck = new JCheckBox();
      aliasCheck.setSelected(chart.getAntiAlias());
      il = new ItemListener()
      {
      public void itemStateChanged(ItemEvent e)
      {
      chart.setAntiAlias( e.getStateChange() == ItemEvent.SELECTED );
      }
      };
      aliasCheck.addItemListener(il);
      list.add(new JLabel("Antialias"), aliasCheck);
    */

    JPanel pdfButtonPanel = new JPanel();
    pdfButtonPanel.setBorder(new javax.swing.border.TitledBorder("Chart Output"));
    DisclosurePanel pan2 = new DisclosurePanel("Chart Output", pdfButtonPanel);

    pdfButtonPanel.setLayout(new BorderLayout());
    Box pdfbox = new Box(BoxLayout.Y_AXIS);
    pdfButtonPanel.add(pdfbox, BorderLayout.WEST);

    JButton pdfButton = new JButton("Save as PDF");
    pdfbox.add(pdfButton);
    pdfButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FileDialog fd = new FileDialog(frame, "Choose PDF file...", FileDialog.SAVE);
            fd.setFile(chart.getTitle().getText() + ".pdf");
            fd.setVisible(true);
            String fileName = fd.getFile();
            if (fileName != null) {
                Dimension dim = chartPanel.getPreferredSize();
                PDFEncoder.generatePDF(chart, dim.width, dim.height,
                        new File(fd.getDirectory(), Utilities.ensureFileEndsWith(fd.getFile(), ".pdf")));
            }
        }
    });
    movieButton = new JButton("Create a Movie");
    pdfbox.add(movieButton);
    pdfbox.add(Box.createGlue());
    movieButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (movieMaker == null)
                startMovie();
            else
                stopMovie();
        }
    });

    globalAttributes.add(pan2);

    // we add into an outer box so we can later on add more global seriesAttributes
    // as the user instructs and still have glue be last
    Box outerAttributes = Box.createVerticalBox();
    outerAttributes.add(globalAttributes);
    outerAttributes.add(Box.createGlue());

    p.add(outerAttributes, BorderLayout.NORTH);
    p.add(scroll, BorderLayout.CENTER);
    p.setMinimumSize(new Dimension(0, 0));
    p.setPreferredSize(new Dimension(200, 0));
    split.setLeftComponent(p);

    // Add scale and proportion fields
    Box header = Box.createHorizontalBox();

    final double MAXIMUM_SCALE = 8;

    fixBox = new JCheckBox("Fill");
    fixBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setFixed(fixBox.isSelected());
        }
    });
    header.add(fixBox);
    fixBox.setSelected(true);

    // add the scale field
    scaleField = new NumberTextField("  Scale: ", 1.0, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0)
                newValue = currentValue;
            if (newValue > MAXIMUM_SCALE)
                newValue = currentValue;
            scale = newValue;
            resizeChart();
            return newValue;
        }
    };
    scaleField.setToolTipText("Zoom in and out");
    scaleField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    scaleField.setEnabled(false);
    scaleField.setText("");
    header.add(scaleField);

    // add the proportion field
    proportionField = new NumberTextField("  Proportion: ", 1.5, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0)
                newValue = currentValue;
            proportion = newValue;
            resizeChart();
            return newValue;
        }
    };
    proportionField.setToolTipText("Change the chart proportions (ratio of width to height)");
    proportionField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    header.add(proportionField);

    chartHolder.setMinimumSize(new Dimension(0, 0));
    chartHolder.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    chartHolder.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    chartHolder.getViewport().setBackground(Color.gray);
    JPanel p2 = new JPanel();
    p2.setLayout(new BorderLayout());
    p2.add(chartHolder, BorderLayout.CENTER);
    p2.add(header, BorderLayout.NORTH);
    split.setRightComponent(p2);
    setLayout(new BorderLayout());
    add(split, BorderLayout.CENTER);

    // set the default to be white, which looks good when printed
    chart.setBackgroundPaint(Color.WHITE);

    // JFreeChart has a hillariously broken way of handling font scaling.
    // It allows fonts to scale independently in X and Y.  We hack a workaround here.
    chartPanel.setMinimumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMaximumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMinimumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setMaximumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setPreferredSize(new java.awt.Dimension((int) (DEFAULT_CHART_HEIGHT * DEFAULT_CHART_PROPORTION),
            (int) (DEFAULT_CHART_HEIGHT)));
}

From source file:net.sf.profiler4j.console.ProjectDialog.java

private JPanel getExportPatternPanel() {
    if (exportPatternPanel == null) {
        exportPatternPanel = new JPanel();
        exportPatternPanel.setLayout(new BoxLayout(exportPatternPanel, BoxLayout.Y_AXIS));
        exportPatternPanel.setBounds(new java.awt.Rectangle(7, 490, 691, 50));
        exportPatternPanel.add(new JLabel("Specify a pattern for the image files to be named."));
        exportPatternPanel.add(getExportPatternText());
    }/*from  w w  w. j av a 2s. c o m*/
    return exportPatternPanel;
}

From source file:edu.gmu.cs.sim.util.media.chart.ChartGenerator.java

/** Generates a new ChartGenerator with a blank chart.  Before anything else, buildChart() is called.  */
public ChartGenerator() {
    // create the chart
    buildChart();/* w ww .  ja  v  a  2  s. c o  m*/
    chart.getPlot().setBackgroundPaint(Color.WHITE);
    chart.setAntiAlias(true);

    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
    split.setBorder(new EmptyBorder(0, 0, 0, 0));
    JScrollPane scroll = new JScrollPane();
    JPanel b = new JPanel();
    b.setLayout(new BorderLayout());
    b.add(seriesAttributes, BorderLayout.NORTH);
    b.add(new JPanel(), BorderLayout.CENTER);
    scroll.getViewport().setView(b);
    scroll.setBackground(getBackground());
    scroll.getViewport().setBackground(getBackground());
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());

    LabelledList list = new LabelledList("Chart Properties");
    DisclosurePanel pan1 = new DisclosurePanel("Chart Properties", list);
    globalAttributes.add(pan1);

    JLabel j = new JLabel("Right-Click or Control-Click");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);
    j = new JLabel("on Chart for More Options");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);

    titleField = new PropertyField() {
        public String newValue(String newValue) {
            setTitle(newValue);
            getChartPanel().repaint();
            return newValue;
        }
    };
    titleField.setValue(chart.getTitle().getText());

    list.add(new JLabel("Title"), titleField);

    buildGlobalAttributes(list);

    final JCheckBox legendCheck = new JCheckBox();
    ItemListener il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                LegendTitle title = new LegendTitle(chart.getPlot());
                title.setLegendItemGraphicPadding(new org.jfree.ui.RectangleInsets(0, 8, 0, 4));
                chart.addLegend(title);
            } else {
                chart.removeLegend();
            }
        }
    };
    legendCheck.addItemListener(il);
    list.add(new JLabel("Legend"), legendCheck);
    legendCheck.setSelected(true);

    /*
      final JCheckBox aliasCheck = new JCheckBox();
      aliasCheck.setSelected(chart.getAntiAlias());
      il = new ItemListener()
      {
      public void itemStateChanged(ItemEvent e)
      {
      chart.setAntiAlias( e.getStateChange() == ItemEvent.SELECTED );
      }
      };
      aliasCheck.addItemListener(il);
      list.add(new JLabel("Antialias"), aliasCheck);
    */

    JPanel pdfButtonPanel = new JPanel();
    pdfButtonPanel.setBorder(new javax.swing.border.TitledBorder("Chart Output"));
    DisclosurePanel pan2 = new DisclosurePanel("Chart Output", pdfButtonPanel);

    pdfButtonPanel.setLayout(new BorderLayout());
    Box pdfbox = new Box(BoxLayout.Y_AXIS);
    pdfButtonPanel.add(pdfbox, BorderLayout.WEST);

    JButton pdfButton = new JButton("Save as PDF");
    pdfbox.add(pdfButton);
    pdfButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FileDialog fd = new FileDialog(frame, "Choose PDF file...", FileDialog.SAVE);
            fd.setFile(chart.getTitle().getText() + ".pdf");
            fd.setVisible(true);
            String fileName = fd.getFile();
            if (fileName != null) {
                Dimension dim = chartPanel.getPreferredSize();
                PDFEncoder.generatePDF(chart, dim.width, dim.height,
                        new File(fd.getDirectory(), Utilities.ensureFileEndsWith(fd.getFile(), ".pdf")));
            }
        }
    });
    movieButton = new JButton("Create a Movie");
    pdfbox.add(movieButton);
    pdfbox.add(Box.createGlue());
    movieButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (movieMaker == null) {
                startMovie();
            } else {
                stopMovie();
            }
        }
    });

    globalAttributes.add(pan2);

    // we add into an outer box so we can later on add more global seriesAttributes
    // as the user instructs and still have glue be last
    Box outerAttributes = Box.createVerticalBox();
    outerAttributes.add(globalAttributes);
    outerAttributes.add(Box.createGlue());

    p.add(outerAttributes, BorderLayout.NORTH);
    p.add(scroll, BorderLayout.CENTER);
    p.setMinimumSize(new Dimension(0, 0));
    p.setPreferredSize(new Dimension(200, 0));
    split.setLeftComponent(p);

    // Add scale and proportion fields
    Box header = Box.createHorizontalBox();

    final double MAXIMUM_SCALE = 8;

    fixBox = new JCheckBox("Fill");
    fixBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setFixed(fixBox.isSelected());
        }
    });
    header.add(fixBox);
    fixBox.setSelected(true);

    // add the scale field
    scaleField = new NumberTextField("  Scale: ", 1.0, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0) {
                newValue = currentValue;
            }
            if (newValue > MAXIMUM_SCALE) {
                newValue = currentValue;
            }
            scale = newValue;
            resizeChart();
            return newValue;
        }
    };
    scaleField.setToolTipText("Zoom in and out");
    scaleField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    scaleField.setEnabled(false);
    scaleField.setText("");
    header.add(scaleField);

    // add the proportion field
    proportionField = new NumberTextField("  Proportion: ", 1.5, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0) {
                newValue = currentValue;
            }
            proportion = newValue;
            resizeChart();
            return newValue;
        }
    };
    proportionField.setToolTipText("Change the chart proportions (ratio of width to height)");
    proportionField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    header.add(proportionField);

    chartHolder.setMinimumSize(new Dimension(0, 0));
    chartHolder.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    chartHolder.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    chartHolder.getViewport().setBackground(Color.gray);
    JPanel p2 = new JPanel();
    p2.setLayout(new BorderLayout());
    p2.add(chartHolder, BorderLayout.CENTER);
    p2.add(header, BorderLayout.NORTH);
    split.setRightComponent(p2);
    setLayout(new BorderLayout());
    add(split, BorderLayout.CENTER);

    // set the default to be white, which looks good when printed
    chart.setBackgroundPaint(Color.WHITE);

    // JFreeChart has a hillariously broken way of handling font scaling.
    // It allows fonts to scale independently in X and Y.  We hack a workaround here.
    chartPanel.setMinimumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMaximumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMinimumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setMaximumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setPreferredSize(new java.awt.Dimension((int) (DEFAULT_CHART_HEIGHT * DEFAULT_CHART_PROPORTION),
            (int) (DEFAULT_CHART_HEIGHT)));
}

From source file:davmail.ui.SettingsFrame.java

protected JPanel getSmartCardPanel() {
    JPanel clientKeystorePanel = new JPanel(new GridLayout(2, 1));
    clientKeystorePanel.setLayout(new BoxLayout(clientKeystorePanel, BoxLayout.Y_AXIS));
    clientKeystorePanel/*  ww w .j a  v a2s.  co  m*/
            .setBorder(BorderFactory.createTitledBorder(BundleMessage.format("UI_CLIENT_CERTIFICATE")));

    clientKeystoreTypeCombo = new JComboBox(new String[] { "PKCS11", "JKS", "PKCS12" });
    clientKeystoreTypeCombo.setSelectedItem(Settings.getProperty("davmail.ssl.clientKeystoreType"));
    clientKeystoreFileField = new JTextField(Settings.getProperty("davmail.ssl.clientKeystoreFile"), 17);
    clientKeystorePassField = new JPasswordField(Settings.getProperty("davmail.ssl.clientKeystorePass"), 15);

    pkcs11LibraryField = new JTextField(Settings.getProperty("davmail.ssl.pkcs11Library"), 17);
    pkcs11ConfigField = new JTextArea(2, 17);
    pkcs11ConfigField.setText(Settings.getProperty("davmail.ssl.pkcs11Config"));
    pkcs11ConfigField.setBorder(pkcs11LibraryField.getBorder());
    pkcs11ConfigField.setFont(pkcs11LibraryField.getFont());

    JPanel clientKeystoreTypePanel = new JPanel(new GridLayout(1, 2));
    addSettingComponent(clientKeystoreTypePanel, BundleMessage.format("UI_CLIENT_KEY_STORE_TYPE"),
            clientKeystoreTypeCombo, BundleMessage.format("UI_CLIENT_KEY_STORE_TYPE_HELP"));
    clientKeystorePanel.add(clientKeystoreTypePanel);

    final JPanel cardPanel = new JPanel(new CardLayout());
    clientKeystorePanel.add(cardPanel);

    JPanel clientKeystoreFilePanel = new JPanel(new GridLayout(2, 2));
    addSettingComponent(clientKeystoreFilePanel, BundleMessage.format("UI_CLIENT_KEY_STORE"),
            clientKeystoreFileField, BundleMessage.format("UI_CLIENT_KEY_STORE_HELP"));
    addSettingComponent(clientKeystoreFilePanel, BundleMessage.format("UI_CLIENT_KEY_STORE_PASSWORD"),
            clientKeystorePassField, BundleMessage.format("UI_CLIENT_KEY_STORE_PASSWORD_HELP"));
    cardPanel.add(clientKeystoreFilePanel, "FILE");

    JPanel pkcs11Panel = new JPanel(new GridLayout(2, 2));
    addSettingComponent(pkcs11Panel, BundleMessage.format("UI_PKCS11_LIBRARY"), pkcs11LibraryField,
            BundleMessage.format("UI_PKCS11_LIBRARY_HELP"));
    addSettingComponent(pkcs11Panel, BundleMessage.format("UI_PKCS11_CONFIG"), pkcs11ConfigField,
            BundleMessage.format("UI_PKCS11_CONFIG_HELP"));
    cardPanel.add(pkcs11Panel, "PKCS11");

    ((CardLayout) cardPanel.getLayout()).show(cardPanel, (String) clientKeystoreTypeCombo.getSelectedItem());

    clientKeystoreTypeCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            CardLayout cardLayout = (CardLayout) (cardPanel.getLayout());
            if ("PKCS11".equals(event.getItem())) {
                cardLayout.show(cardPanel, "PKCS11");
            } else {
                cardLayout.show(cardPanel, "FILE");
            }
        }
    });
    updateMaximumSize(clientKeystorePanel);
    return clientKeystorePanel;
}

From source file:TransformExplorer.java

Box scalePanel() {
    Box panel = new Box(BoxLayout.Y_AXIS);

    // Uniform Scale
    JLabel uniform = new JLabel("Uniform Scale");
    panel.add(new LeftAlignComponent(uniform));

    FloatLabelJSlider coneScaleSlider = new FloatLabelJSlider("S:", 0.1f, 0.0f, 3.0f, coneScale);
    coneScaleSlider.setMajorTickSpacing(1.0f);
    coneScaleSlider.setPaintTicks(true);
    coneScaleSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            coneScale = e.getValue();/* w w  w.  j  a  v a 2 s .  co  m*/
            useUniformScale = true;
            if (useCompoundTransform) {
                updateUsingCompoundTransform();
            } else {
                setConeUScale();
            }
        }
    });
    panel.add(coneScaleSlider);

    JLabel nonUniform = new JLabel("Non-Uniform Scale");
    panel.add(new LeftAlignComponent(nonUniform));

    // Non-Uniform Scale
    FloatLabelJSlider coneNUScaleXSlider = new FloatLabelJSlider("X: ", 0.1f, 0.0f, 3.0f,
            (float) coneNUScale.x);
    coneNUScaleXSlider.setMajorTickSpacing(1.0f);
    coneNUScaleXSlider.setPaintTicks(true);
    coneNUScaleXSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            coneNUScale.x = (double) e.getValue();
            useUniformScale = false;
            if (useCompoundTransform) {
                updateUsingCompoundTransform();
            } else {
                setConeNUScale();
            }
        }
    });
    panel.add(coneNUScaleXSlider);

    FloatLabelJSlider coneNUScaleYSlider = new FloatLabelJSlider("Y: ", 0.1f, 0.0f, 3.0f,
            (float) coneNUScale.y);
    coneNUScaleYSlider.setMajorTickSpacing(1.0f);
    coneNUScaleYSlider.setPaintTicks(true);
    coneNUScaleYSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            coneNUScale.y = (double) e.getValue();
            useUniformScale = false;
            if (useCompoundTransform) {
                updateUsingCompoundTransform();
            } else {
                setConeNUScale();
            }
        }
    });
    panel.add(coneNUScaleYSlider);

    FloatLabelJSlider coneNUScaleZSlider = new FloatLabelJSlider("Z: ", 0.1f, 0.0f, 3.0f,
            (float) coneNUScale.z);
    coneNUScaleZSlider.setMajorTickSpacing(1.0f);
    coneNUScaleZSlider.setPaintTicks(true);
    coneNUScaleZSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            coneNUScale.z = (double) e.getValue();
            useUniformScale = false;
            if (useCompoundTransform) {
                updateUsingCompoundTransform();
            } else {
                setConeNUScale();
            }
        }
    });
    panel.add(coneNUScaleZSlider);

    return panel;
}

From source file:com.att.aro.ui.view.menu.tools.RegexWizard.java

private JPanel getMatcherPanel() {
    if (matcherPanel == null) {
        matcherPanel = new JPanel();
        matcherPanel.setLayout(new GridBagLayout());
        Color bgColor = matcherPanel.getBackground();
        matcherPanel.setBorder(new RoundedBorderPanel(bgColor));

        GridBagConstraints constraint = new GridBagConstraints();
        constraint.gridx = 0;//from w  w w.j a va 2  s .  com
        constraint.gridy = 0;
        constraint.insets = new Insets(0, 0, 0, 0);
        constraint.anchor = GridBagConstraints.FIRST_LINE_START;
        constraint.weightx = 0.5;

        ignore = new JRadioButton(ResourceBundleHelper.getMessageString("videoTab.ignore"));
        match = new JRadioButton(ResourceBundleHelper.getMessageString("videoTab.match"));

        ButtonGroup groupBtn = new ButtonGroup();
        groupBtn.add(ignore);
        groupBtn.add(match);

        keep = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.keep"));
        alpha = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.alpha"));
        characters = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.characters"));
        charField = new JTextField(20);

        numeric = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.numeric"));
        lengthMin = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.min.length"));
        lengthMax = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.max.length"));
        lengthMinField = new JTextField(10);
        lengthMaxField = new JTextField(10);

        matcherPanel.add(ignore, constraint);

        constraint.gridy = 1;
        constraint.anchor = GridBagConstraints.WEST;
        matcherPanel.add(match, constraint);

        constraint.anchor = GridBagConstraints.EAST;

        enterBtn = new JButton(ResourceBundleHelper.getMessageString("videoTab.enter"));
        enterBtn.setName(ResourceBundleHelper.getMessageString("videoTab.enter"));
        enterBtn.addActionListener(this);
        matcherPanel.add(enterBtn, constraint);

        constraint.anchor = GridBagConstraints.WEST;
        constraint.gridy = 2;
        matcherPanel.add(keep, constraint);

        constraint.gridy = 3;
        matcherPanel.add(alpha, constraint);

        constraint.gridy = 4;
        JPanel panelChar = new JPanel(new FlowLayout());
        panelChar.add(characters);
        panelChar.add(charField);
        matcherPanel.add(panelChar, constraint);

        constraint.gridy = 5;
        matcherPanel.add(numeric, constraint);

        constraint.gridy = 6;
        JPanel panelNumericLength = new JPanel();
        panelNumericLength.setLayout(new BoxLayout(panelNumericLength, BoxLayout.Y_AXIS));
        JPanel panelMinLength = new JPanel(new FlowLayout());
        panelMinLength.add(lengthMin);
        panelMinLength.add(lengthMinField);
        panelNumericLength.add(panelMinLength);
        JPanel panelMaxLength = new JPanel(new FlowLayout());
        panelMaxLength.add(lengthMax);
        panelMaxLength.add(lengthMaxField);
        panelNumericLength.add(panelMaxLength);
        matcherPanel.add(panelNumericLength, constraint);

        constraint.weighty = 1;

        matcherPanel.add(new JPanel(), constraint);
    }
    return matcherPanel;
}

From source file:jmemorize.gui.swing.frames.MainFrame.java

private void initComponents() {
    final JPanel mainPanel = new JPanel(new BorderLayout());

    m_deckChartPanel = new DeckChartPanel(this);
    m_deckChartPanel.setMinimumSize(new Dimension(100, 150));

    m_learnPanel = new LearnPanel();
    m_deckTablePanel = new DeckTablePanel(this);

    // north panel
    final JPanel northPanel = new JPanel();
    northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.Y_AXIS));
    northPanel.add(buildOperationsBar());
    northPanel.add(buildCategoryBar());//  w w  w.  j a  v a2 s  .  c  om

    m_categoryTree = new CategoryTree(jMemorizeIO);
    m_categoryTree.addSelectionObserver(new SelectionObserver() {

        @Override
        public void selectionChanged(final SelectionProvider source) {
            treeSelectionChanged(source);
        }

    });
    m_treeScrollPane = new JScrollPane(m_categoryTree);

    // bottom panel
    m_bottomPanel = new JPanel(new CardLayout());
    m_bottomPanel.add(m_deckTablePanel, DECK_CARD);
    m_bottomPanel.add(m_learnPanel, REPEAT_CARD);

    // vertical split pane
    m_verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    m_verticalSplitPane.setPreferredSize(new Dimension(16, 500));
    m_verticalSplitPane.setBorder(null);
    beautifyDividerBorder(m_verticalSplitPane);

    m_verticalSplitPane.setTopComponent(m_deckChartPanel);
    m_verticalSplitPane.setBottomComponent(m_bottomPanel);

    mainPanel.setPreferredSize(new Dimension(800, 500));
    mainPanel.add(m_verticalSplitPane, BorderLayout.CENTER);

    // horizontal split pane
    m_horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    m_horizontalSplitPane.setDividerLocation(m_categoryTreeWidth);
    m_horizontalSplitPane.setDividerSize(DIVIDER_SIZE);
    m_horizontalSplitPane.setBorder(null);

    m_horizontalSplitPane.setLeftComponent(m_treeScrollPane);
    m_horizontalSplitPane.setRightComponent(mainPanel);

    // frame content pane
    getContentPane().add(northPanel, BorderLayout.NORTH);
    getContentPane().add(m_horizontalSplitPane, BorderLayout.CENTER);
    getContentPane().add(m_statusBar, BorderLayout.SOUTH);
    setJMenuBar(new MainMenu(this, m_main.getRecentLessonFiles(), jMemorizeIO, this));

    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(final WindowEvent evt) {
            ExitAction.exit();
        }
    });

    setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/resource/icons/main.png"))); //$NON-NLS-1$
    pack();
}

From source file:edu.ucla.stat.SOCR.chart.SuperPieChart.java

public void initMapPanel() {
    listIndex = new int[dataTable.getColumnCount()];
    for (int j = 0; j < listIndex.length; j++)
        listIndex[j] = 1;/* w w w. j a  va2 s. c  om*/
    bPanel = new JPanel(new BorderLayout());
    mapPanel = new JPanel(new GridLayout(2, 5, 50, 50));
    bPanel.add(mapPanel, BorderLayout.CENTER);
    //   bPanel.add(new JPanel(),BorderLayout.NORTH);

    addButton1.addActionListener(this);
    addButton2.addActionListener(this);
    addButton3.addActionListener(this);
    removeButton1.addActionListener(this);
    removeButton2.addActionListener(this);
    removeButton3.addActionListener(this);

    lModelAdded = new DefaultListModel();
    lModelDep = new DefaultListModel();
    lModelIndep = new DefaultListModel();
    lModelPullout = new DefaultListModel();

    int cellWidth = 10;

    listAdded = new JList(lModelAdded);
    listAdded.setSelectedIndex(0);
    listDepRemoved = new JList(lModelDep);
    listIndepRemoved = new JList(lModelIndep);
    listPulloutRemoved = new JList(lModelPullout);

    paintTable(listIndex);
    listAdded.setFixedCellWidth(cellWidth);
    listDepRemoved.setFixedCellWidth(cellWidth);
    listIndepRemoved.setFixedCellWidth(cellWidth);
    listPulloutRemoved.setFixedCellWidth(cellWidth);

    tools1 = new JToolBar(JToolBar.VERTICAL);
    tools2 = new JToolBar(JToolBar.VERTICAL);
    tools3 = new JToolBar(JToolBar.VERTICAL);

    if (mapDep) {
        tools1.add(depLabel);
        tools1.add(addButton1);
        tools1.add(removeButton1);
    }
    if (mapIndep) {
        tools2.add(indLabel);
        tools2.add(addButton2);
        tools2.add(removeButton2);
    }
    if (mapPullout) {
        tools3.add(pulloutLabel);
        tools3.add(addButton3);
        tools3.add(removeButton3);
    }
    tools1.setFloatable(false);
    tools2.setFloatable(false);
    tools3.setFloatable(false);

    /*  topPanel.add(listAdded);
    topPanel.add(addButton);
    topPanel.add(listDepRemoved);
    bottomPanel.add(listIndepRemoved);
    bottomPanel.add(addButton2);
    bottomPanel.add(list4); */

    JRadioButton legendPanelOnSwitch;
    JRadioButton legendPanelOffSwitch;
    //
    JPanel choicesPanel = new JPanel();
    choicesPanel.setLayout(new BoxLayout(choicesPanel, BoxLayout.Y_AXIS));
    legendPanelOnSwitch = new JRadioButton("On");
    legendPanelOnSwitch.addActionListener(this);
    legendPanelOnSwitch.setActionCommand(LEGENDON);
    legendPanelOnSwitch.setSelected(false);
    legendPanelOn = false;

    legendPanelOffSwitch = new JRadioButton("Off");
    legendPanelOffSwitch.addActionListener(this);
    legendPanelOffSwitch.setActionCommand(LEGENDOFF);
    legendPanelOffSwitch.setSelected(true);

    ButtonGroup group = new ButtonGroup();
    group.add(legendPanelOnSwitch);
    group.add(legendPanelOffSwitch);
    choicesPanel.add(new JLabel("Turn the legend panel:"));
    choicesPanel.add(legendPanelOnSwitch);
    choicesPanel.add(legendPanelOffSwitch);
    choicesPanel.setPreferredSize(new Dimension(200, 100));

    JRadioButton rotateOnSwitch;
    JRadioButton rotateOffSwitch;
    //
    JPanel rotateChoicesPanel = new JPanel();
    rotateChoicesPanel.setLayout(new BoxLayout(rotateChoicesPanel, BoxLayout.Y_AXIS));
    rotateOnSwitch = new JRadioButton("On");
    rotateOnSwitch.addActionListener(this);
    rotateOnSwitch.setActionCommand(ROTATEON);
    rotateOnSwitch.setSelected(false);
    rotateOn = false;

    rotateOffSwitch = new JRadioButton("Off");
    rotateOffSwitch.addActionListener(this);
    rotateOffSwitch.setActionCommand(ROTATEOFF);
    rotateOffSwitch.setSelected(true);

    ButtonGroup group2 = new ButtonGroup();
    group2.add(rotateOnSwitch);
    group2.add(rotateOffSwitch);
    choicesPanel.add(new JLabel("Turn the rotator:"));
    choicesPanel.add(rotateOnSwitch);
    choicesPanel.add(rotateOffSwitch);
    choicesPanel.setPreferredSize(new Dimension(200, 100));

    JPanel emptyPanel = new JPanel();
    JPanel emptyPanel2 = new JPanel();
    JPanel emptyPanel3 = new JPanel();

    //2X5
    //first line
    mapPanel.add(new JScrollPane(listAdded));
    mapPanel.add(tools1);
    mapPanel.add(new JScrollPane(listDepRemoved));

    mapPanel.add(tools3);
    if (mapPullout)
        mapPanel.add(new JScrollPane(listPulloutRemoved));
    else
        mapPanel.add(emptyPanel);
    //second line--               
    mapPanel.add(choicesPanel);
    mapPanel.add(tools2);
    mapPanel.add(new JScrollPane(listIndepRemoved));

    mapPanel.add(emptyPanel2);
    mapPanel.add(emptyPanel3);
}

From source file:jboost.visualization.HistogramFrame.java

private JPanel getJPanel3() {
    if (jPanel3 == null) {
        jPanel3 = new JPanel();
        BoxLayout jPanel3Layout = new BoxLayout(jPanel3, BoxLayout.Y_AXIS);
        jPanel3.setLayout(jPanel3Layout);
        {/*from www  .  j ava2  s .c o m*/
            jPanel3.add(getJScrollPane1());
            jPanel3.setPreferredSize(new java.awt.Dimension(80, 400));
        }
    }
    return jPanel3;
}

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//from   w w  w. jav  a  2s . com
 * 
 * @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);
}