Example usage for javax.swing BoxLayout LINE_AXIS

List of usage examples for javax.swing BoxLayout LINE_AXIS

Introduction

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

Prototype

int LINE_AXIS

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

Click Source Link

Document

Specifies that components should be laid out in the direction of a line of text as determined by the target container's ComponentOrientation property.

Usage

From source file:components.ListDialog.java

private ListDialog(Frame frame, Component locationComp, String labelText, String title, Object[] data,
        String initialValue, String longValue) {
    super(frame, title, true);

    //Create and initialize the buttons.
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(this);
    ////  w  w  w .  j  a  va2  s  .c  om
    final JButton setButton = new JButton("Set");
    setButton.setActionCommand("Set");
    setButton.addActionListener(this);
    getRootPane().setDefaultButton(setButton);

    //main part of the dialog
    list = new JList(data) {
        //Subclass JList to workaround bug 4832765, which can cause the
        //scroll pane to not let the user easily scroll up to the beginning
        //of the list.  An alternative would be to set the unitIncrement
        //of the JScrollBar to a fixed value. You wouldn't get the nice
        //aligned scrolling, but it should work.
        public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
            int row;
            if (orientation == SwingConstants.VERTICAL && direction < 0
                    && (row = getFirstVisibleIndex()) != -1) {
                Rectangle r = getCellBounds(row, row);
                if ((r.y == visibleRect.y) && (row != 0)) {
                    Point loc = r.getLocation();
                    loc.y--;
                    int prevIndex = locationToIndex(loc);
                    Rectangle prevR = getCellBounds(prevIndex, prevIndex);

                    if (prevR == null || prevR.y >= r.y) {
                        return 0;
                    }
                    return prevR.height;
                }
            }
            return super.getScrollableUnitIncrement(visibleRect, orientation, direction);
        }
    };

    list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    if (longValue != null) {
        list.setPrototypeCellValue(longValue); //get extra space
    }
    list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    list.setVisibleRowCount(-1);
    list.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                setButton.doClick(); //emulate button click
            }
        }
    });
    JScrollPane listScroller = new JScrollPane(list);
    listScroller.setPreferredSize(new Dimension(250, 80));
    listScroller.setAlignmentX(LEFT_ALIGNMENT);

    //Create a container so that we can add a title around
    //the scroll pane.  Can't add a title directly to the
    //scroll pane because its background would be white.
    //Lay out the label and scroll pane from top to bottom.
    JPanel listPane = new JPanel();
    listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS));
    JLabel label = new JLabel(labelText);
    label.setLabelFor(list);
    listPane.add(label);
    listPane.add(Box.createRigidArea(new Dimension(0, 5)));
    listPane.add(listScroller);
    listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    //Lay out the buttons from left to right.
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(cancelButton);
    buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
    buttonPane.add(setButton);

    //Put everything together, using the content pane's BorderLayout.
    Container contentPane = getContentPane();
    contentPane.add(listPane, BorderLayout.CENTER);
    contentPane.add(buttonPane, BorderLayout.PAGE_END);

    //Initialize values.
    setValue(initialValue);
    pack();
    setLocationRelativeTo(locationComp);
}

From source file:org.streamspinner.harmonica.application.CQGraphTerminal.java

private JPanel getJContentPane() {
    if (jContentPane == null) {
        jContentPane = new JPanel();
        jContentPane.setLayout(new BoxLayout(jContentPane, BoxLayout.LINE_AXIS));
        jContentPane.add(getJPanel0());//from www. j  a  va 2 s  .  com
        jContentPane.add(getJPanel());
        /*
        jContentPane.setLayout(null);      
        jContentPane.add(getJScrollPane(), null);                  
        jContentPane.add(getJScrollPane1(), null);                  
        jContentPane.add(getJButton(), null);
        jContentPane.add(getJButton1(), null);            
        jContentPane.add(getJPanel(), null);
        */
    }
    return jContentPane;
}

From source file:io.github.jeremgamer.editor.panels.Buttons.java

public Buttons(final JFrame frame, final ButtonPanel be, final PanelSave ps) {
    this.setBorder(BorderFactory.createTitledBorder(""));

    this.frame = frame;

    JButton add = null;//from  www  .j  av  a2 s.  co m
    try {
        add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    add.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                JOptionPane jop = new JOptionPane();
                @SuppressWarnings("static-access")
                String name = jop.showInputDialog(null, "Nommez le bouton :", "Crer un bouton",
                        JOptionPane.QUESTION_MESSAGE);

                if (name != null) {
                    for (int i = 0; i < data.getSize(); i++) {
                        if (data.get(i).equals(name)) {
                            name += "1";
                        }
                    }
                    data.addElement(name);
                    new ButtonSave(name);
                    ActionPanel.updateLists();
                    OtherPanel.updateLists();
                    PanelsPanel.updateLists();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

        }

    });

    JButton remove = null;
    try {
        remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    remove.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                if (buttonList.getSelectedValue() != null) {
                    File file = new File("projects/" + Editor.getProjectName() + "/buttons/"
                            + buttonList.getSelectedValue() + "/" + buttonList.getSelectedValue() + ".rbd");
                    JOptionPane jop = new JOptionPane();
                    @SuppressWarnings("static-access")
                    int option = jop.showConfirmDialog(null, "tes-vous sr de vouloir supprimer ce bouton?",
                            "Avertissement", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);

                    if (option == JOptionPane.OK_OPTION) {
                        File dir = new File("projects/" + Editor.getProjectName() + "/panels");
                        for (File f : FileUtils.listFilesAndDirs(dir, TrueFileFilter.INSTANCE,
                                TrueFileFilter.INSTANCE)) {
                            if (!f.isDirectory()) {
                                try {
                                    ps.load(f);
                                } catch (IOException e) {
                                    e.printStackTrace();
                                }
                                for (String section : ps
                                        .getSectionsContaining(buttonList.getSelectedValue() + " (Bouton)")) {
                                    ps.removeSection(section);
                                    try {
                                        ps.save(f);
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        }
                        if (buttonList.getSelectedValue().equals(be.getFileName())) {
                            be.setFileName("");
                        }
                        be.hide();
                        file.delete();
                        File parent = new File(file.getParent());
                        for (File img : FileUtils.listFiles(parent, TrueFileFilter.INSTANCE,
                                TrueFileFilter.INSTANCE)) {
                            img.delete();
                        }
                        parent.delete();
                        data.remove(buttonList.getSelectedIndex());
                        ActionPanel.updateLists();
                        OtherPanel.updateLists();
                        PanelsPanel.updateLists();
                    }
                }
            } catch (NullPointerException npe) {
                npe.printStackTrace();
            }

        }

    });

    JPanel buttons = new JPanel();
    buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS));
    buttons.add(add);
    buttons.add(remove);

    updateList();
    buttonList.addMouseListener(new MouseAdapter() {
        @SuppressWarnings("unchecked")
        public void mouseClicked(MouseEvent evt) {
            JList<String> list = (JList<String>) evt.getSource();
            if (evt.getClickCount() == 2) {
                int index = list.locationToIndex(evt.getPoint());
                if (isOpen == false) {
                    be.load(new File("projects/" + Editor.getProjectName() + "/buttons/"
                            + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index)
                            + ".rbd"));
                    be.show();
                    previousSelection = list.getSelectedValue();
                    isOpen = true;
                } else {
                    try {
                        if (previousSelection.equals(list.getModel().getElementAt(index))) {
                            be.hide();
                            previousSelection = list.getSelectedValue();
                            list.clearSelection();
                            isOpen = false;
                        } else {
                            be.hideThenShow();
                            previousSelection = list.getSelectedValue();
                            be.load(new File("projects/" + Editor.getProjectName() + "/buttons/"
                                    + list.getModel().getElementAt(index) + "/"
                                    + list.getModel().getElementAt(index) + ".rbd"));
                        }
                    } catch (NullPointerException npe) {
                        be.hide();
                        list.clearSelection();
                    }
                }
            } else if (evt.getClickCount() == 3) {
                int index = list.locationToIndex(evt.getPoint());
                if (isOpen == false) {
                    be.load(new File("projects/" + Editor.getProjectName() + "/buttons/"
                            + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index)
                            + ".rbd"));
                    be.show();
                    previousSelection = list.getSelectedValue();
                    isOpen = true;
                } else {
                    try {
                        if (previousSelection.equals(list.getModel().getElementAt(index))) {
                            be.hide();
                            previousSelection = list.getSelectedValue();
                            list.clearSelection();
                            isOpen = false;
                        } else {
                            be.hideThenShow();
                            previousSelection = list.getSelectedValue();
                            be.load(new File("projects/" + Editor.getProjectName() + "/buttons/"
                                    + list.getModel().getElementAt(index) + "/"
                                    + list.getModel().getElementAt(index) + ".rbd"));
                        }
                    } catch (NullPointerException npe) {
                        be.hide();
                        list.clearSelection();
                    }
                }
            }
        }
    });
    JScrollPane listPane = new JScrollPane(buttonList);
    listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED);
    this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    this.add(buttons);
    this.add(listPane);

}

From source file:com.gdc.nms.web.mibquery.wizard.ciscavate.cjwizard.WizardContainer.java

/**
 * // w  ww .java  2  s . com
 */
private void initComponents() {
    final JButton prevBtn = new JButton(_prevAction);
    final JButton nextBtn = new JButton(_nextAction);
    final JButton finishBtn = new JButton(_finishAction);
    final JButton cancelBtn = new JButton(_cancelAction);

    _extraButtonPanel = new JPanel();
    _extraButtonPanel.setLayout(new BoxLayout(_extraButtonPanel, BoxLayout.LINE_AXIS));

    final JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
    buttonPanel.add(_extraButtonPanel);
    buttonPanel.add(Box.createHorizontalGlue());
    buttonPanel.add(prevBtn);
    buttonPanel.add(Box.createHorizontalStrut(5));
    buttonPanel.add(nextBtn);
    buttonPanel.add(Box.createHorizontalStrut(10));
    buttonPanel.add(finishBtn);
    buttonPanel.add(Box.createHorizontalStrut(10));
    buttonPanel.add(cancelBtn);

    buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15));
    //this.setLayout(new BorderLayout());

    //this.add(_template, BorderLayout.CENTER);
    //this.add(buttonPanel, BorderLayout.SOUTH);
}

From source file:com.github.cjwizard.WizardContainer.java

/**
 * //from www  .  ja v a 2 s.  c o  m
 */
private void initComponents() {
    final JButton prevBtn = new JButton(_prevAction);
    final JButton nextBtn = new JButton(_nextAction);
    final JButton finishBtn = new JButton(_finishAction);
    final JButton cancelBtn = new JButton(_cancelAction);

    _extraButtonPanel = new JPanel();
    _extraButtonPanel.setLayout(new BoxLayout(_extraButtonPanel, BoxLayout.LINE_AXIS));

    final JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
    buttonPanel.add(_extraButtonPanel);
    buttonPanel.add(Box.createHorizontalGlue());
    buttonPanel.add(prevBtn);
    buttonPanel.add(Box.createHorizontalStrut(5));
    buttonPanel.add(nextBtn);
    buttonPanel.add(Box.createHorizontalStrut(10));
    buttonPanel.add(finishBtn);
    buttonPanel.add(Box.createHorizontalStrut(10));
    buttonPanel.add(cancelBtn);

    buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15));
    this.setLayout(new BorderLayout());

    this.add(_template, BorderLayout.CENTER);
    this.add(buttonPanel, BorderLayout.SOUTH);
}

From source file:edu.ku.brc.specify.ui.treetables.TreeDefinitionEditor.java

/**
* @param isEditMode whether to enable editing.
*//*from ww w  . java  2  s .  com*/
protected void initUI() {
    this.setLayout(new BorderLayout());

    Dimension horizSpacer = new Dimension(5, 0);

    statusBar = UIRegistry.getStatusBar();

    // create north panel
    titlePanel = new JPanel();
    titlePanel.setLayout(new BoxLayout(titlePanel, BoxLayout.LINE_AXIS));

    defNameLabel = createLabel(""); //$NON-NLS-1$

    titlePanel.add(Box.createHorizontalGlue());
    titlePanel.add(defNameLabel);
    titlePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 4, 0));

    if (isEditMode) {
        //editDefButton = createButton(editIcon);
        editDefButton = UIHelper.createIconBtn("EditIcon", "TTV_EDIT_TREDEF_TITLE", new ActionListener() //$NON-NLS-1$ //$NON-NLS-2$
        {
            public void actionPerformed(ActionEvent ae) {
                showDefEditDialog(displayedDef);
            }
        });
        editDefButton.setEnabled(true);

        // add north panel widgets
        titlePanel.add(Box.createRigidArea(horizSpacer));
        titlePanel.add(editDefButton);

    } else {
        editDefButton = null;
    }
    titlePanel.add(Box.createHorizontalGlue());

    if (isEditMode) {
        // create south panel
        ActionListener deleteAction = new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                deleteItem(defItemsTable.getSelectedRow());
            }
        };
        ActionListener newItemAction = new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                newItem(defItemsTable.getSelectedRow());
            }
        };

        ActionListener editItemAction = new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                editTreeDefItem(defItemsTable.getSelectedRow());
            }
        };

        edaPanel = new EditDeleteAddPanel(editItemAction, deleteAction, newItemAction, "TTV_EDIT_TDI", //$NON-NLS-1$
                "TTV_DEL_TDI", "TTV_NEW_TDI"); //$NON-NLS-1$ //$NON-NLS-2$
    }
}

From source file:io.github.jeremgamer.editor.panels.Others.java

public Others(final JFrame frame, final OtherPanel op, final PanelSave ps) {
    this.frame = frame;

    this.setBorder(BorderFactory.createTitledBorder(""));
    JButton add = null;//from   w w w .  ja  v  a  2  s .c o  m
    try {
        add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    add.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                JOptionPane jop = new JOptionPane();
                @SuppressWarnings("static-access")
                String name = jop.showInputDialog((JFrame) SwingUtilities.windowForComponent(otherList),
                        "Nommez le composant :", "Crer un composant", JOptionPane.QUESTION_MESSAGE);

                if (name != null) {
                    for (int i = 0; i < data.getSize(); i++) {
                        if (data.get(i).equals(name)) {
                            name += "1";
                        }
                    }
                    data.addElement(name);
                    new OtherSave(name);
                    ActionPanel.updateLists();
                    PanelsPanel.updateLists();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

        }

    });

    JButton remove = null;
    try {
        remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    remove.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                if (otherList.getSelectedValue() != null) {
                    File file = new File("projects/" + Editor.getProjectName() + "/others/"
                            + otherList.getSelectedValue() + ".rbd");
                    JOptionPane jop = new JOptionPane();
                    @SuppressWarnings("static-access")
                    int option = jop.showConfirmDialog((JFrame) SwingUtilities.windowForComponent(otherList),
                            "tes-vous sr de vouloir supprimer ce composant?", "Avertissement",
                            JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);

                    if (option == JOptionPane.OK_OPTION) {
                        File dir = new File("projects/" + Editor.getProjectName() + "/panels");
                        for (File f : FileUtils.listFilesAndDirs(dir, TrueFileFilter.INSTANCE,
                                TrueFileFilter.INSTANCE)) {
                            if (!f.isDirectory()) {
                                try {
                                    ps.load(f);
                                } catch (IOException e) {
                                    e.printStackTrace();
                                }

                                OtherSave os = new OtherSave();
                                try {
                                    os.load(file);
                                } catch (IOException e1) {
                                    e1.printStackTrace();
                                }
                                String type = null;
                                switch (os.getInt("type")) {
                                case 0:
                                    type = "Zone de saisie";
                                    break;
                                case 1:
                                    type = "Zone de saisie de mot de passe";
                                    break;
                                case 2:
                                    type = "Zone de saisie (Grande)";
                                    break;
                                case 3:
                                    type = "Case  cocher";
                                    break;
                                case 4:
                                    type = "Menu droulant";
                                    break;
                                case 5:
                                    type = "Barre de progression";
                                    break;
                                case 6:
                                    type = "Slider";
                                    break;
                                case 7:
                                    type = "Spinner";
                                    break;
                                }
                                for (String section : ps.getSectionsContaining(
                                        otherList.getSelectedValue() + " (" + type + ")")) {
                                    ps.removeSection(section);
                                    try {
                                        ps.save(f);
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        }
                        if (otherList.getSelectedValue().equals(op.getFileName())) {
                            op.setFileName("");
                        }
                        op.hide();
                        file.delete();
                        data.remove(otherList.getSelectedIndex());
                        ActionPanel.updateLists();
                        OtherPanel.updateLists();
                        PanelsPanel.updateLists();
                    }
                }
            } catch (NullPointerException npe) {
                npe.printStackTrace();
            }

        }

    });

    JPanel buttons = new JPanel();
    buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS));
    buttons.add(add);
    buttons.add(remove);

    updateList();
    otherList.addMouseListener(new MouseAdapter() {
        @SuppressWarnings("unchecked")
        public void mouseClicked(MouseEvent evt) {
            JList<String> list = (JList<String>) evt.getSource();
            if (evt.getClickCount() == 2) {
                int index = list.locationToIndex(evt.getPoint());
                if (isOpen == false) {
                    op.show();
                    op.load(new File("projects/" + Editor.getProjectName() + "/others/"
                            + list.getModel().getElementAt(index) + ".rbd"));
                    previousSelection = list.getSelectedValue();
                    isOpen = true;
                } else {
                    try {
                        if (previousSelection.equals(list.getModel().getElementAt(index))) {
                            op.hide();
                            previousSelection = list.getSelectedValue();
                            list.clearSelection();
                            isOpen = false;
                        } else {
                            op.hideThenShow();
                            previousSelection = list.getSelectedValue();
                            op.load(new File("projects/" + Editor.getProjectName() + "/others/"
                                    + list.getModel().getElementAt(index) + ".rbd"));
                        }
                    } catch (NullPointerException npe) {
                        op.hide();
                        list.clearSelection();
                    }
                }
            } else if (evt.getClickCount() == 3) {
                int index = list.locationToIndex(evt.getPoint());
                if (isOpen == false) {
                    op.show();
                    op.load(new File("projects/" + Editor.getProjectName() + "/others/"
                            + list.getModel().getElementAt(index) + ".rbd"));
                    previousSelection = list.getSelectedValue();
                    isOpen = true;
                } else {
                    try {
                        if (previousSelection.equals(list.getModel().getElementAt(index))) {
                            op.hide();
                            previousSelection = list.getSelectedValue();
                            list.clearSelection();
                            isOpen = false;
                        } else {
                            op.hideThenShow();
                            previousSelection = list.getSelectedValue();
                            op.load(new File("projects/" + Editor.getProjectName() + "/others/"
                                    + list.getModel().getElementAt(index) + ".rbd"));
                        }
                    } catch (NullPointerException npe) {
                        op.hide();
                        list.clearSelection();
                    }
                }
            }
        }
    });
    JScrollPane listPane = new JScrollPane(otherList);
    listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED);
    this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    this.add(buttons);
    this.add(listPane);
    OtherPanel.updateLists();
}

From source file:ch.zhaw.ias.dito.ui.AnalysisPanel.java

private JPanel createDecompositionPanel(String title, double[][] mdsValues) {
    JFreeChart chart = ChartFactory.createScatterPlot(title, null, null, new MdsXYDataset(mdsValues),
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.getRenderer().setBaseToolTipGenerator(new XYToolTipGenerator() {
        @Override/*  w w  w  .j a  va2s  . c o  m*/
        public String generateToolTip(XYDataset dataset, int series, int item) {
            return "item #" + (item + 1);
        }
    });

    JPanel mdsPanel = new JPanel(new BorderLayout(0, 10));
    mdsPanel.add(new ChartPanel(chart), BorderLayout.CENTER);
    dimensionsCombo = new JComboBox(new Integer[] { 2, 3 });
    JButton exportButton = new JButton(Translation.INSTANCE.get("s4.bu.exportDecomposition"));
    exportButton.addActionListener(this);
    JPanel mdsInputPanel = new JPanel();
    mdsInputPanel.setLayout(new BoxLayout(mdsInputPanel, BoxLayout.LINE_AXIS));
    mdsInputPanel.add(Box.createHorizontalGlue());
    mdsInputPanel.add(Box.createHorizontalGlue());
    mdsInputPanel.add(new JLabel(Translation.INSTANCE.get("s4.lb.dimension")));
    mdsInputPanel.add(Box.createHorizontalStrut(10));
    mdsInputPanel.add(dimensionsCombo);
    mdsInputPanel.add(Box.createHorizontalStrut(10));
    mdsInputPanel.add(exportButton);
    mdsPanel.add(mdsInputPanel, BorderLayout.SOUTH);

    return mdsPanel;
}

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.//ww  w .  j  a  v a2s  .  c o 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.vfsjfilechooser.plaf.metal.MetalVFSFileChooserUI.java

@SuppressWarnings("serial")
@Override/*  w  w w.j a v  a 2s.com*/
public void installComponents(VFSJFileChooser fc) {
    AbstractVFSFileSystemView fsv = fc.getFileSystemView();

    fc.setBorder(new EmptyBorder(12, 12, 11, 11));
    fc.setLayout(new BorderLayout(0, 11));

    filePane = new VFSFilePane(new MetalVFSFileChooserUIAccessor());
    fc.addPropertyChangeListener(filePane);

    updateUseShellFolder();

    // ********************************* //
    // **** Construct the top panel **** //
    // ********************************* //

    // Directory manipulation buttons
    JPanel topPanel = new JPanel(new BorderLayout(11, 0));
    topButtonPanel = new JPanel();
    topButtonPanel.setLayout(new BoxLayout(topButtonPanel, BoxLayout.LINE_AXIS));
    topPanel.add(topButtonPanel, BorderLayout.AFTER_LINE_ENDS);

    // Add the top panel to the fileChooser
    fc.add(topPanel, BorderLayout.NORTH);

    // ComboBox Label
    lookInLabel = new JLabel(lookInLabelText);
    topPanel.add(lookInLabel, BorderLayout.BEFORE_LINE_BEGINS);

    // CurrentDir ComboBox
    directoryComboBox = new JComboBox() {
        @Override
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            // Must be small enough to not affect total width.
            d.width = 150;

            return d;
        }
    };
    directoryComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, lookInLabelText);
    directoryComboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    lookInLabel.setLabelFor(directoryComboBox);
    directoryComboBoxModel = createDirectoryComboBoxModel(fc);
    directoryComboBox.setModel(directoryComboBoxModel);
    directoryComboBox.addActionListener(directoryComboBoxAction);
    directoryComboBox.setRenderer(createDirectoryComboBoxRenderer(fc));
    directoryComboBox.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    directoryComboBox.setAlignmentY(JComponent.TOP_ALIGNMENT);
    directoryComboBox.setMaximumRowCount(8);

    topPanel.add(directoryComboBox, BorderLayout.CENTER);

    // Up Button
    upFolderButton = new JButton(getChangeToParentDirectoryAction());
    upFolderButton.setText(null);
    upFolderButton.setIcon(upFolderIcon);
    upFolderButton.setToolTipText(upFolderToolTipText);
    upFolderButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, upFolderAccessibleName);
    upFolderButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    upFolderButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    upFolderButton.setMargin(shrinkwrap);

    topButtonPanel.add(upFolderButton);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // Home Button
    FileObject homeDir = fsv.getHomeDirectory();
    String toolTipText = homeFolderToolTipText;

    if (fsv.isRoot(homeDir)) {
        toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop".
    }

    JButton b = new JButton(homeFolderIcon);
    b.setToolTipText(toolTipText);
    b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, homeFolderAccessibleName);
    b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    b.setMargin(shrinkwrap);

    b.addActionListener(getGoHomeAction());
    topButtonPanel.add(b);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // New Directory Button
    if (!UIManager.getBoolean("FileChooser.readOnly")) {
        b = new JButton(filePane.getNewFolderAction());
        b.setText(null);
        b.setIcon(newFolderIcon);
        b.setToolTipText(newFolderToolTipText);
        b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, newFolderAccessibleName);
        b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
        b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
        b.setMargin(shrinkwrap);
    }

    topButtonPanel.add(b);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // View button group
    ButtonGroup viewButtonGroup = new ButtonGroup();

    // List Button
    listViewButton = new JToggleButton(listViewIcon);
    listViewButton.setToolTipText(listViewButtonToolTipText);
    listViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, listViewButtonAccessibleName);
    listViewButton.setSelected(true);
    listViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    listViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    listViewButton.setMargin(shrinkwrap);
    listViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_LIST));
    topButtonPanel.add(listViewButton);
    viewButtonGroup.add(listViewButton);

    // Details Button
    detailsViewButton = new JToggleButton(detailsViewIcon);
    detailsViewButton.setToolTipText(detailsViewButtonToolTipText);
    detailsViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
            detailsViewButtonAccessibleName);
    detailsViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    detailsViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    detailsViewButton.setMargin(shrinkwrap);
    detailsViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_DETAILS));
    topButtonPanel.add(detailsViewButton);
    viewButtonGroup.add(detailsViewButton);
    filePane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            if ("viewType".equals(e.getPropertyName())) {
                final int viewType = filePane.getViewType();

                if (viewType == VFSFilePane.VIEWTYPE_LIST) {
                    listViewButton.setSelected(true);
                } else if (viewType == VFSFilePane.VIEWTYPE_DETAILS) {
                    detailsViewButton.setSelected(true);
                }
            }
        }
    });

    // ************************************** //
    // ******* Add the directory pane ******* //
    // ************************************** //
    fc.add(getAccessoryPanel(), BorderLayout.AFTER_LINE_ENDS);

    JComponent accessory = fc.getAccessory();

    if (accessory != null) {
        getAccessoryPanel().add(accessory);
    }

    filePane.setPreferredSize(LIST_PREF_SIZE);
    fc.add(filePane, BorderLayout.CENTER);

    // ********************************** //
    // **** Construct the bottom panel ** //
    // ********************************** //
    bottomPanel = getBottomPanel();
    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS));
    fc.add(bottomPanel, BorderLayout.SOUTH);

    // FileName label and textfield
    JPanel fileNamePanel = new JPanel();
    fileNamePanel.setLayout(new BoxLayout(fileNamePanel, BoxLayout.LINE_AXIS));
    bottomPanel.add(fileNamePanel);
    bottomPanel.add(Box.createRigidArea(vstrut5));

    fileNameLabel = new AlignedLabel();
    populateFileNameLabel();
    fileNamePanel.add(fileNameLabel);

    fileNameTextField = new JTextField(35) {
        @Override
        public Dimension getMaximumSize() {
            return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height);
        }
    };

    PopupHandler.installDefaultMouseListener(fileNameTextField);

    fileNamePanel.add(fileNameTextField);
    fileNameLabel.setLabelFor(fileNameTextField);
    fileNameTextField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            if (!getFileChooser().isMultiSelectionEnabled()) {
                filePane.clearSelection();
            }
        }
    });

    if (fc.isMultiSelectionEnabled()) {
        setFileName(fileNameString(fc.getSelectedFiles()));
    } else {
        setFileName(fileNameString(fc.getSelectedFile()));
    }

    // Filetype label and combobox
    JPanel filesOfTypePanel = new JPanel();
    filesOfTypePanel.setLayout(new BoxLayout(filesOfTypePanel, BoxLayout.LINE_AXIS));
    bottomPanel.add(filesOfTypePanel);

    AlignedLabel filesOfTypeLabel = new AlignedLabel(filesOfTypeLabelText);
    filesOfTypePanel.add(filesOfTypeLabel);

    filterComboBoxModel = createFilterComboBoxModel();
    fc.addPropertyChangeListener(filterComboBoxModel);
    filterComboBox = new JComboBox(filterComboBoxModel);
    filterComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, filesOfTypeLabelText);
    filesOfTypeLabel.setLabelFor(filterComboBox);
    filterComboBox.setRenderer(createFilterComboBoxRenderer());
    filesOfTypePanel.add(filterComboBox);

    // buttons
    getButtonPanel().setLayout(new ButtonAreaLayout());

    approveButton = new JButton(getApproveButtonText(fc));
    // Note: Metal does not use mnemonics for approve and cancel
    approveButton.addActionListener(getApproveSelectionAction());
    fileNameTextField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                getApproveSelectionAction().actionPerformed(null);
            }
        }
    });
    approveButton.setToolTipText(getApproveButtonToolTipText(fc));
    getButtonPanel().add(approveButton);

    cancelButton = new JButton(cancelButtonText);
    cancelButton.setToolTipText(cancelButtonToolTipText);
    cancelButton.addActionListener(getCancelSelectionAction());
    getButtonPanel().add(cancelButton);

    if (fc.getControlButtonsAreShown()) {
        addControlButtons();
    }

    groupLabels(new AlignedLabel[] { fileNameLabel, filesOfTypeLabel });
}