Example usage for javax.swing JSeparator JSeparator

List of usage examples for javax.swing JSeparator JSeparator

Introduction

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

Prototype

public JSeparator() 

Source Link

Document

Creates a new horizontal separator.

Usage

From source file:client.ui.FilePane.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  .  ja  v  a  2  s . c  o m
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    fileButtonPane = new JPanel();
    uploadFileButton = new JButton();
    downloadFileButton = new JButton();
    deleteFileButton = new JButton();
    renameFileButton = new JButton();
    authorizationButton = new JButton();
    jSeparator1 = new JSeparator();
    addNoteButton = new JButton();
    deleteNoteButton = new JButton();
    jSeparator2 = new JSeparator();
    targetIDField = new JTextField();
    searchUserButton = new JButton();
    returnButton = new JButton();
    jSeparator3 = new JSeparator();
    refreshButton = new JButton();
    jSeparator4 = new JSeparator();
    changePasswdButton = new JButton();
    fileSplitPane = new JSplitPane();
    jSplitPane2 = new JSplitPane();
    fileInfoScroll = new JScrollPane();
    fileInfoTable = new JTable();
    noteDisplayScroll = new JScrollPane();
    noteTable = new JTable();
    jSplitPane1 = new JSplitPane();
    fileDisplayScroll = new JScrollPane();
    fileContentArea = new JTextArea();
    noteInputScroll = new JScrollPane();
    noteInputArea = new JTextArea();

    FormListener formListener = new FormListener();

    setForeground(new Color(240, 240, 240));
    setFont(new Font("", 0, 12)); // NOI18N
    setMaximumSize(new Dimension(1366, 768));
    setPreferredSize(new Dimension(1366, 700));

    fileButtonPane.setMaximumSize(new Dimension(32767, 50));
    fileButtonPane.setMinimumSize(new Dimension(404, 50));

    uploadFileButton.setFont(new Font("", 0, 12)); // NOI18N
    uploadFileButton.setText("");
    uploadFileButton.setActionCommand("JButton1");
    uploadFileButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    uploadFileButton.setBorderPainted(false);
    uploadFileButton.setContentAreaFilled(false);
    uploadFileButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    uploadFileButton.setFocusPainted(false);
    uploadFileButton.setMaximumSize(new Dimension(30, 20));
    uploadFileButton.setMinimumSize(new Dimension(30, 20));
    uploadFileButton.addMouseListener(formListener);
    uploadFileButton.addActionListener(formListener);

    downloadFileButton.setFont(new Font("", 0, 12)); // NOI18N
    downloadFileButton.setText("");
    downloadFileButton.setActionCommand("JButton1");
    downloadFileButton.setBorder(null);
    downloadFileButton.setBorderPainted(false);
    downloadFileButton.setContentAreaFilled(false);
    downloadFileButton.setEnabled(false);
    downloadFileButton.setFocusPainted(false);
    downloadFileButton.setMaximumSize(new Dimension(30, 20));
    downloadFileButton.setMinimumSize(new Dimension(30, 20));
    downloadFileButton.setPreferredSize(new Dimension(30, 20));
    downloadFileButton.addMouseListener(formListener);
    downloadFileButton.addActionListener(formListener);

    deleteFileButton.setFont(new Font("", 0, 12)); // NOI18N
    deleteFileButton.setText("");
    deleteFileButton.setBorder(null);
    deleteFileButton.setBorderPainted(false);
    deleteFileButton.setContentAreaFilled(false);
    deleteFileButton.setEnabled(false);
    deleteFileButton.setFocusPainted(false);
    deleteFileButton.addMouseListener(formListener);
    deleteFileButton.addActionListener(formListener);

    renameFileButton.setFont(new Font("", 0, 12)); // NOI18N
    renameFileButton.setText("???");
    renameFileButton.setBorder(null);
    renameFileButton.setBorderPainted(false);
    renameFileButton.setContentAreaFilled(false);
    renameFileButton.setEnabled(false);
    renameFileButton.setFocusPainted(false);
    renameFileButton.addMouseListener(formListener);
    renameFileButton.addActionListener(formListener);

    authorizationButton.setFont(new Font("", 0, 12)); // NOI18N
    authorizationButton.setText("??");
    authorizationButton.setBorder(null);
    authorizationButton.setBorderPainted(false);
    authorizationButton.setContentAreaFilled(false);
    authorizationButton.setEnabled(false);
    authorizationButton.setFocusPainted(false);
    authorizationButton.addMouseListener(formListener);
    authorizationButton.addActionListener(formListener);

    jSeparator1.setOrientation(SwingConstants.VERTICAL);

    addNoteButton.setFont(new Font("", 0, 12)); // NOI18N
    addNoteButton.setText("");
    addNoteButton.setActionCommand("JButton1");
    addNoteButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    addNoteButton.setBorderPainted(false);
    addNoteButton.setContentAreaFilled(false);
    addNoteButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    addNoteButton.setEnabled(false);
    addNoteButton.setFocusPainted(false);
    addNoteButton.setMaximumSize(new Dimension(30, 20));
    addNoteButton.setMinimumSize(new Dimension(30, 20));
    addNoteButton.addMouseListener(formListener);
    addNoteButton.addActionListener(formListener);

    deleteNoteButton.setFont(new Font("", 0, 12)); // NOI18N
    deleteNoteButton.setText("");
    deleteNoteButton.setActionCommand("JButton1");
    deleteNoteButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    deleteNoteButton.setBorderPainted(false);
    deleteNoteButton.setContentAreaFilled(false);
    deleteNoteButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    deleteNoteButton.setEnabled(false);
    deleteNoteButton.setFocusPainted(false);
    deleteNoteButton.setMaximumSize(new Dimension(30, 20));
    deleteNoteButton.setMinimumSize(new Dimension(30, 20));
    deleteNoteButton.addMouseListener(formListener);
    deleteNoteButton.addActionListener(formListener);

    jSeparator2.setOrientation(SwingConstants.VERTICAL);

    targetIDField.setFont(new Font("", 0, 12)); // NOI18N

    searchUserButton.setFont(new Font("", 0, 12)); // NOI18N
    searchUserButton.setText("");
    searchUserButton.setActionCommand("JButton1");
    searchUserButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    searchUserButton.setBorderPainted(false);
    searchUserButton.setContentAreaFilled(false);
    searchUserButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    searchUserButton.setFocusPainted(false);
    searchUserButton.setMaximumSize(new Dimension(30, 20));
    searchUserButton.setMinimumSize(new Dimension(30, 20));
    searchUserButton.addMouseListener(formListener);
    searchUserButton.addActionListener(formListener);

    returnButton.setFont(new Font("", 0, 12)); // NOI18N
    returnButton.setText("");
    returnButton.setActionCommand("JButton1");
    returnButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    returnButton.setBorderPainted(false);
    returnButton.setContentAreaFilled(false);
    returnButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    returnButton.setFocusPainted(false);
    returnButton.setMaximumSize(new Dimension(30, 20));
    returnButton.setMinimumSize(new Dimension(30, 20));
    returnButton.addMouseListener(formListener);
    returnButton.addActionListener(formListener);

    jSeparator3.setOrientation(SwingConstants.VERTICAL);

    refreshButton.setFont(new Font("", 0, 12)); // NOI18N
    refreshButton.setText("");
    refreshButton.setActionCommand("JButton1");
    refreshButton.setBorder(null);
    refreshButton.setBorderPainted(false);
    refreshButton.setContentAreaFilled(false);
    refreshButton.setFocusPainted(false);
    refreshButton.setMaximumSize(new Dimension(30, 20));
    refreshButton.setMinimumSize(new Dimension(30, 20));
    refreshButton.setPreferredSize(new Dimension(30, 20));
    refreshButton.addMouseListener(formListener);
    refreshButton.addActionListener(formListener);

    jSeparator4.setOrientation(SwingConstants.VERTICAL);

    changePasswdButton.setFont(new Font("", 0, 12)); // NOI18N
    changePasswdButton.setText("?");
    changePasswdButton.setActionCommand("JButton1");
    changePasswdButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    changePasswdButton.setBorderPainted(false);
    changePasswdButton.setContentAreaFilled(false);
    changePasswdButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    changePasswdButton.setFocusPainted(false);
    changePasswdButton.setMaximumSize(new Dimension(30, 20));
    changePasswdButton.setMinimumSize(new Dimension(30, 20));
    changePasswdButton.addMouseListener(formListener);
    changePasswdButton.addActionListener(formListener);

    GroupLayout fileButtonPaneLayout = new GroupLayout(fileButtonPane);
    fileButtonPane.setLayout(fileButtonPaneLayout);
    fileButtonPaneLayout.setHorizontalGroup(fileButtonPaneLayout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(fileButtonPaneLayout.createSequentialGroup()
                    .addComponent(uploadFileButton, GroupLayout.PREFERRED_SIZE, 46, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(downloadFileButton, GroupLayout.PREFERRED_SIZE, 46,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(deleteFileButton, GroupLayout.PREFERRED_SIZE, 46, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(renameFileButton, GroupLayout.PREFERRED_SIZE, 57, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(authorizationButton, GroupLayout.PREFERRED_SIZE, 63,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jSeparator1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(addNoteButton, GroupLayout.PREFERRED_SIZE, 63, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(deleteNoteButton, GroupLayout.PREFERRED_SIZE, 63, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jSeparator2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(targetIDField, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(searchUserButton, GroupLayout.PREFERRED_SIZE, 63, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(returnButton, GroupLayout.PREFERRED_SIZE, 63, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jSeparator3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(refreshButton, GroupLayout.PREFERRED_SIZE, 46, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jSeparator4, GroupLayout.PREFERRED_SIZE, 2, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(changePasswdButton,
                            GroupLayout.PREFERRED_SIZE, 63, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(18, Short.MAX_VALUE)));
    fileButtonPaneLayout.setVerticalGroup(fileButtonPaneLayout
            .createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING,
                    fileButtonPaneLayout.createSequentialGroup().addContainerGap().addGroup(fileButtonPaneLayout
                            .createParallelGroup(GroupLayout.Alignment.TRAILING).addComponent(jSeparator4)
                            .addGroup(fileButtonPaneLayout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                                    .addGroup(fileButtonPaneLayout
                                            .createParallelGroup(GroupLayout.Alignment.TRAILING)
                                            .addComponent(changePasswdButton, GroupLayout.PREFERRED_SIZE, 25,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addGroup(fileButtonPaneLayout
                                                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                                                    .addComponent(refreshButton, GroupLayout.PREFERRED_SIZE, 25,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addGroup(fileButtonPaneLayout
                                                            .createParallelGroup(
                                                                    GroupLayout.Alignment.TRAILING, false)
                                                            .addComponent(jSeparator2)
                                                            .addGroup(fileButtonPaneLayout
                                                                    .createParallelGroup(
                                                                            GroupLayout.Alignment.BASELINE)
                                                                    .addComponent(addNoteButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE)
                                                                    .addComponent(deleteNoteButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE))
                                                            .addComponent(jSeparator1)
                                                            .addGroup(fileButtonPaneLayout
                                                                    .createParallelGroup(
                                                                            GroupLayout.Alignment.BASELINE)
                                                                    .addComponent(downloadFileButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE)
                                                                    .addComponent(deleteFileButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE)
                                                                    .addComponent(renameFileButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE)
                                                                    .addComponent(authorizationButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE)
                                                                    .addComponent(uploadFileButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE))
                                                            .addComponent(jSeparator3)
                                                            .addGroup(GroupLayout.Alignment.LEADING,
                                                                    fileButtonPaneLayout.createParallelGroup(
                                                                            GroupLayout.Alignment.BASELINE)
                                                                            .addComponent(targetIDField)
                                                                            .addComponent(searchUserButton,
                                                                                    GroupLayout.PREFERRED_SIZE,
                                                                                    25,
                                                                                    GroupLayout.PREFERRED_SIZE)
                                                                            .addComponent(returnButton,
                                                                                    GroupLayout.PREFERRED_SIZE,
                                                                                    25,
                                                                                    GroupLayout.PREFERRED_SIZE)))))))
                            .addGap(15, 15, 15)));

    fileSplitPane.setBackground(new Color(255, 255, 255));
    fileSplitPane.setDividerLocation(750);
    fileSplitPane.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    fileSplitPane.setMaximumSize(new Dimension(1366, 768));
    fileSplitPane.setPreferredSize(new Dimension(701, 646));

    jSplitPane2.setDividerLocation(400);
    jSplitPane2.setOrientation(JSplitPane.VERTICAL_SPLIT);
    jSplitPane2.setContinuousLayout(true);
    jSplitPane2.setMaximumSize(new Dimension(1366, 768));

    fileInfoScroll.setBackground(new Color(255, 255, 255));
    fileInfoScroll.setFont(new Font("", 0, 12)); // NOI18N
    fileInfoScroll.getViewport().setBackground(Color.WHITE);
    fileInfoScroll.addMouseListener(formListener);

    fileInfoTable.setAutoCreateRowSorter(true);
    fileInfoTable.setFont(new Font("", 0, 12)); // NOI18N
    fileInfoTable.setModel(fileTableModel);
    fileInfoTable.getTableHeader().setFont(new Font("", 0, 12));
    fileInfoTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    fileInfoTable.setRowHeight(20);
    fileInfoTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    fileInfoTable.setShowHorizontalLines(false);
    fileInfoTable.setShowVerticalLines(false);
    fileInfoTable.addMouseListener(formListener);
    fileInfoTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent evt) {
            fileSelectedChanged(evt);
        }
    });
    fileInfoScroll.setViewportView(fileInfoTable);

    jSplitPane2.setTopComponent(fileInfoScroll);

    noteDisplayScroll.setBackground(new Color(255, 255, 255));
    noteDisplayScroll.setFont(new Font("", 0, 12)); // NOI18N
    noteDisplayScroll.getViewport().setBackground(Color.WHITE);
    noteDisplayScroll.addMouseListener(formListener);

    noteTable.setAutoCreateRowSorter(true);
    noteTable.setFont(new Font("", 0, 12)); // NOI18N
    noteTable.setModel(noteTableModel);
    noteTable.getTableHeader().setFont(new Font("", 0, 12));
    noteTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    noteTable.setRowHeight(20);
    noteTable.setShowHorizontalLines(false);
    noteTable.setShowVerticalLines(false);
    noteTable.addMouseListener(formListener);
    noteTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            noteSelectedChanged(evt);
        }
    });
    noteDisplayScroll.setViewportView(noteTable);

    jSplitPane2.setBottomComponent(noteDisplayScroll);

    fileSplitPane.setLeftComponent(jSplitPane2);

    jSplitPane1.setDividerLocation(500);
    jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);

    fileDisplayScroll.setFont(new Font("", 0, 12)); // NOI18N
    fileDisplayScroll.setMinimumSize(new Dimension(30, 30));

    fileContentArea.setEditable(false);
    fileContentArea.setColumns(20);
    fileContentArea.setFont(new Font("", 0, 12)); // NOI18N
    fileContentArea.setRows(5);
    fileContentArea.setToolTipText("");
    fileContentArea
            .setBorder(BorderFactory.createTitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION,
                    TitledBorder.DEFAULT_POSITION, new Font("", 0, 12))); // NOI18N
    fileDisplayScroll.setViewportView(fileContentArea);

    jSplitPane1.setTopComponent(fileDisplayScroll);

    noteInputScroll.setFont(new Font("", 0, 12)); // NOI18N
    noteInputScroll.setMaximumSize(new Dimension(1366, 768));
    noteInputScroll.setMinimumSize(new Dimension(30, 30));

    noteInputArea.setColumns(20);
    noteInputArea.setFont(new Font("", 0, 12)); // NOI18N
    noteInputArea.setRows(5);
    noteInputArea.setToolTipText("");
    noteInputArea
            .setBorder(BorderFactory.createTitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION,
                    TitledBorder.DEFAULT_POSITION, new Font("", 0, 12))); // NOI18N
    noteInputScroll.setViewportView(noteInputArea);

    jSplitPane1.setBottomComponent(noteInputScroll);

    fileSplitPane.setRightComponent(jSplitPane1);

    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
            .createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(fileSplitPane, GroupLayout.DEFAULT_SIZE, 1346, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                            .addComponent(fileButtonPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, Short.MAX_VALUE)))
            .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                    .addComponent(fileButtonPane, GroupLayout.PREFERRED_SIZE, 38, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(fileSplitPane,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
}

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

protected void createUI(final ChartPanel chartPanel, final JPanel optionsPanel, BindingContext bindingContext) {
    roiMaskSelector = new RoiMaskSelector(bindingContext);

    final JPanel extendedOptionsPanel = GridBagUtils.createPanel();
    GridBagConstraints extendedOptionsPanelConstraints = GridBagUtils.createConstraints(
            "insets.left=4,insets.right=2,anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1");
    GridBagUtils.addToPanel(extendedOptionsPanel, new JSeparator(), extendedOptionsPanelConstraints, "gridy=0");
    GridBagUtils.addToPanel(extendedOptionsPanel, roiMaskSelector.createPanel(),
            extendedOptionsPanelConstraints, "gridy=1,insets.left=-4");
    GridBagUtils.addToPanel(extendedOptionsPanel, new JPanel(), extendedOptionsPanelConstraints,
            "gridy=1,insets.left=-4");
    GridBagUtils.addToPanel(extendedOptionsPanel, optionsPanel, extendedOptionsPanelConstraints,
            "insets.left=0,insets.right=0,gridy=2,fill=VERTICAL,fill=HORIZONTAL,weighty=1");
    GridBagUtils.addToPanel(extendedOptionsPanel, new JSeparator(), extendedOptionsPanelConstraints,
            "insets.left=4,insets.right=2,gridy=5,anchor=SOUTHWEST");

    final SimpleScrollPane optionsScrollPane = new SimpleScrollPane(extendedOptionsPanel,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    optionsScrollPane.setBorder(null);//from ww  w. j  a v  a2s.co  m
    optionsScrollPane.getVerticalScrollBar().setUnitIncrement(20);

    final JPanel rightPanel = new JPanel(new BorderLayout());
    rightPanel.add(createTopPanel(), BorderLayout.NORTH);
    rightPanel.add(optionsScrollPane, BorderLayout.CENTER);
    rightPanel.add(createChartBottomPanel(chartPanel), BorderLayout.SOUTH);

    final ImageIcon collapseIcon = UIUtils.loadImageIcon("icons/PanelRight12.png");
    final ImageIcon collapseRolloverIcon = ToolButtonFactory.createRolloverIcon(collapseIcon);
    final ImageIcon expandIcon = UIUtils.loadImageIcon("icons/PanelLeft12.png");
    final ImageIcon expandRolloverIcon = ToolButtonFactory.createRolloverIcon(expandIcon);

    hideAndShowButton = ToolButtonFactory.createButton(collapseIcon, false);
    hideAndShowButton.setToolTipText("Collapse Options Panel");
    hideAndShowButton.setName("switchToChartButton");
    hideAndShowButton.addActionListener(new ActionListener() {

        public boolean rightPanelShown;

        @Override
        public void actionPerformed(ActionEvent e) {
            rightPanel.setVisible(rightPanelShown);
            if (rightPanelShown) {
                hideAndShowButton.setIcon(collapseIcon);
                hideAndShowButton.setRolloverIcon(collapseRolloverIcon);
                hideAndShowButton.setToolTipText("Collapse Options Panel");
            } else {
                hideAndShowButton.setIcon(expandIcon);
                hideAndShowButton.setRolloverIcon(expandRolloverIcon);
                hideAndShowButton.setToolTipText("Expand Options Panel");
            }
            rightPanelShown = !rightPanelShown;
        }
    });

    backgroundPanel = new JPanel(new BorderLayout());
    backgroundPanel.add(chartPanel, BorderLayout.CENTER);
    backgroundPanel.add(rightPanel, BorderLayout.EAST);

    JLayeredPane layeredPane = new JLayeredPane();
    layeredPane.add(backgroundPanel, new Integer(0));
    layeredPane.add(hideAndShowButton, new Integer(1));
    add(layeredPane);
}

From source file:edu.clemson.cs.nestbed.client.gui.NetworkMonitorFrame.java

private final JMenu buildFileMenu() {
    JMenu menu = new JMenu("File");
    JMenuItem video = new JMenuItem("Video");
    JMenuItem close = new JMenuItem("Close");

    video.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            WebCam cam = new WebCam("nestbed.cs.clemson.edu", 9192);
        }//from  w  w w . jav  a  2  s. c o m
    });
    menu.add(video);

    close.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            NetworkMonitorFrame.this.setVisible(false);
        }
    });
    menu.add(new JSeparator());
    menu.add(close);

    return menu;
}

From source file:com.jidesoft.spring.richclient.docking.JideApplicationLifecycleAdvisor.java

@Override
public void onPostStartup() {
    initializeRepaintManager();/*from   w  w  w. j av a 2 s  .c  om*/
    if (devOption == false) {
        JMenuBar menuBar = Application.instance().getActiveWindow().getControl().getJMenuBar();
        for (int i = 0; i < menuBar.getMenuCount(); i++) {
            //TODO:I18N
            if (menuBar.getMenu(i).getText().equals("Admin")) {
                menuBar.getMenu(i).setVisible(false);
            }
        }
    }
    JMenuBar menuBar = Application.instance().getActiveWindow().getControl().getJMenuBar();
    for (int i = 0; i < menuBar.getMenuCount(); i++) {
        // recent games
        //TODO: I18N
        if (menuBar.getMenu(i).getText().equals("Game")) {
            for (int j = 0; j < menuBar.getMenu(i).getItemCount(); j++) {
                if (menuBar.getMenu(i).getItem(j) != null && menuBar.getMenu(i).getItem(j).getText() != null
                        && menuBar.getMenu(i).getItem(j).getText().equals("Recent Games")) {
                    JMenu menu = (JMenu) menuBar.getMenu(i).getItem(j);
                    RecentGames rg = new RecentGames();
                    ArrayList<RecentGames.RecentGameInfo> rgis = rg.getRecentGameInfo();
                    for (RecentGameInfo rgi : rgis) {
                        final RecentGameInfo frgi = rgi;
                        JMenuItem mu = new JMenuItem();
                        mu.setText("Game " + String.valueOf(rgi.getNumber()));
                        mu.addActionListener(new ActionListener() {
                            @Override
                            public void actionPerformed(ActionEvent e) {
                                LoadGame loadGame = new LoadGame(frgi.getFile());
                                loadGame.execute();
                            }
                        });
                        menu.add(mu);
                    }
                }
            }
        }

        // user guide
        //TODO:I18N
        if (menuBar.getMenu(i).getText().equals("Help")) {
            try {
                final File f = new File("JOverseerUserGuide.pdf");
                if (f.exists()) {
                    //TODO:I18N
                    JMenuItem mi = new JMenuItem("User's Guide");
                    mi.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            try {
                                Runtime.getRuntime()
                                        .exec("rundll32 url.dll,FileProtocolHandler " + f.getAbsolutePath());
                            } catch (Exception exc) {
                                // do nothing
                            }
                        }
                    });
                    menuBar.getMenu(i).add(new JSeparator());
                    menuBar.getMenu(i).add(mi);
                }
            } catch (Exception exc) {
                // do nothing
            }
        }

    }

    if (JOverseerJIDEClient.cmdLineArgs != null && JOverseerJIDEClient.cmdLineArgs.length == 1
            && JOverseerJIDEClient.cmdLineArgs[0].endsWith(".jov")) {
        String fname = JOverseerJIDEClient.cmdLineArgs[0];
        File f = new File(fname);
        if (f.exists()) {
            LoadGame lg = new LoadGame(fname);
            lg.loadGame();
        }
    }
}

From source file:edu.synth.SynthHelper.java

private void menu() {
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);//from w  w w. ja v  a  2  s  . c  o  m

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

    mntmOpenWorkspace = new JMenuItem("Open Workspace...");
    mntmOpenWorkspace.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    clear();
                    String path = SyntHelper.getInstance().openDialogFileChooser(state.getWorkspacePath(), true,
                            "Choose Workspace", "Choose", null);
                    try {
                        state.setWorkspacePath(path);
                    } catch (IOException e) {
                        Messager.publish("Set Workspace", e);
                    }
                    initSettings();
                    setValues();
                }
            }).start();
        }
    });
    mnFile.add(mntmOpenWorkspace);

    mntmApplyChanges = new JMenuItem("Save Changes...");
    mntmApplyChanges.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        state.saveSettings();
                    } catch (IOException e) {
                        Messager.publish("Save Settings Files", e);
                    }
                }
            }).start();
        }
    });
    mnFile.add(mntmApplyChanges);

    mntmExportConfFiles = new JMenuItem("Export Settings Files to Workspace...");
    mntmExportConfFiles.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        state.saveSettings();
                    } catch (IOException e) {
                        Messager.publish("Save Settings Files", e);
                    }
                    if (!state.getWorkspacePath().isEmpty())
                        try {
                            state.copySettingsFilesToWorkspace();
                        } catch (IOException e) {
                            Messager.publish("Export Settings Files to Workspace", e);
                        }
                    else
                        Messager.publish("Export Settings Files to Workspace",
                                "Files have not been copied. Workspace has not been selected!");
                }
            }).start();
        }
    });
    mnFile.add(mntmExportConfFiles);

    mnFile.add(new JSeparator());
    mntmExit = new JMenuItem("Exit");
    mntmExit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            System.exit(0);
        }
    });
    mnFile.add(mntmExit);

    mnOperations = new JMenu("Operations");
    menuBar.add(mnOperations);

    mntmViewObs = new JMenuItem("View Observed Data (1.obs)");
    mntmViewObs.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        new DataViewWindow("Observed Data Viewer", new File(Constants.OBS_DATA));
                    } catch (IOException e) {
                        Messager.publish("Observed Data Viewer error", e);
                    }
                }
            }).start();
        }
    });
    mnOperations.add(mntmViewObs);

    mnOperations.add(new JSeparator());

    mntmRunSynth = new JMenuItem("Run Synth");
    mntmRunSynth.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            new Thread(new ExecuteSynthConvThread()).start();
        }
    });
    mnOperations.add(mntmRunSynth);

    mntmRunSynthForObs = new JMenuItem("Run Synth for Observed Data");
    mntmRunSynthForObs.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            final Thread main = new Thread(new ExecuteSynthConvDivThread());
            main.start();
            new Thread(new Runnable() {
                @Override
                public void run() {
                    while (main.isAlive()) {
                    }
                    ;
                    try {
                        new SyntHelperChartWindow("Result of synthesis and dividing");
                    } catch (IOException e) {
                        Messager.publish("Charting result error", e);
                    }
                }
            }).start();
        }
    });
    mnOperations.add(mntmRunSynthForObs);

    mnHelp = new JMenu("Help");
    menuBar.add(mnHelp);

    mntmLogWindow = new JMenuItem("Log Window");
    mntmLogWindow.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            LogPublisher.getInstance().openWindow();
        }
    });
    mnHelp.add(mntmLogWindow);

    mnHelp.add(new JSeparator());

    mntmAbout = new JMenuItem("About SYNTHelper");
    mnHelp.add(mntmAbout);

    mntmHelp = new JMenuItem("Help Content");
    mnHelp.add(mntmHelp);
}

From source file:medsavant.uhn.cancer.UserCommentApp.java

private JSeparator getCommentSeparator() {
    JSeparator js = new JSeparator();
    js.setPreferredSize(new Dimension(panel.getWidth(), COMMENT_SEPARATOR_HEIGHT));
    return js;/*from ww w  .j  a v  a  2 s. c o m*/
}

From source file:org.esa.beam.visat.toolviews.stat.ChartPagePanel.java

protected void createUI(final ChartPanel chartPanel, final JPanel optionsPanel, BindingContext bindingContext) {
    roiMaskSelector = new RoiMaskSelector(bindingContext);

    final JPanel extendedOptionsPanel = GridBagUtils.createPanel();
    GridBagConstraints extendedOptionsPanelConstraints = GridBagUtils.createConstraints(
            "insets.left=4,insets.right=2,anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1");
    GridBagUtils.addToPanel(extendedOptionsPanel, new JSeparator(), extendedOptionsPanelConstraints, "gridy=0");
    GridBagUtils.addToPanel(extendedOptionsPanel, roiMaskSelector.createPanel(),
            extendedOptionsPanelConstraints, "gridy=1,insets.left=-4");
    GridBagUtils.addToPanel(extendedOptionsPanel, optionsPanel, extendedOptionsPanelConstraints,
            "insets.left=0,insets.right=0,gridy=2,fill=VERTICAL,fill=HORIZONTAL,weighty=1");
    GridBagUtils.addToPanel(extendedOptionsPanel, new JSeparator(), extendedOptionsPanelConstraints,
            "insets.left=4,insets.right=2,gridy=5,anchor=SOUTHWEST");

    final JScrollPane optionsScrollPane = new SimpleScrollPane(extendedOptionsPanel,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    optionsScrollPane.setBorder(null);/*from w  w w . j  a v a2  s. c om*/

    final JPanel rightPanel = new JPanel(new BorderLayout());
    rightPanel.add(createTopPanel(), BorderLayout.NORTH);
    rightPanel.add(optionsScrollPane, BorderLayout.CENTER);
    rightPanel.add(createChartBottomPanel(chartPanel), BorderLayout.SOUTH);

    final ImageIcon collapseIcon = UIUtils.loadImageIcon("icons/PanelRight12.png");
    final ImageIcon collapseRolloverIcon = ToolButtonFactory.createRolloverIcon(collapseIcon);
    final ImageIcon expandIcon = UIUtils.loadImageIcon("icons/PanelLeft12.png");
    final ImageIcon expandRolloverIcon = ToolButtonFactory.createRolloverIcon(expandIcon);

    hideAndShowButton = ToolButtonFactory.createButton(collapseIcon, false);
    hideAndShowButton.setToolTipText("Collapse Options Panel");
    hideAndShowButton.setName("switchToChartButton");
    hideAndShowButton.addActionListener(new ActionListener() {

        public boolean rightPanelShown;

        @Override
        public void actionPerformed(ActionEvent e) {
            rightPanel.setVisible(rightPanelShown);
            if (rightPanelShown) {
                hideAndShowButton.setIcon(collapseIcon);
                hideAndShowButton.setRolloverIcon(collapseRolloverIcon);
                hideAndShowButton.setToolTipText("Collapse Options Panel");
            } else {
                hideAndShowButton.setIcon(expandIcon);
                hideAndShowButton.setRolloverIcon(expandRolloverIcon);
                hideAndShowButton.setToolTipText("Expand Options Panel");
            }
            rightPanelShown = !rightPanelShown;
        }
    });

    backgroundPanel = new JPanel(new BorderLayout());
    backgroundPanel.add(chartPanel, BorderLayout.CENTER);
    backgroundPanel.add(rightPanel, BorderLayout.EAST);

    JLayeredPane layeredPane = new JLayeredPane();
    layeredPane.add(backgroundPanel, new Integer(0));
    layeredPane.add(hideAndShowButton, new Integer(1));
    add(layeredPane);
}

From source file:net.sf.jabref.gui.mergeentries.MergeEntries.java

/**
 * Main function for building the merge entry JPanel
 *///from www.j a  va2 s .  c o m
private void initialize() {
    doneBuilding = false;
    setupFields();

    // Fill diff mode combo box
    for (String diffText : DIFF_MODES) {
        diffMode.addItem(diffText);
    }
    diffMode.setSelectedIndex(Math.min(Globals.prefs.getInt(JabRefPreferences.MERGE_ENTRIES_DIFF_MODE),
            diffMode.getItemCount() - 1));
    diffMode.addActionListener(e -> {
        updateTextPanes(differentFields);
        storePreference();
    });

    // Create main layout
    String colSpecMain = "left:pref, 5px, center:3cm:grow, 5px, center:pref, 3px, center:pref, 3px, center:pref, 5px, center:3cm:grow";
    String colSpecMerge = "left:pref, 5px, fill:3cm:grow, 5px, center:pref, 3px, center:pref, 3px, center:pref, 5px, fill:3cm:grow";
    String rowSpec = "pref, pref, 10px, fill:5cm:grow, 10px, pref, 10px, fill:3cm:grow";
    StringBuilder rowBuilder = new StringBuilder("");
    for (int i = 0; i < allFields.size(); i++) {
        rowBuilder.append("pref, 2dlu, ");
    }
    rowBuilder.append("pref");

    JPanel mergePanel = new JPanel();
    FormLayout mainLayout = new FormLayout(colSpecMain, rowSpec);
    FormLayout mergeLayout = new FormLayout(colSpecMerge, rowBuilder.toString());
    mainPanel.setLayout(mainLayout);
    mergePanel.setLayout(mergeLayout);

    CellConstraints cc = new CellConstraints();

    mainPanel.add(boldFontLabel(Localization.lang("Use")), cc.xyw(4, 1, 7, "center, bottom"));
    mainPanel.add(diffMode, cc.xy(11, 1, "right, bottom"));

    // Set headings
    JLabel[] headingLabels = new JLabel[6];
    for (int i = 0; i < 6; i++) {
        headingLabels[i] = boldFontLabel(COLUMN_HEADINGS[i]);
        mainPanel.add(headingLabels[i], cc.xy(1 + (i * 2), 2));

    }

    mainPanel.add(new JSeparator(), cc.xyw(1, 3, 11));

    // Start with entry type
    mergePanel.add(boldFontLabel(Localization.lang("Entry type")), cc.xy(1, 1));

    JTextPane leftTypeDisplay = getStyledTextPane();
    leftTypeDisplay.setText(HTML_START + leftEntry.getType() + HTML_END);
    mergePanel.add(leftTypeDisplay, cc.xy(3, 1));
    if (leftEntry.getType().equals(rightEntry.getType())) {
        identicalTypes = true;
    } else {
        identicalTypes = false;
        ButtonGroup group = new ButtonGroup();
        typeRadioButtons = new ArrayList<>(2);
        for (int k = 0; k < 3; k += 2) {
            JRadioButton button = new JRadioButton();
            typeRadioButtons.add(button);
            group.add(button);
            mergePanel.add(button, cc.xy(5 + (k * 2), 1));
            button.addChangeListener(e -> updateAll());
        }
        typeRadioButtons.get(0).setSelected(true);
    }
    JTextPane rightTypeDisplay = getStyledTextPane();
    rightTypeDisplay.setText(HTML_START + rightEntry.getType() + HTML_END);
    mergePanel.add(rightTypeDisplay, cc.xy(11, 1));

    // For all fields in joint add a row and possibly radio buttons
    int row = 2;
    int maxLabelWidth = -1;
    for (String field : allFields) {
        JLabel label = boldFontLabel(new SentenceCaseFormatter().format(field));
        mergePanel.add(label, cc.xy(1, (2 * row) - 1, "left, top"));
        Optional<String> leftString = leftEntry.getFieldOptional(field);
        Optional<String> rightString = rightEntry.getFieldOptional(field);
        if (leftString.equals(rightString)) {
            identicalFields.add(field);
        } else {
            differentFields.add(field);
        }

        maxLabelWidth = Math.max(maxLabelWidth, label.getPreferredSize().width);

        // Left text pane
        if (leftString.isPresent()) {
            JTextPane tf = getStyledTextPane();
            mergePanel.add(tf, cc.xy(3, (2 * row) - 1, "f, f"));
            leftTextPanes.put(field, tf);
        }

        // Add radio buttons if the two entries do not have identical fields
        if (identicalFields.contains(field)) {
            mergedEntry.setField(field, leftString.get()); // Will only happen if both entries have the field and the content is identical
        } else {
            ButtonGroup group = new ButtonGroup();
            List<JRadioButton> list = new ArrayList<>(3);
            for (int k = 0; k < 3; k++) {
                JRadioButton button = new JRadioButton();
                group.add(button);
                mergePanel.add(button, cc.xy(5 + (k * 2), (2 * row) - 1));
                button.addChangeListener(e -> updateAll());
                list.add(button);
            }
            radioButtons.put(field, list);
            if (leftString.isPresent()) {
                list.get(0).setSelected(true);
                if (!rightString.isPresent()) {
                    list.get(2).setEnabled(false);
                }
            } else {
                list.get(0).setEnabled(false);
                list.get(2).setSelected(true);
            }
        }

        // Right text pane
        if (rightString.isPresent()) {
            JTextPane tf = getStyledTextPane();
            mergePanel.add(tf, cc.xy(11, (2 * row) - 1, "f, f"));
            rightTextPanes.put(field, tf);
        }
        row++;
    }

    scrollPane = new JScrollPane(mergePanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    updateTextPanes(allFields);
    mainPanel.add(scrollPane, cc.xyw(1, 4, 11));
    mainPanel.add(new JSeparator(), cc.xyw(1, 5, 11));

    // Synchronize column widths
    String[] rbAlign = { "right", "center", "left" };
    mainLayout.setColumnSpec(1, ColumnSpec.decode(Integer.toString(maxLabelWidth) + "px"));
    Integer maxRBWidth = -1;
    for (int k = 2; k < 5; k++) {
        maxRBWidth = Math.max(maxRBWidth, headingLabels[k].getPreferredSize().width);
    }
    for (int k = 0; k < 3; k++) {
        mergeLayout.setColumnSpec(5 + (k * 2), ColumnSpec.decode(rbAlign[k] + ":" + maxRBWidth + "px"));
    }

    // Setup a PreviewPanel and a Bibtex source box for the merged entry
    mainPanel.add(boldFontLabel(Localization.lang("Merged entry")), cc.xyw(1, 6, 6));

    entryPreview = new PreviewPanel(null, mergedEntry, null, Globals.prefs.get(JabRefPreferences.PREVIEW_0));
    mainPanel.add(entryPreview, cc.xyw(1, 8, 6));

    mainPanel.add(boldFontLabel(Localization.lang("Merged BibTeX source code")), cc.xyw(8, 6, 4));

    sourceView = new JTextArea();
    sourceView.setLineWrap(true);
    sourceView.setFont(new Font("Monospaced", Font.PLAIN, Globals.prefs.getInt(JabRefPreferences.FONT_SIZE)));
    mainPanel.add(new JScrollPane(sourceView), cc.xyw(8, 8, 4));
    sourceView.setEditable(false);

    // Add some margin around the layout
    mainLayout.appendRow(RowSpec.decode(MARGIN));
    mainLayout.appendColumn(ColumnSpec.decode(MARGIN));
    mainLayout.insertRow(1, RowSpec.decode(MARGIN));
    mainLayout.insertColumn(1, ColumnSpec.decode(MARGIN));

    // Everything done, allow any action to actually update the merged entry
    doneBuilding = true;

    updateAll();

    // Show what we've got
    mainPanel.setVisible(true);
    javax.swing.SwingUtilities.invokeLater(() -> scrollPane.getVerticalScrollBar().setValue(0));
}

From source file:uk.co.markfrimston.tasktree.Main.java

public Main(TaskTree taskTree) {
    super();/*from w  w  w .  j  a  v a 2  s  .  co m*/

    this.taskTree = taskTree;

    this.setTitle("Task Tree");
    this.setSize(new Dimension(300, 500));
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel quickInPanel = new JPanel(new BorderLayout());
    this.quickIn = new JTextArea();
    this.quickIn.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent arg0) {
            if (arg0.getKeyCode() == KeyEvent.VK_ENTER) {
                String newText = quickIn.getText().trim();
                if (newText != null && newText.length() > 0) {
                    addTask(Main.this.taskTree.getRoot(), 0, newText, true);
                    try {
                        Main.this.taskTree.changesMade();
                    } catch (Exception e) {
                        error(e.getMessage());
                    }
                }
                quickIn.setText("");
            }
        }
    });
    this.quickIn.setPreferredSize(new Dimension(300, 75));
    this.quickIn.setBorder(BorderFactory.createTitledBorder("Quick Input"));
    quickInPanel.add(this.quickIn, BorderLayout.CENTER);
    this.syncButton = new JButton("Sync");
    this.syncButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new SyncThread(Main.this).start();
        }
    });
    quickInPanel.add(this.syncButton, BorderLayout.EAST);
    this.getContentPane().add(quickInPanel, BorderLayout.NORTH);

    this.tree = new JTree(taskTree.getTreeModel());
    DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer() {
        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
                boolean expanded, boolean leaf, int row, boolean hasFocus) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
            Object newVal = htmlFilter(String.valueOf(node.getUserObject()));
            if (node.getChildCount() > 0 && !tree.isExpanded(new TreePath(node.getPath()))) {
                DefaultMutableTreeNode firstLeaf = (DefaultMutableTreeNode) node.getFirstLeaf();
                newVal = htmlFilter(String.valueOf(node.getUserObject()))
                        + " <span style='color:silver;font-style:italic'>" + "("
                        + String.valueOf(firstLeaf.getUserObject()) + ")</span>";
            }
            newVal = "<html>" + newVal + "</html>";

            return super.getTreeCellRendererComponent(tree, newVal, selected, expanded, leaf, row, hasFocus);
        }
    };
    ImageIcon bulletIcon = new ImageIcon(Main.class.getResource("bullet.gif"));
    renderer.setLeafIcon(bulletIcon);
    renderer.setOpenIcon(bulletIcon);
    renderer.setClosedIcon(bulletIcon);
    renderer.setBorder(BorderFactory.createEmptyBorder(4, 0, 4, 0));
    this.tree.setCellRenderer(renderer);
    this.tree.setRootVisible(false);
    this.tree.setShowsRootHandles(true);
    this.tree.addMouseListener(new MouseAdapter() {
        protected void doSelectRow(MouseEvent arg0) {
            int row = tree.getRowForLocation(arg0.getX(), arg0.getY());
            if (row != -1) {
                tree.setSelectionRow(row);
                if (arg0.isPopupTrigger()) {
                    popup.show(tree, arg0.getX(), arg0.getY());
                }
            }
        }

        public void mousePressed(MouseEvent arg0) {
            doSelectRow(arg0);
        }

        public void mouseReleased(MouseEvent arg0) {
            doSelectRow(arg0);
        }
    });
    JScrollPane treeScroll = new JScrollPane(tree);
    treeScroll.setBorder(BorderFactory.createTitledBorder("Task List"));
    this.getContentPane().add(treeScroll, BorderLayout.CENTER);

    this.popup = new JPopupMenu();
    JMenuItem addBefore = new JMenuItem("Add Before");
    addBefore.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode selected = getSelectedNode();
            DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selected.getParent();
            int pos = parent.getIndex(selected);
            promptAndInsert(parent, pos);
            try {
                Main.this.taskTree.changesMade();
            } catch (Exception ex) {
                error(ex.getMessage());
            }
        }
    });
    this.popup.add(addBefore);
    JMenuItem addAfter = new JMenuItem("Add After");
    addAfter.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode selected = getSelectedNode();
            DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selected.getParent();
            int pos = parent.getIndex(selected) + 1;
            promptAndInsert(parent, pos);
            try {
                Main.this.taskTree.changesMade();
            } catch (Exception ex) {
                error(ex.getMessage());
            }
        }
    });
    this.popup.add(addAfter);
    JMenuItem addNested = new JMenuItem("Add Nested");
    addNested.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode selected = getSelectedNode();
            int pos = selected.getChildCount();
            promptAndInsert(selected, pos);
            try {
                Main.this.taskTree.changesMade();
            } catch (Exception ex) {
                ex.getMessage();
            }
        }
    });
    this.popup.add(addNested);
    this.popup.add(new JSeparator());
    JMenuItem moveTop = new JMenuItem("Move to Top");
    moveTop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode selected = getSelectedNode();
            DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selected.getParent();
            moveTask(selected, parent, 0);
            try {
                Main.this.taskTree.changesMade();
            } catch (Exception ex) {
                error(ex.getMessage());
            }
        }
    });
    this.popup.add(moveTop);
    JMenuItem moveUp = new JMenuItem("Move Up");
    moveUp.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode selected = getSelectedNode();
            DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selected.getParent();
            int pos = Math.max(parent.getIndex(selected) - 1, 0);
            moveTask(selected, parent, pos);
            try {
                Main.this.taskTree.changesMade();
            } catch (Exception ex) {
                error(ex.getMessage());
            }
        }
    });
    this.popup.add(moveUp);
    JMenuItem moveDown = new JMenuItem("Move Down");
    moveDown.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode selected = getSelectedNode();
            DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selected.getParent();
            int pos = Math.min(parent.getIndex(selected) + 1, parent.getChildCount() - 1);
            moveTask(selected, parent, pos);
            try {
                Main.this.taskTree.changesMade();
            } catch (Exception ex) {
                error(ex.getMessage());
            }
        }
    });
    this.popup.add(moveDown);
    JMenuItem moveBottom = new JMenuItem("Move to Bottom");
    moveBottom.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode selected = getSelectedNode();
            DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selected.getParent();
            moveTask(selected, parent, parent.getChildCount() - 1);
            try {
                Main.this.taskTree.changesMade();
            } catch (Exception ex) {
                error(ex.getMessage());
            }
        }
    });
    this.popup.add(moveBottom);
    this.popup.add(new JSeparator());
    JMenuItem rename = new JMenuItem("Edit");
    rename.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode selected = getSelectedNode();
            String newText = prompt((String) selected.getUserObject());
            if (newText != null && newText.length() > 0) {
                selected.setUserObject(newText);
                Main.this.taskTree.getTreeModel().reload(selected);
                try {
                    Main.this.taskTree.changesMade();
                } catch (Exception ex) {
                    error(ex.getMessage());
                }
            }
        }
    });
    this.popup.add(rename);
    JMenuItem delete = new JMenuItem("Delete");
    delete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            promptAndRemove(getSelectedNode());
            try {
                Main.this.taskTree.changesMade();
            } catch (Exception ex) {
                error(ex.getMessage());
            }
        }
    });
    this.popup.add(delete);

    this.setVisible(true);

    loadConfig();
    load();

    syncButton.setVisible(this.taskTree.hasSyncCapability());
}

From source file:medsavant.uhn.cancer.UserCommentApp.java

private JSeparator getOntologySeparator() {
    JSeparator js = new JSeparator();
    js.setPreferredSize(new Dimension(panel.getWidth(), ONTOLOGY_SEPARATOR_HEIGHT));
    return js;//from  www.j ava2s  .c om
}