Example usage for javax.swing JToolBar JToolBar

List of usage examples for javax.swing JToolBar JToolBar

Introduction

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

Prototype

public JToolBar() 

Source Link

Document

Creates a new tool bar; orientation defaults to HORIZONTAL.

Usage

From source file:com.emental.mindraider.ui.outline.OutlineArchiveJPanel.java

public OutlineArchiveJPanel() {
    setLayout(new BorderLayout());

    // table with archived concepts (title)
    // let table model to load discarded concepts itself
    tableModel = new ArchiveTableModel(this);
    table = new JTable(tableModel);
    table.setAutoCreateRowSorter(true);//w w  w  .  j ava 2 s  .c o m
    JScrollPane scroll = new JScrollPane(table);
    table.setFillsViewportHeight(true);
    table.setShowHorizontalLines(false);
    table.setShowVerticalLines(false);
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    JToolBar toolbar = new JToolBar();

    undoButton = new JButton("", IconsRegistry.getImageIcon("trashUndo.png"));
    undoButton.setEnabled(false);
    undoButton.setToolTipText("Restore Note");
    undoButton.addActionListener(new UndiscardConceptActionListener(tableModel, table));
    toolbar.add(undoButton);

    deleteButton = new JButton("", IconsRegistry.getImageIcon("explorerDeleteSmall.png"));
    deleteButton.setEnabled(true);
    deleteButton.setToolTipText("Delete Note");
    deleteButton.addActionListener(new DeleteConceptActionListener(tableModel, table));
    toolbar.add(deleteButton);

    purgeButton = new JButton("", IconsRegistry.getImageIcon("trashFull.png"));
    purgeButton.setEnabled(true);
    purgeButton.setToolTipText("Empty Notes Archive");
    purgeButton.addActionListener(new EmptyArchiveActionListener());
    toolbar.add(purgeButton);

    add(toolbar, BorderLayout.NORTH);

    add(scroll, BorderLayout.CENTER);
}

From source file:Main.java

protected JToolBar createToolBar() {
    JToolBar bar = new JToolBar();

    // Add simple actions for opening & saving.
    bar.add(getOpenAction()).setText("");
    bar.add(getSaveAction()).setText("");
    bar.addSeparator();/*from ww  w.  ja va  2  s  .  c o  m*/

    // Add cut/copy/paste buttons.
    bar.add(textComp.getActionMap().get(DefaultEditorKit.cutAction)).setText("");
    bar.add(textComp.getActionMap().get(DefaultEditorKit.copyAction)).setText("");
    bar.add(textComp.getActionMap().get(DefaultEditorKit.pasteAction)).setText("");
    return bar;
}

From source file:org.jax.bham.test.PhenotypeEffectPlotPanel.java

/**
 * Constructor//from  w ww.ja va2s. c  om
 * @param phenotypeDataSource
 *          the phenotype data source
 * @param strainGroups
 *          the strain groupings
 */
public PhenotypeEffectPlotPanel(PhenotypeDataSource phenotypeDataSource,
        Map<String, ? extends Collection<String>> strainGroups) {
    super(new BorderLayout());

    this.chartPanel = new ChartPanel(null, true);
    this.showIndividualStrainEffectsCheckBox = new JCheckBox("Show Individual Strain Effects", false);
    this.phenotypeDataSource = phenotypeDataSource;
    this.phenotypeData = phenotypeDataSource.getPhenotypeData();
    this.strainGroups = strainGroups;

    this.updateChart();

    JToolBar toolBar = new JToolBar();
    toolBar.add(this.showIndividualStrainEffectsCheckBox);
    this.showIndividualStrainEffectsCheckBox.addItemListener(new ItemListener() {
        /**
         * {@inheritDoc}
         */
        public void itemStateChanged(ItemEvent e) {
            PhenotypeEffectPlotPanel.this.updateChart();
        }
    });

    this.add(toolBar, BorderLayout.PAGE_START);
    this.add(this.chartPanel, BorderLayout.CENTER);
}

From source file:edu.ucla.stat.SOCR.analyses.gui.KolmogorovSmirnoff.java

/**Initialize the Analysis*/
public void init() {
    showSelect = false;//from  ww  w .  ja  v a  2 s.co  m
    showVisualize = false;
    showInput = false;
    super.init();
    analysisType = AnalysisType.KOLMOGOROV_SMIRNOFF;
    useInputExample = false;
    useLocalExample = false;
    useRandomExample = true;
    useServerExample = false;
    useStaticExample = KolmogorovSmirnoffExamples.availableExamples;
    depMax = 1; // max number of dependent var
    indMax = 1; // max number of independent var
    resultPanelTextArea.setFont(new Font(outputFontFace, Font.BOLD, outputFontSize));
    frame = getFrame(this);
    setName("Regression & Correlation Analysis");
    // Create the toolBar
    toolBar = new JToolBar();
    createActionComponents(toolBar);
    this.getContentPane().add(toolBar, BorderLayout.NORTH);
    depLabel.setText(VARIABLE_1);
    indLabel.setText(VARIABLE_2);
    validate();
    reset();
}

From source file:ToolbarDemo.java

protected JMenuBar createMenuBar() {
    final JMenuBar menuBar = new JMenuBar();

    JMenu mFile = new JMenu("File");
    mFile.setMnemonic('f');

    ImageIcon iconNew = new ImageIcon("file_new.gif");
    Action actionNew = new AbstractAction("New", iconNew) {
        public void actionPerformed(ActionEvent e) {
            System.out.println("new action");
        }// w ww  .jav  a  2  s.c  o  m
    };
    JMenuItem item = mFile.add(actionNew);
    mFile.add(item);

    ImageIcon iconOpen = new ImageIcon("file_open.gif");
    Action actionOpen = new AbstractAction("Open...", iconOpen) {
        public void actionPerformed(ActionEvent e) {
            System.out.println("open action");
        }
    };
    item = mFile.add(actionOpen);
    mFile.add(item);

    ImageIcon iconSave = new ImageIcon("file_save.gif");
    Action actionSave = new AbstractAction("Save...", iconSave) {
        public void actionPerformed(ActionEvent e) {
            System.out.println("save action");
        }
    };
    item = mFile.add(actionSave);
    mFile.add(item);

    mFile.addSeparator();

    Action actionExit = new AbstractAction("Exit") {
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    };
    item = mFile.add(actionExit);
    item.setMnemonic('x');
    menuBar.add(mFile);

    toolBar = new JToolBar();
    JButton btn1 = toolBar.add(actionNew);
    btn1.setToolTipText("New text");
    JButton btn2 = toolBar.add(actionOpen);
    btn2.setToolTipText("Open text file");
    JButton btn3 = toolBar.add(actionSave);
    btn3.setToolTipText("Save text file");

    ActionListener fontListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateMonitor();
        }
    };

    JMenu mFont = new JMenu("Font");
    mFont.setMnemonic('o');

    ButtonGroup group = new ButtonGroup();
    fontMenus = new JMenuItem[FontNames.length];
    for (int k = 0; k < FontNames.length; k++) {
        int m = k + 1;
        fontMenus[k] = new JRadioButtonMenuItem(m + " " + FontNames[k]);
        boolean selected = (k == 0);
        fontMenus[k].setSelected(selected);
        fontMenus[k].setMnemonic('1' + k);
        fontMenus[k].setFont(fonts[k]);
        fontMenus[k].addActionListener(fontListener);
        group.add(fontMenus[k]);
        mFont.add(fontMenus[k]);
    }

    mFont.addSeparator();

    boldMenu.setMnemonic('b');
    Font fn = fonts[1].deriveFont(Font.BOLD);
    boldMenu.setFont(fn);
    boldMenu.setSelected(false);
    boldMenu.addActionListener(fontListener);
    mFont.add(boldMenu);

    italicMenu.setMnemonic('i');
    fn = fonts[1].deriveFont(Font.ITALIC);
    italicMenu.setFont(fn);
    italicMenu.setSelected(false);
    italicMenu.addActionListener(fontListener);
    mFont.add(italicMenu);

    menuBar.add(mFont);

    getContentPane().add(toolBar, BorderLayout.NORTH);

    return menuBar;
}

From source file:com.pl.plugins.commons.ui.views.impl.SimpleDictionaryToolBar.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Vlad Kimo
    jtbToolBar = new JToolBar();
    jbNew = new JButton();
    jbEdit = new JButton();
    jbDelete = new JButton();
    jbRefresh = new JButton();
    jbFind = new JButton();

    //======== jtbToolBar ========
    {/*from w ww.ja  va 2s  . c o  m*/
        jtbToolBar.setFloatable(false);

        //---- jbNew ----
        jbNew.setText("New");
        jbNew.setIcon(new ImageIcon(
                getClass().getResource("/com/pl/plugins/commons/ui/views/impl/document_new.png")));
        jtbToolBar.add(jbNew);
        jtbToolBar.addSeparator();

        //---- jbEdit ----
        jbEdit.setText("Edit");
        jbEdit.setIcon(new ImageIcon(
                getClass().getResource("/com/pl/plugins/commons/ui/views/impl/document_edit.png")));
        jtbToolBar.add(jbEdit);
        jtbToolBar.addSeparator();

        //---- jbDelete ----
        jbDelete.setText("Delete");
        jbDelete.setIcon(new ImageIcon(
                getClass().getResource("/com/pl/plugins/commons/ui/views/impl/document_delete.png")));
        jtbToolBar.add(jbDelete);
        jtbToolBar.addSeparator();

        //---- jbRefresh ----
        jbRefresh.setText("Refresh");
        jbRefresh.setIcon(new ImageIcon(
                getClass().getResource("/com/pl/plugins/commons/ui/views/impl/document_refresh.png")));
        jtbToolBar.add(jbRefresh);
        jtbToolBar.addSeparator();

        //---- jbFind ----
        jbFind.setText("Find");
        jbFind.setIcon(new ImageIcon(
                getClass().getResource("/com/pl/plugins/commons/ui/views/impl/document_find.png")));
        jtbToolBar.add(jbFind);
    }
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:edu.ucla.stat.SOCR.chart.demo.PowerTransformQQNormalPlotChart.java

public void init() {

    sliderPanel = new JPanel();
    powerSlider = new FloatSlider("Power", 1.0, -10.0, 10.0);
    powerSlider.setPreferredSize(new Dimension(CHART_SIZE_X / 2 + 150, 80));
    powerSlider.addObserver(this);
    powerSlider.setToolTipText("Slider for adjusting the value of power.");
    sliderPanel.add(this.powerSlider);

    super.init();
    depLabel.setText("Data"); // Y

    toolBar = new JToolBar();
    createActionComponents(toolBar);/*  w  ww .ja  v a 2 s .c  o  m*/
    JPanel toolBarContainer = new JPanel();
    toolBarContainer.add(toolBar);

    JSplitPane toolContainer = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolBarContainer,
            new JScrollPane(sliderPanel));
    toolContainer.setContinuousLayout(true);
    toolContainer.setDividerLocation(0.6);
    this.getContentPane().add(toolContainer, BorderLayout.NORTH);
}

From source file:mulavito.samples.GraphAlgorithmDemo.java

public GraphAlgorithmDemo() {
    super("MuLaViTo Algorithms Demo");

    // Set the frame icon.
    ImageIcon icon = Resources.getIconByName("/img/mulavito-logo.png");
    if (icon != null)
        setIconImage(icon.getImage());//from w  ww.  ja v  a 2  s  .  c  o  m

    // Create toolbar.
    JToolBar toolbar = new JToolBar();
    getToolBarPane().add(toolbar);

    JButton btn;

    btn = new JButton("New Graph");
    btn.setActionCommand("graph");
    btn.addActionListener(this);
    toolbar.add(btn);

    btn = new JButton("Auto Size");
    btn.setActionCommand("autosize");
    btn.addActionListener(this);
    toolbar.add(btn);

    btn = new JButton("Eppstein");
    btn.setActionCommand("eppstein");
    btn.addActionListener(this);
    toolbar.add(btn);

    btn = new JButton("Yen");
    btn.setActionCommand("yen");
    btn.addActionListener(this);
    toolbar.add(btn);

    btn = new JButton("Suurballe-Tarjan");
    btn.setActionCommand("suurballe-tarjan");
    btn.addActionListener(this);
    toolbar.add(btn);

    btn = new JButton("About");
    btn.setActionCommand("about");
    btn.addActionListener(this);
    toolbar.add(btn);

    normalOutput("Welcome to MuLaViTo demonstrator.\n");
    debugOutput("Click on \"New Graph\" to create a new graph.\n");
    warnOutput("Click Eppstein, Yen, or Suurballe-Tarjan to randomly "
            + "select source and destination and run the algorithm\n");
    notifyOutput("Have fun!!!\n");

    setPreferredSize(new Dimension(500, 600));
    setMinimumSize(new Dimension(500, 600));
    setVisible(true);
}

From source file:com.petersoft.advancedswing.enhancedtextarea.EnhancedTextArea.java

private void initGUI() {
    try {//from   ww  w .j a v a2 s  . co m
        BorderLayout thisLayout = new BorderLayout();
        this.setLayout(thisLayout);
        this.setPreferredSize(new java.awt.Dimension(725, 290));
        {
            jToolBar = new JToolBar();
            this.add(jToolBar, BorderLayout.NORTH);
            {
                jSaveButton = new JButton();
                jToolBar.add(jSaveButton);
                jSaveButton.setText("Save");
                jSaveButton.setIcon(new ImageIcon(getClass().getClassLoader()
                        .getResource("com/petersoft/advancedswing/enhancedtextarea/disk.png")));
                jSaveButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jSaveButtonActionPerformed(evt);
                    }
                });
            }
            {
                jLineWrapButton = new JToggleButton();
                jToolBar.add(jLineWrapButton);
                jLineWrapButton.setText("Wrap");
                jLineWrapButton.setIcon(new ImageIcon(getClass().getClassLoader()
                        .getResource("com/petersoft/advancedswing/enhancedtextarea/linewrap.png")));
                jLineWrapButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jLineWrapButtonActionPerformed(evt);
                    }
                });
            }
            {
                jFontBiggerButton = new JButton();
                jToolBar.add(jFontBiggerButton);
                jFontBiggerButton.setIcon(new ImageIcon(getClass().getClassLoader()
                        .getResource("com/petersoft/advancedswing/enhancedtextarea/font_add.png")));
                jFontBiggerButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jFontBiggerButtonActionPerformed(evt);
                    }
                });
            }
            {
                jFontSmallerButton = new JButton();
                jToolBar.add(jFontSmallerButton);
                jFontSmallerButton.setIcon(new ImageIcon(getClass().getClassLoader()
                        .getResource("com/petersoft/advancedswing/enhancedtextarea/font_delete.png")));
                jFontSmallerButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jFontSmallerButtonActionPerformed(evt);
                    }
                });
            }
            {
                jLabel1 = new JLabel();
                jToolBar.add(jLabel1);
                jLabel1.setText(" ");
            }
            {
                jSearchTextField = new JSearchTextField();
                jToolBar.add(jSearchTextField);
                jSearchTextField.setMaximumSize(new java.awt.Dimension(100, 22));
                jSearchTextField.setPreferredSize(new java.awt.Dimension(100, 22));
                jSearchTextField.setSize(new java.awt.Dimension(100, 22));
                jSearchTextField.addKeyListener(new KeyAdapter() {
                    public void keyReleased(KeyEvent evt) {
                        jSearchTextFieldKeyReleased(evt);
                    }
                });

            }
            {
                jSeparatorLabel = new JLabel();
                jToolBar.add(jSeparatorLabel);
                jSeparatorLabel.setText(" ");
            }
            {
                GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
                Font[] fonts = e.getAllFonts();
                String fontNames[] = new String[fonts.length];
                int x = 0;
                for (Font f : fonts) {
                    fontNames[x++] = f.getFontName();
                }
                ComboBoxModel jFontComboBoxModel = new DefaultComboBoxModel(fontNames);
                jFontComboBox = new JComboBox();
                jToolBar.add(jFontComboBox);
                jFontComboBox.setModel(jFontComboBoxModel);
                jFontComboBox.setMaximumSize(new java.awt.Dimension(180, 22));
                jFontComboBox.setPreferredSize(new java.awt.Dimension(180, 22));
                jFontComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jFontComboBoxActionPerformed(evt);
                    }
                });
            }
            {
                pager = new Pager();
                jToolBar.add(pager);
                pager.setVisible(false);
            }
        }
        {
            jScrollPane1 = new JScrollPane();
            this.add(jScrollPane1, BorderLayout.CENTER);
            {
                jTextArea = new JTextArea();
                jTextArea.getDocument().addDocumentListener(this);
                lines = new JTextArea(" 1 ");
                lines.setBackground(new Color(200, 230, 245));
                lines.setEditable(false);
                jScrollPane1.setRowHeaderView(lines);

                jTextArea.getDocument().addDocumentListener(new DocumentListener() {
                    public String getText() {
                        int caretPosition = jTextArea.getDocument().getLength();
                        Element root = jTextArea.getDocument().getDefaultRootElement();

                        int base = 0;
                        if (separateByLine == false) {
                            if (str != null) {
                                base = StringUtils.countMatches(
                                        str.substring(0, (pager.getPage() - 1) * pageSize),
                                        System.getProperty("line.separator"));
                                if (base == 1) {
                                    base = 0;
                                }
                            }
                        } else {
                            base = (pager.getPage() - 1) * pageSize;
                        }
                        base += lineNoBase;
                        String text = " " + (base + 1) + " " + System.getProperty("line.separator");
                        for (int i = 2; i < root.getElementIndex(caretPosition) + 2; i++) {
                            text += " " + (base + i) + " " + System.getProperty("line.separator");
                        }
                        return text;
                    }

                    @Override
                    public void changedUpdate(DocumentEvent de) {
                        lines.setText(getText());
                    }

                    @Override
                    public void insertUpdate(DocumentEvent de) {
                        lines.setText(getText());
                    }

                    @Override
                    public void removeUpdate(DocumentEvent de) {
                        lines.setText(getText());
                    }

                });
                jScrollPane1.setViewportView(jTextArea);
            }
        }
        {
            jStatusPanel = new JPanel();
            FlowLayout jStatusPanelLayout = new FlowLayout();
            jStatusPanelLayout.setAlignment(FlowLayout.LEFT);
            jStatusPanel.setLayout(jStatusPanelLayout);
            this.add(jStatusPanel, BorderLayout.SOUTH);
            {
                jStatusLabel = new JLabel();
                jStatusPanel.add(jStatusLabel);
            }
            {
                jSearchLabel = new JLabel();
                jStatusPanel.add(jSearchLabel);
            }
        }
        this.jFontComboBox.setSelectedItem(jTextArea.getFont().getFamily() + ".plain");
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:ScribbleDragAndDrop.java

/**
 * The main method. Creates a simple application using this class. Note the
 * buttons for switching between draw mode and drag mode.
 *///w  w w. j av  a 2  s . co  m
public static void main(String[] args) {
    // Create a frame and put a scribble pane in it
    JFrame frame = new JFrame("ScribbleDragAndDrop");
    final ScribbleDragAndDrop scribblePane = new ScribbleDragAndDrop();
    frame.getContentPane().add(scribblePane, BorderLayout.CENTER);

    // Create two buttons for switching modes
    JToolBar toolbar = new JToolBar();
    ButtonGroup group = new ButtonGroup();
    JToggleButton draw = new JToggleButton("Draw");
    JToggleButton drag = new JToggleButton("Drag");
    draw.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scribblePane.setDragMode(false);
        }
    });
    drag.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scribblePane.setDragMode(true);
        }
    });
    group.add(draw);
    group.add(drag);
    toolbar.add(draw);
    toolbar.add(drag);
    frame.getContentPane().add(toolbar, BorderLayout.NORTH);

    // Start off in drawing mode
    draw.setSelected(true);
    scribblePane.setDragMode(false);

    // Pop up the window
    frame.setSize(400, 400);
    frame.setVisible(true);
}