Example usage for javax.swing BoxLayout X_AXIS

List of usage examples for javax.swing BoxLayout X_AXIS

Introduction

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

Prototype

int X_AXIS

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

Click Source Link

Document

Specifies that components should be laid out left to right.

Usage

From source file:misc.AccessibleScrollDemo.java

public AccessibleScrollDemo() {
    // Get the image to use.
    ImageIcon bee = createImageIcon("images/flyingBee.jpg", "Photograph of a flying bee.");

    // Create the row and column headers.
    columnView = new Rule(Rule.HORIZONTAL, true);
    if (bee != null) {
        columnView.setPreferredWidth(bee.getIconWidth());
    } else {//from   w  w w  .j  a v a  2  s  . c om
        columnView.setPreferredWidth(320);
    }
    columnView.getAccessibleContext().setAccessibleName("Column Header");
    columnView.getAccessibleContext()
            .setAccessibleDescription("Displays horizontal ruler for " + "measuring scroll pane client.");
    rowView = new Rule(Rule.VERTICAL, true);
    if (bee != null) {
        rowView.setPreferredHeight(bee.getIconHeight());
    } else {
        rowView.setPreferredHeight(480);
    }
    rowView.getAccessibleContext().setAccessibleName("Row Header");
    rowView.getAccessibleContext()
            .setAccessibleDescription("Displays vertical ruler for " + "measuring scroll pane client.");

    // Create the corners.
    JPanel buttonCorner = new JPanel();
    isMetric = new JToggleButton("cm", true);
    isMetric.setFont(new Font("SansSerif", Font.PLAIN, 11));
    isMetric.setMargin(new Insets(2, 2, 2, 2));
    isMetric.addItemListener(this);
    isMetric.setToolTipText("Toggles rulers' unit of measure " + "between inches and centimeters.");
    buttonCorner.add(isMetric); //Use the default FlowLayout
    buttonCorner.getAccessibleContext().setAccessibleName("Upper Left Corner");

    String desc = "Fills the corner of a scroll pane " + "with color for aesthetic reasons.";
    Corner lowerLeft = new Corner();
    lowerLeft.getAccessibleContext().setAccessibleName("Lower Left Corner");
    lowerLeft.getAccessibleContext().setAccessibleDescription(desc);

    Corner upperRight = new Corner();
    upperRight.getAccessibleContext().setAccessibleName("Upper Right Corner");
    upperRight.getAccessibleContext().setAccessibleDescription(desc);

    // Set up the scroll pane.
    picture = new ScrollablePicture(bee, columnView.getIncrement());
    picture.setToolTipText(bee.getDescription());
    picture.getAccessibleContext().setAccessibleName("Scroll pane client");

    JScrollPane pictureScrollPane = new JScrollPane(picture);
    pictureScrollPane.setPreferredSize(new Dimension(300, 250));
    pictureScrollPane.setViewportBorder(BorderFactory.createLineBorder(Color.black));

    pictureScrollPane.setColumnHeaderView(columnView);
    pictureScrollPane.setRowHeaderView(rowView);

    // In theory, to support internationalization you would change
    // UPPER_LEFT_CORNER to UPPER_LEADING_CORNER,
    // LOWER_LEFT_CORNER to LOWER_LEADING_CORNER, and
    // UPPER_RIGHT_CORNER to UPPER_TRAILING_CORNER.  In practice,
    // bug #4467063 makes that impossible (at least in 1.4.0).
    pictureScrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, buttonCorner);
    pictureScrollPane.setCorner(JScrollPane.LOWER_LEFT_CORNER, lowerLeft);
    pictureScrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, upperRight);

    // Put it in this panel.
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    add(pictureScrollPane);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:components.SharedModelDemo.java

public SharedModelDemo() {
    super(new BorderLayout());

    Vector data = new Vector(7);
    String[] columnNames = { "French", "Spanish", "Italian" };
    String[] oneData = { "un", "uno", "uno" };
    String[] twoData = { "deux", "dos", "due" };
    String[] threeData = { "trois", "tres", "tre" };
    String[] fourData = { "quatre", "cuatro", "quattro" };
    String[] fiveData = { "cinq", "cinco", "cinque" };
    String[] sixData = { "six", "seis", "sei" };
    String[] sevenData = { "sept", "siete", "sette" };

    //Build the model.
    SharedDataModel dataModel = new SharedDataModel(columnNames);
    dataModel.addElement(oneData);//w  w w  .j a  v  a 2  s .  c  o  m
    dataModel.addElement(twoData);
    dataModel.addElement(threeData);
    dataModel.addElement(fourData);
    dataModel.addElement(fiveData);
    dataModel.addElement(sixData);
    dataModel.addElement(sevenData);

    list = new JList(dataModel);
    list.setCellRenderer(new DefaultListCellRenderer() {
        public Component getListCellRendererComponent(JList l, Object value, int i, boolean s, boolean f) {
            String[] array = (String[]) value;
            return super.getListCellRendererComponent(l, array[0], i, s, f);
        }
    });

    listSelectionModel = list.getSelectionModel();
    listSelectionModel.addListSelectionListener(new SharedListSelectionHandler());
    JScrollPane listPane = new JScrollPane(list);

    table = new JTable(dataModel);
    table.setSelectionModel(listSelectionModel);
    JScrollPane tablePane = new JScrollPane(table);

    //Build control area (use default FlowLayout).
    JPanel controlPane = new JPanel();
    String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" };

    final JComboBox comboBox = new JComboBox(modes);
    comboBox.setSelectedIndex(2);
    comboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String newMode = (String) comboBox.getSelectedItem();
            if (newMode.equals("SINGLE_SELECTION")) {
                listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) {
                listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
            } else {
                listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            }
            output.append("----------" + "Mode: " + newMode + "----------" + newline);
        }
    });
    controlPane.add(new JLabel("Selection mode:"));
    controlPane.add(comboBox);

    //Build output area.
    output = new JTextArea(10, 40);
    output.setEditable(false);
    JScrollPane outputPane = new JScrollPane(output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

    //Do the layout.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    add(splitPane, BorderLayout.CENTER);

    JPanel topHalf = new JPanel();
    topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.X_AXIS));
    JPanel listContainer = new JPanel(new GridLayout(1, 1));
    listContainer.setBorder(BorderFactory.createTitledBorder("List"));
    listContainer.add(listPane);
    JPanel tableContainer = new JPanel(new GridLayout(1, 1));
    tableContainer.setBorder(BorderFactory.createTitledBorder("Table"));
    tableContainer.add(tablePane);
    tablePane.setPreferredSize(new Dimension(300, 100));
    topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
    topHalf.add(listContainer);
    topHalf.add(tableContainer);

    topHalf.setMinimumSize(new Dimension(400, 50));
    topHalf.setPreferredSize(new Dimension(400, 110));
    splitPane.add(topHalf);

    JPanel bottomHalf = new JPanel(new BorderLayout());
    bottomHalf.add(controlPane, BorderLayout.NORTH);
    bottomHalf.add(outputPane, BorderLayout.CENTER);
    //XXX: next line needed if bottomHalf is a scroll pane:
    //bottomHalf.setMinimumSize(new Dimension(400, 50));
    bottomHalf.setPreferredSize(new Dimension(450, 135));
    splitPane.add(bottomHalf);
}

From source file:NormSample.java

public void init() {

    // preparing values for the normalization forms ComboBox

    formValues.put("NFC", Normalizer.Form.NFC);
    formValues.put("NFD", Normalizer.Form.NFD);
    formValues.put("NFKC", Normalizer.Form.NFKC);
    formValues.put("NFKD", Normalizer.Form.NFKD);

    formComboBox = new JComboBox();

    for (Iterator it = formValues.keySet().iterator(); it.hasNext();) {
        formComboBox.addItem((String) it.next());
    }/*w ww.j  a va  2s.  co  m*/

    // preparing samples for normalization

    // text with the acute accent symbol
    templateValues.put("acute accent", "touch" + "\u00e9");

    // text with ligature
    templateValues.put("ligature", "a" + "\ufb03" + "ance");

    // text with the cedilla
    templateValues.put("cedilla", "fa" + "\u00e7" + "ade");

    // text with half-width katakana
    templateValues.put("half-width katakana", "\uff81\uff6e\uff7a\uff9a\uff70\uff84");

    normalizationTemplate = new JComboBox();

    for (Iterator it = templateValues.keySet().iterator(); it.hasNext();) {
        normalizationTemplate.addItem((String) it.next());
    }

    // defining a component to output normalization results

    paintingComponent = new JComponent() {
        static final long serialVersionUID = -3725620407788489160L;

        public Dimension getSize() {
            return new Dimension(550, 200);
        }

        public Dimension getPreferredSize() {
            return new Dimension(550, 200);
        }

        public Dimension getMinimumSize() {
            return new Dimension(550, 200);
        }

        public void paint(Graphics g) {
            Graphics2D g2 = (Graphics2D) g;

            g2.setFont(new Font("Serif", Font.PLAIN, 20));
            g2.setColor(Color.BLACK);
            g2.drawString("Original string:", 100, 80);
            g2.drawString("Normalized string:", 100, 120);
            g2.setFont(new Font("Serif", Font.BOLD, 24));

            // output of the original sample selected from the ComboBox

            String original_string = templateValues.get(normalizationTemplate.getSelectedItem());
            g2.drawString(original_string, 320, 80);

            // normalization and output of the normalized string

            String normalized_string;
            java.text.Normalizer.Form currentForm = formValues.get(formComboBox.getSelectedItem());
            normalized_string = Normalizer.normalize(original_string, currentForm);
            g2.drawString(normalized_string, 320, 120);
        }
    };
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    add(paintingComponent);
    JPanel controls = new JPanel();

    controls.setLayout(new BoxLayout(controls, BoxLayout.X_AXIS));
    controls.add(new Label("Normalization Form: "));
    controls.add(formComboBox);
    controls.add(new Label("Normalization Template:"));
    controls.add(normalizationTemplate);
    add(controls);
    formComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            paintingComponent.repaint();
        }
    });

    normalizationTemplate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            paintingComponent.repaint();
        }
    });
}

From source file:it.iit.genomics.cru.igb.bundles.mi.view.MIResultPanel.java

public MIResultPanel(IgbService service, String summary, List<MIResult> results, String label, MIQuery query) {
    setLayout(new BorderLayout());

    this.label = label;

    igbLogger = IGBLogger.getInstance(label);

    colorer = TaxonColorer.getColorer(query.getTaxid());

    Box menuBox = new Box(BoxLayout.X_AXIS);

    Box buttonBox = new Box(BoxLayout.Y_AXIS);
    Box buttonBox1 = new Box(BoxLayout.X_AXIS);

    Box buttonBox3 = new Box(BoxLayout.X_AXIS);
    buttonBox.add(buttonBox1);/*from   www  . ja  v  a 2 s . c o m*/

    buttonBox.add(buttonBox3);

    JTextPane querySummary = new JTextPane();
    querySummary.setContentType("text/html");
    querySummary.setEditable(false);
    querySummary.setText(summary);

    menuBox.add(querySummary);

    menuBox.add(buttonBox);

    final JFrame logFrame = new JFrame("MI Bundle Log");
    logFrame.setVisible(false);
    Dimension preferredSize = new Dimension(800, 500);

    logFrame.setPreferredSize(preferredSize);
    logFrame.setMinimumSize(preferredSize);

    logFrame.add(new LogPanel(igbLogger));

    JButton log = new JButton();

    if (igbLogger.hasError()) {
        log.setBackground(Color.red);
    }

    log.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/console.png"));

    log.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            logFrame.setVisible(true);
        }

    });

    buttonBox1.add(log);

    JButton networkButton = new JButton("");
    networkButton.setIcon(new ImageIcon(getClass().getResource("/network.jpg")));
    networkButton.addActionListener(new DisplayNetworkActionListener());

    buttonBox1.add(networkButton);

    buttonBox1.add(new JSeparator(JSeparator.VERTICAL));

    buttonBox1.add(new JLabel("Save: "));
    JButton exportButton = new JButton("text");
    exportButton.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/save.png"));
    exportButton.addActionListener(new ExportActionListener());

    if (false == MICommons.testVersion) {
        buttonBox1.add(exportButton);
    }

    JButton exportXgmmlButton = new JButton("xgmml");
    exportXgmmlButton.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/save.png"));
    exportXgmmlButton.addActionListener(new ExportXgmmlActionListener());
    if (false == MICommons.testVersion) {
        buttonBox1.add(exportXgmmlButton);
    }

    buttonBox1.add(new JSeparator(JSeparator.VERTICAL));

    buttonBox1.add(new JLabel("View structure: "));

    structures = new StructuresPanel(service, label);

    buttonBox1.add(structures.getJmolButton());
    buttonBox1.add(structures.getLinkButton());

    // Filters
    ButtonGroup scoreGroup = new ButtonGroup();
    JRadioButton scoreButton0 = new JRadioButton("<html>" + HTML_SCORE_0 + "</html>");
    JRadioButton scoreButton1 = new JRadioButton("<html>" + HTML_SCORE_1 + "</html>");
    JRadioButton scoreButton2 = new JRadioButton("<html>" + HTML_SCORE_2 + "</html>");
    JRadioButton scoreButton3 = new JRadioButton("<html>" + HTML_SCORE_3 + "</html>");
    scoreButton0.setSelected(true);

    ScoreListener scoreListener = new ScoreListener();
    scoreButton0.addActionListener(scoreListener);
    scoreButton1.addActionListener(scoreListener);
    scoreButton2.addActionListener(scoreListener);
    scoreButton3.addActionListener(scoreListener);

    scoreGroup.add(scoreButton0);
    scoreGroup.add(scoreButton1);
    scoreGroup.add(scoreButton2);
    scoreGroup.add(scoreButton3);

    buttonBox1.add(new JSeparator(JSeparator.VERTICAL));
    buttonBox1.add(new JLabel("Score: "));
    buttonBox1.add(scoreButton0);
    buttonBox1.add(scoreButton1);
    buttonBox1.add(scoreButton2);
    buttonBox1.add(scoreButton3);

    buttonBox3.add(new JLabel("Interaction type: "));

    JCheckBox EvidencePhysicalButton = new JCheckBox(HTML_CHECKBOX_PHYSICAL);
    JCheckBox EvidenceAssociationButton = new JCheckBox(HTML_CHECKBOX_ASSOCIATION);
    JCheckBox EvidenceEnzymaticButton = new JCheckBox(HTML_CHECKBOX_ENZYMATIC);
    JCheckBox EvidenceOtherButton = new JCheckBox(HTML_CHECKBOX_OTHER);
    JCheckBox EvidenceUnspecifiedButton = new JCheckBox(HTML_CHECKBOX_UNSPECIFIED);
    JCheckBox EvidenceStructureButton = new JCheckBox(HTML_CHECKBOX_STRUCTURE);

    EvidencePhysicalButton.setSelected(true);
    EvidenceAssociationButton.setSelected(true);
    EvidenceEnzymaticButton.setSelected(true);
    EvidenceOtherButton.setSelected(true);
    EvidenceUnspecifiedButton.setSelected(true);
    EvidenceStructureButton.setSelected(true);

    buttonBox3.add(EvidencePhysicalButton);
    buttonBox3.add(EvidenceAssociationButton);
    buttonBox3.add(EvidenceEnzymaticButton);
    buttonBox3.add(EvidenceOtherButton);
    buttonBox3.add(EvidenceUnspecifiedButton);
    buttonBox3.add(EvidenceStructureButton);

    EvidenceTypeListener evidenceListener = new EvidenceTypeListener();
    EvidencePhysicalButton.addActionListener(evidenceListener);
    EvidenceAssociationButton.addActionListener(evidenceListener);
    EvidenceEnzymaticButton.addActionListener(evidenceListener);
    EvidenceOtherButton.addActionListener(evidenceListener);
    EvidenceUnspecifiedButton.addActionListener(evidenceListener);
    EvidenceStructureButton.addActionListener(evidenceListener);

    Box tableBox = new Box(BoxLayout.Y_AXIS);

    MITableModel model = new MITableModel(results);

    miTable = new MITable(model, service, query);

    miTable.setFillsViewportHeight(true);

    miTable.setStructuresPanel(structures);

    tableBox.add(miTable.getTableHeader());
    tableBox.add(miTable);

    JScrollPane tableScroll = new JScrollPane(tableBox);

    tableScroll.setMinimumSize(new Dimension(800, 50));
    tableScroll.setPreferredSize(new Dimension(800, 50));
    tableScroll.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));

    structures.setMinimumSize(new Dimension(200, 500));
    structures.setPreferredSize(new Dimension(200, 500));
    structures.setMaximumSize(new Dimension(200, Short.MAX_VALUE));

    resultBox = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tableScroll, structures);
    resultBox.setOneTouchExpandable(true);

    add(menuBox, BorderLayout.NORTH);
    add(resultBox, BorderLayout.CENTER);

}

From source file:davmail.ui.SettingsFrame.java

protected void addPortSettingComponent(JPanel panel, String label, JComponent component,
        JComponent checkboxComponent, JComponent checkboxSSLComponent, String toolTipText) {
    JLabel fieldLabel = new JLabel(label);
    fieldLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    fieldLabel.setVerticalAlignment(SwingConstants.CENTER);
    panel.add(fieldLabel);/*from  w ww.  j a  v  a 2 s  .  co m*/
    component.setMaximumSize(component.getPreferredSize());
    JPanel innerPanel = new JPanel();
    innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS));
    innerPanel.add(checkboxComponent);
    innerPanel.add(component);
    innerPanel.add(checkboxSSLComponent);
    panel.add(innerPanel);
    if (toolTipText != null) {
        fieldLabel.setToolTipText(toolTipText);
        component.setToolTipText(toolTipText);
    }
}

From source file:strobe.spectroscopy.StrobeSpectroscopy.java

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

    fileChooser = new javax.swing.JFileChooser();
    graphPanel = new javax.swing.JPanel();
    controlPanel = new javax.swing.JPanel();
    btnStart = new javax.swing.JButton();
    btnPause = new javax.swing.JButton();
    btnStop = new javax.swing.JButton();
    spr1 = new javax.swing.JSeparator();
    tbtnBackward = new javax.swing.JToggleButton();
    tbtnForward = new javax.swing.JToggleButton();
    spr2 = new javax.swing.JSeparator();
    jPanel1 = new javax.swing.JPanel();
    cBoxSpeed = new javax.swing.JComboBox<>();
    spr4 = new javax.swing.JSeparator();
    cBoxResolution = new javax.swing.JComboBox<>();
    spr3 = new javax.swing.JSeparator();
    cBoxFromWavelength = new javax.swing.JComboBox<>();
    cBoxToWavelength = new javax.swing.JComboBox<>();
    spr5 = new javax.swing.JSeparator();
    btnSetZero = new javax.swing.JButton();
    btnSetMark = new javax.swing.JButton();
    strobeMenuBar = new javax.swing.JMenuBar();
    menuFile = new javax.swing.JMenu();
    menuFileOpen = new javax.swing.JMenuItem();
    menuFileSave = new javax.swing.JMenuItem();
    menuFileExit = new javax.swing.JMenuItem();
    settingMenu = new javax.swing.JMenu();
    menuAbout = new javax.swing.JMenu();
    menuAboutAbout = new javax.swing.JMenuItem();

    fileChooser.setAcceptAllFileFilterUsed(false);

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setTitle("Strobe-spectroscopy");
    setIconImage(new javax.swing.ImageIcon(getClass().getResource("/icons/iconFrame.png")).getImage());
    setLocationByPlatform(true);
    setMinimumSize(new java.awt.Dimension(800, 550));
    setName("strobeFrame"); // NOI18N
    setPreferredSize(new java.awt.Dimension(800, 550));

    controlPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204)));
    controlPanel.setLayout(new javax.swing.BoxLayout(controlPanel, javax.swing.BoxLayout.X_AXIS));

    btnStart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/iconStart.png"))); // NOI18N
    btnStart.setToolTipText("Start measurement");
    btnStart.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnStartActionPerformed(evt);
        }
    });
    controlPanel.add(btnStart);

    btnPause.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/iconPause.png"))); // NOI18N
    btnPause.setToolTipText("Pause measurement");
    btnPause.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnPauseActionPerformed(evt);
        }
    });
    controlPanel.add(btnPause);

    btnStop.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/iconStop.png"))); // NOI18N
    btnStop.setToolTipText("Stop measurement");
    btnStop.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnStopActionPerformed(evt);
        }
    });
    controlPanel.add(btnStop);

    spr1.setForeground(new java.awt.Color(255, 255, 255));
    spr1.setOrientation(javax.swing.SwingConstants.VERTICAL);
    spr1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    spr1.setMaximumSize(new java.awt.Dimension(5, 0));
    spr1.setPreferredSize(new java.awt.Dimension(5, 0));
    spr1.setRequestFocusEnabled(false);
    controlPanel.add(spr1);
    spr1.getAccessibleContext().setAccessibleDescription("");

    tbtnBackward.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/iconBackward.png"))); // NOI18N
    tbtnBackward.setToolTipText("Backwar spinning of the driver, while pressed.");
    tbtnBackward.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            tbtnBackwardActionPerformed(evt);
        }
    });
    controlPanel.add(tbtnBackward);

    tbtnForward.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/iconForward.png"))); // NOI18N
    tbtnForward.setToolTipText("Forward spinning of the drive, while pressed.");
    tbtnForward.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            tbtnForwardActionPerformed(evt);
        }
    });
    controlPanel.add(tbtnForward);

    spr2.setForeground(new java.awt.Color(255, 255, 255));
    spr2.setOrientation(javax.swing.SwingConstants.VERTICAL);
    spr2.setAlignmentX(1.0F);
    spr2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    spr2.setMaximumSize(new java.awt.Dimension(5, 0));
    spr2.setPreferredSize(new java.awt.Dimension(5, 0));
    spr2.setRequestFocusEnabled(false);
    controlPanel.add(spr2);

    jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.LINE_AXIS));

    cBoxSpeed.setToolTipText("");
    cBoxSpeed.setMinimumSize(new java.awt.Dimension(50, 20));
    cBoxSpeed.setPreferredSize(new java.awt.Dimension(50, 20));
    jPanel1.add(cBoxSpeed);

    spr4.setForeground(new java.awt.Color(255, 255, 255));
    spr4.setOrientation(javax.swing.SwingConstants.VERTICAL);
    spr4.setAlignmentX(1.0F);
    spr4.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    spr4.setMaximumSize(new java.awt.Dimension(5, 0));
    spr4.setPreferredSize(new java.awt.Dimension(5, 0));
    spr4.setRequestFocusEnabled(false);
    jPanel1.add(spr4);

    cBoxResolution.setAutoscrolls(true);
    cBoxResolution.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    cBoxResolution.setMinimumSize(new java.awt.Dimension(50, 20));
    cBoxResolution.setPreferredSize(new java.awt.Dimension(50, 20));
    cBoxResolution.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            cBoxResolutionActionPerformed(evt);
        }
    });
    jPanel1.add(cBoxResolution);

    controlPanel.add(jPanel1);

    spr3.setForeground(new java.awt.Color(255, 255, 255));
    spr3.setOrientation(javax.swing.SwingConstants.VERTICAL);
    spr3.setAlignmentX(1.0F);
    spr3.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    spr3.setMaximumSize(new java.awt.Dimension(5, 0));
    spr3.setPreferredSize(new java.awt.Dimension(5, 0));
    spr3.setRequestFocusEnabled(false);
    controlPanel.add(spr3);

    cBoxFromWavelength.setEditable(true);
    cBoxFromWavelength.setAutoscrolls(true);
    controlPanel.add(cBoxFromWavelength);

    cBoxToWavelength.setEditable(true);
    cBoxToWavelength.setAutoscrolls(true);
    cBoxToWavelength.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            cBoxToWavelengthActionPerformed(evt);
        }
    });
    controlPanel.add(cBoxToWavelength);

    spr5.setForeground(new java.awt.Color(255, 255, 255));
    spr5.setOrientation(javax.swing.SwingConstants.VERTICAL);
    spr5.setAlignmentX(1.0F);
    spr5.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    spr5.setMaximumSize(new java.awt.Dimension(5, 0));
    spr5.setPreferredSize(new java.awt.Dimension(5, 0));
    spr5.setRequestFocusEnabled(false);
    controlPanel.add(spr5);

    btnSetZero.setText("Set zero");
    btnSetZero.setToolTipText("Set zero imput signal level to subtract thermal noise");
    btnSetZero.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnSetZeroActionPerformed(evt);
        }
    });
    controlPanel.add(btnSetZero);

    btnSetMark.setText("Mark");
    btnSetMark.setToolTipText("Set a mark on the input graph");
    btnSetMark.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnSetMarkActionPerformed(evt);
        }
    });
    controlPanel.add(btnSetMark);

    getContentPane().add(controlPanel, java.awt.BorderLayout.SOUTH);

    menuFile.setText("File");
    menuFile.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuFileActionPerformed(evt);
        }
    });

    menuFileOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O,
            java.awt.event.InputEvent.CTRL_MASK));
    menuFileOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/open.png"))); // NOI18N
    menuFileOpen.setText("Open");
    menuFileOpen.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuFileOpenActionPerformed(evt);
        }
    });
    menuFile.add(menuFileOpen);

    menuFileSave.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
            java.awt.event.InputEvent.CTRL_MASK));
    menuFileSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/save.png"))); // NOI18N
    menuFileSave.setText("Save");
    menuFileSave.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuFileSaveActionPerformed(evt);
        }
    });
    menuFile.add(menuFileSave);

    menuFileExit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W,
            java.awt.event.InputEvent.CTRL_MASK));
    menuFileExit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/close.png"))); // NOI18N
    menuFileExit.setText("Exit");
    menuFileExit.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuFileExitActionPerformed(evt);
        }
    });
    menuFile.add(menuFileExit);

    strobeMenuBar.add(menuFile);

    settingMenu.setText("Settings");
    strobeMenuBar.add(settingMenu);

    menuAbout.setText("About");

    menuAboutAbout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/info.png"))); // NOI18N
    menuAboutAbout.setText("About");
    menuAboutAbout.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuAboutAboutActionPerformed(evt);
        }
    });
    menuAbout.add(menuAboutAbout);

    //chartPanel.setPreferredSize( new java.awt.Dimension(graphPanel.getMinimumSize()));

    chartPanel.setMaximumSize(new Dimension(3000, 2000));
    graphPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Spectrum"));

    graphPanel.add(chartPanel);
    graphPanel.setLayout(new GridLayout(0, 1));
    getContentPane().add(graphPanel, java.awt.BorderLayout.CENTER);

    chartRenderer.setSeriesPaint(0, Color.RED);
    chartRenderer.setSeriesStroke(0, new BasicStroke(2.0f));
    plot.setRenderer(chartRenderer);
    plot.datasetChanged(new DatasetChangeEvent(graphChart, dataSet));
    marker.setPaint(Color.red);
    plot.addDomainMarker(marker);

    strobeMenuBar.add(menuAbout);

    setJMenuBar(strobeMenuBar);

    pack();
}

From source file:net.sf.maltcms.chromaui.chromatogram1Dviewer.ui.Chromatogram1DViewTopComponent.java

public void initialize(final IChromAUIProject project, final List<IChromatogramDescriptor> filename,
        final ADataset1D<IChromatogram1D, IScan> ds) {
    boolean initializedSucccess = initialized.compareAndSet(false, true);
    if (initializedSucccess) {
        final Chromatogram1DViewTopComponent instance = this;
        final ProgressHandle handle = ProgressHandleFactory.createHandle("Loading chart");
        final JComponent progressComponent = ProgressHandleFactory.createProgressComponent(handle);
        final JPanel box = new JPanel();
        box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
        box.add(Box.createHorizontalGlue());
        box.add(progressComponent);/*w  ww . j  a  v  a2 s. c o m*/
        box.add(Box.createHorizontalGlue());
        add(box, BorderLayout.CENTER);
        AProgressAwareRunnable runnable = new AProgressAwareRunnable() {
            @Override
            public void run() {
                try {
                    handle.start();
                    handle.progress("Initializing Overlays...");
                    if (project != null) {
                        ic.add(project);
                    }
                    dataset = ds;
                    annotations = new ArrayList<>(0);
                    final DefaultComboBoxModel dcbm = new DefaultComboBoxModel();
                    for (IChromatogramDescriptor descr : filename) {
                        ic.add(descr);
                        List<ChartOverlay> overlays = new LinkedList<>();
                        if (project != null) {
                            Collection<Peak1DContainer> peaks = project.getPeaks(descr);
                            for (Peak1DContainer container : peaks) {
                                Peak1DOverlay overlay = new Peak1DOverlay(descr, container.getName(),
                                        container.getDisplayName(), container.getShortDescription(), true,
                                        container);
                                ic.add(overlay);
                                overlays.add(overlay);
                            }
                        }
                        /*
                         * Virtual overlay that groups all related overlays
                         */
                        ChromatogramDescriptorOverlay cdo = new ChromatogramDescriptorOverlay(descr,
                                descr.getName(), descr.getDisplayName(), descr.getShortDescription(), true,
                                overlays);
                        ic.add(cdo);
                        // create node children for display in navigator view
                        Children children = Children.create(new ChartOverlayChildFactory(overlays), true);
                        // create the actual node for this chromatogram
                        ic.add(Charts.overlayNode(cdo, children));
                        for (int i = 0; i < ds.getSeriesCount(); i++) {
                            if (ds.getSeriesKey(i).toString().equals(descr.getDisplayName())) {
                                dcbm.addElement(new SeriesItem(cdo, ds.getSeriesKey(i), true));
                            }
                        }
                    }
                    ic.add(ds);
                    handle.progress("Initializing Settings and Properties...");
                    ic.add(new Properties());
                    sp = new SettingsPanel();
                    ic.add(sp);
                    result = Utilities.actionsGlobalContext().lookupResult(ChromatogramViewViewport.class);
                    result.addLookupListener(instance);
                    handle.progress("Creating panel...");
                    jp = new Chromatogram1DViewPanel(ic, getLookup(), ds);
                    ic.add(jp);
                    ic.add(this);
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            //EDT stuff
                            setDisplayName("Chromatogram View of " + new File(
                                    getLookup().lookup(IChromatogramDescriptor.class).getResourceLocation())
                                            .getName());
                            setToolTipText(
                                    getLookup().lookup(IChromatogramDescriptor.class).getResourceLocation());
                            seriesComboBox.setModel(dcbm);
                            remove(box);
                            add(new JScrollPane(jp, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
                            load();
                        }
                    });
                } finally {
                    handle.finish();
                }
            }
        };
        runnable.setProgressHandle(handle);
        AProgressAwareRunnable.createAndRun("Creating chart", runnable);
    }
}

From source file:AccessibleScrollDemo.java

public AccessibleScrollDemo() {
    //Load the photograph into an image icon.
    ImageIcon david = new ImageIcon("images/youngdad.jpeg");
    david.setDescription("Photograph of David McNabb in his youth.");

    //Create the row and column headers
    columnView = new Rule(Rule.HORIZONTAL, true);
    columnView.setPreferredWidth(david.getIconWidth());
    columnView.getAccessibleContext().setAccessibleName("Column Header");
    columnView.getAccessibleContext()/*from ww  w. j  a v a 2s  .c  o  m*/
            .setAccessibleDescription("Displays horizontal ruler for " + "measuring scroll pane client.");
    rowView = new Rule(Rule.VERTICAL, true);
    rowView.setPreferredHeight(david.getIconHeight());
    rowView.getAccessibleContext().setAccessibleName("Row Header");
    rowView.getAccessibleContext()
            .setAccessibleDescription("Displays vertical ruler for " + "measuring scroll pane client.");

    //Create the corners
    JPanel buttonCorner = new JPanel();
    isMetric = new JToggleButton("cm", true);
    isMetric.setFont(new Font("SansSerif", Font.PLAIN, 11));
    isMetric.setMargin(new Insets(2, 2, 2, 2));
    isMetric.addItemListener(new UnitsListener());
    isMetric.setToolTipText("Toggles rulers' unit of measure " + "between inches and centimeters.");
    buttonCorner.add(isMetric); //Use the default FlowLayout
    buttonCorner.getAccessibleContext().setAccessibleName("Upper Left Corner");

    String desc = "Fills the corner of a scroll pane " + "with color for aesthetic reasons.";
    Corner lowerLeft = new Corner();
    lowerLeft.getAccessibleContext().setAccessibleName("Lower Left Corner");
    lowerLeft.getAccessibleContext().setAccessibleDescription(desc);

    Corner upperRight = new Corner();
    upperRight.getAccessibleContext().setAccessibleName("Upper Right Corner");
    upperRight.getAccessibleContext().setAccessibleDescription(desc);

    //Set up the scroll pane
    picture = new ScrollablePicture(david, columnView.getIncrement());
    picture.setToolTipText(david.getDescription());
    picture.getAccessibleContext().setAccessibleName("Scroll pane client");

    JScrollPane pictureScrollPane = new JScrollPane(picture);
    pictureScrollPane.setPreferredSize(new Dimension(300, 250));
    pictureScrollPane.setViewportBorder(BorderFactory.createLineBorder(Color.black));

    pictureScrollPane.setColumnHeaderView(columnView);
    pictureScrollPane.setRowHeaderView(rowView);

    pictureScrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, buttonCorner);
    pictureScrollPane.setCorner(JScrollPane.LOWER_LEFT_CORNER, lowerLeft);
    pictureScrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, upperRight);

    //Put it in this panel
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    add(pictureScrollPane);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:gdt.jgui.entity.index.JIndexPanel.java

/**
 * The default constructor./*w w  w . j a v  a 2  s. c  o  m*/
 */
public JIndexPanel() {
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    scrollPane = new JScrollPane();
    add(scrollPane);

}

From source file:BoxAlignmentDemo.java

protected JPanel createYAlignmentExample(boolean doItRight) {
    JPanel pane = new JPanel();
    String title;//from   www .  ja  v a  2  s.  co  m

    JComponent component1 = new JPanel();
    Dimension size = new Dimension(100, 50);
    component1.setMaximumSize(size);
    component1.setPreferredSize(size);
    component1.setMinimumSize(size);
    TitledBorder border = new TitledBorder(new LineBorder(Color.black), "A JPanel", TitledBorder.CENTER,
            TitledBorder.BELOW_TOP);
    border.setTitleColor(Color.black);
    component1.setBorder(border);

    JComponent component2 = new JPanel();
    size = new Dimension(100, 50);
    component2.setMaximumSize(size);
    component2.setPreferredSize(size);
    component2.setMinimumSize(size);
    border = new TitledBorder(new LineBorder(Color.black), "A JPanel", TitledBorder.CENTER,
            TitledBorder.BELOW_TOP);
    border.setTitleColor(Color.black);
    component2.setBorder(border);

    if (doItRight) {
        title = "Matched";
    } else {
        component1.setAlignmentY(TOP_ALIGNMENT);
        title = "Mismatched";
    }

    pane.setBorder(BorderFactory.createTitledBorder(title));
    pane.setLayout(new BoxLayout(pane, BoxLayout.X_AXIS));
    pane.add(component1);
    pane.add(component2);
    return pane;
}