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:net.sf.jhylafax.addressbook.AddressBook.java

private void initializeToolBar() {
    mainToolBar = new JToolBar();
    //mainToolBar.setBorderPainted(false);
    //mainToolBar.setRollover(true);
    getContentPane().add(mainToolBar, BorderLayout.NORTH);

    mainToolBar.add(Builder.createToolBarButton(newAction));
    mainToolBar.addSeparator();//from   w  ww.  j  a va2 s  .  c  o  m
    mainToolBar.add(Builder.createToolBarButton(editAction));
    mainToolBar.add(Builder.createToolBarButton(deleteAction));
}

From source file:com.intuit.tank.proxy.ProxyApp.java

private JToolBar createToolBar() {
    JToolBar ret = new JToolBar();
    // ret.setBackground(new Color(111,167,209));

    ret.add(Box.createHorizontalStrut(5));
    ret.add(createButton(openAction));// w w  w  . j  a  v a  2 s. c om
    ret.add(Box.createHorizontalStrut(5));
    ret.add(createButton(saveAction));

    ret.addSeparator();

    ret.add(Box.createHorizontalStrut(5));
    ret.add(createButton(startAction));
    ret.add(Box.createHorizontalStrut(5));
    ret.add(createButton(stopAction));
    ret.add(Box.createHorizontalStrut(5));
    ret.add(createButton(pauseAction));
    ret.add(Box.createHorizontalStrut(5));

    ret.addSeparator();

    ret.add(Box.createHorizontalStrut(5));
    ret.add(createButton(filterAction));
    ret.add(createButton(settingsAction));
    ret.addSeparator();

    ret.add(Box.createHorizontalStrut(5));
    ret.add(createButton(showHostsAction));

    ret.add(Box.createHorizontalGlue());

    return ret;
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.AnnotationReportApplet.java

private JToolBar createToolBar() {

    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);//w w w. j a  va 2 s  .c  om

    toolbar.add(theActionManager.get("print"));

    toolbar.addSeparator();

    toolbar.add(theActionManager.get("undo"));
    toolbar.add(theActionManager.get("redo"));

    toolbar.addSeparator();

    toolbar.add(theActionManager.get("cut"));
    toolbar.add(theActionManager.get("copy"));
    toolbar.add(theActionManager.get("delete"));
    toolbar.add(theActionManager.get("screenshot"));

    toolbar.addSeparator();

    toolbar.add(theActionManager.get("enlarge"));
    toolbar.add(theActionManager.get("resetsize"));
    toolbar.add(theActionManager.get("shrink"));

    toolbar.addSeparator();

    toolbar.add(theActionManager.get("zoomnone"));
    toolbar.add(theActionManager.get("zoomin"));
    toolbar.add(theActionManager.get("zoomout"));

    toolbar.addSeparator();

    toolbar.add(theActionManager.get("orientation"));

    return toolbar;
}

From source file:com.mgmtp.perfload.loadprofiles.ui.AppFrame.java

/**
 * Mostly created by Eclipse WindowBuilder
 *//*from   w  w w.  j  a v  a 2  s  .c o m*/
private void initComponents() {
    setTitle("perfLoad - Load Profile Configurator");
    setSize(1032, 984);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    SwingUtils.setUIFontStyle(Font.PLAIN);
    {
        JMenuBar menuBar = new JMenuBar();
        menuBar.setName("menuBar");
        setJMenuBar(menuBar);
        initMenuBar(menuBar);
    }

    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(new MigLayout("insets 0", "[grow][]", "[25px][400][grow]"));
    {
        JToolBar toolBar = new JToolBar() {
            @Override
            protected JButton createActionComponent(final Action a) {
                JButton button = super.createActionComponent(a);
                button.setFocusable(false);
                button.setHideActionText(false);
                return button;
            }
        };
        toolBar.setName("toolBar");
        contentPane.add(toolBar, "cell 0 0 2 1,growx,aligny top");
        initToolBar(toolBar);
    }
    {
        JScrollPane spTree = new JScrollPane();
        spTree.setBorder(new CompoundBorder(
                new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Load Profile Elements",
                        TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)),
                new EmptyBorder(4, 4, 4, 4)));
        contentPane.add(spTree, "cell 0 1,grow");
        spTree.setName("spTree");
        {
            tree = new JTree();
            tree.addKeyListener(new TreeKeyListener());
            tree.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
            tree.addTreeSelectionListener(new TreeTreeSelectionListener());
            tree.setShowsRootHandles(true);
            tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
            tree.setName("tree");
            spTree.setViewportView(tree);
        }
    }
    {
        JPanel pnlMain = new JPanel();
        contentPane.add(pnlMain, "cell 1 1");
        pnlMain.setName("pnlMain");
        pnlMain.setLayout(new MigLayout("insets 0", "[664!]", "[grow][]"));
        {
            JPanel pnlLoadProfileProperties = new JPanel();
            pnlLoadProfileProperties.setBorder(new TitledBorder(null, "Load Profile Properties",
                    TitledBorder.LEADING, TitledBorder.TOP, null, null));
            pnlLoadProfileProperties.setName("pnlLoadProfileProperties");
            pnlMain.add(pnlLoadProfileProperties, "flowx,cell 0 0,grow");
            pnlLoadProfileProperties
                    .setLayout(new MigLayout("insets 4", "[270,grow]8[]8[200]8[]8[200]", "[][][][grow]"));
            {
                lblName = new JLabel("Name");
                lblName.setDisplayedMnemonic('N');
                lblName.setHorizontalAlignment(SwingConstants.CENTER);
                lblName.setName("lblName");
                pnlLoadProfileProperties.add(lblName, "cell 0 0");
            }
            {
                JSeparator separator = new JSeparator();
                separator.setPreferredSize(new Dimension(0, 200));
                separator.setOrientation(SwingConstants.VERTICAL);
                separator.setName("separator");
                pnlLoadProfileProperties.add(separator, "cell 1 0 1 4, growy");
            }
            {
                JLabel lblClient = new JLabel("Clients");
                lblClient.setName("lblClient");
                pnlLoadProfileProperties.add(lblClient, "cell 2 0");
            }
            {
                JSeparator separator = new JSeparator();
                separator.setPreferredSize(new Dimension(0, 200));
                separator.setOrientation(SwingConstants.VERTICAL);
                separator.setName("separator");
                pnlLoadProfileProperties.add(separator, "cell 3 0 1 4, growy");
            }
            {
                lblTargets = new JLabel("Targets");
                lblTargets.setName("lblTargets");
                pnlLoadProfileProperties.add(lblTargets, "cell 4 0");
            }
            {
                txtName = new JTextField();
                lblName.setLabelFor(txtName);
                txtName.setColumns(10);
                txtName.setName("txtName");
                txtName.getDocument().addDocumentListener(dirtyListener);
                pnlLoadProfileProperties.add(txtName, "cell 0 1,growx");
            }
            {
                JScrollPane spClients = new JScrollPane();
                spClients.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
                spClients.setName("spClients");
                pnlLoadProfileProperties.add(spClients, "cell 2 1 1 3,grow");
                {
                    tblClients = new JCheckListTable();
                    tblClients.setName("tblClients");
                    spClients.setViewportView(tblClients);
                    spClients.setColumnHeaderView(null);
                }
            }
            {
                JScrollPane spTargets = new JScrollPane();
                spTargets.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
                spTargets.setName("spTargets");
                pnlLoadProfileProperties.add(spTargets, "cell 4 1 1 3,grow");
                {
                    tblTargets = new JCheckListTable();
                    tblTargets.setName("tblTargets");
                    spTargets.setViewportView(tblTargets);
                    spTargets.setColumnHeaderView(null);
                }
            }
            {
                lblDescription = new JLabel("Description");
                lblDescription.setDisplayedMnemonic('D');
                lblDescription.setName("lblDescription");
                pnlLoadProfileProperties.add(lblDescription, "cell 0 2");
            }
            {
                JScrollPane spDescription = new JScrollPane();
                spDescription.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
                spDescription.setName("spDescription");
                pnlLoadProfileProperties.add(spDescription, "cell 0 3,height 50:50:,grow");
                {
                    taDescription = new JTextArea();
                    taDescription.setFont(txtName.getFont());
                    lblDescription.setLabelFor(taDescription);
                    taDescription.setRows(3);
                    taDescription.setName("taDescription");
                    taDescription.getDocument().addDocumentListener(dirtyListener);
                    spDescription.setViewportView(taDescription);
                }
            }
        }
        {
            JPanel pnlCurveAssignment = new JPanel();
            pnlCurveAssignment.setBorder(new TitledBorder(null, "Active Load Curve Assignment",
                    TitledBorder.LEADING, TitledBorder.TOP, null, null));
            pnlMain.add(pnlCurveAssignment, "cell 0 1,grow");
            pnlCurveAssignment.setLayout(new MigLayout("insets 4", "[grow]", "[grow][]"));
            {
                pnlCard = new JPanel();
                pnlCard.setName("pnlCard");
                pnlCurveAssignment.add(pnlCard, "cell 0 0,grow");
                cardLayout = new CardLayout(0, 0);
                pnlCard.setLayout(cardLayout);
                {
                    stairsPanel = new StairsPanel();
                    stairsPanel.setName("stairsPanel");
                    pnlCard.add(stairsPanel, "stairs");
                }
                {
                    oneTimePanel = new OneTimePanel();
                    oneTimePanel.setName("oneTimePanel");
                    pnlCard.add(oneTimePanel, "oneTime");
                }
                {
                    markerPanel = new MarkerPanel();
                    markerPanel.setName("markerPanel");
                    pnlCard.add(markerPanel, "marker");
                }
                {
                    JLabel lblNoActiveCurve = new JLabel("no active curve assignment");
                    lblNoActiveCurve.setHorizontalAlignment(SwingConstants.CENTER);
                    pnlCard.add(lblNoActiveCurve, "none");
                    lblNoActiveCurve.setName("lblNoActiveCurve");
                }
            }
            {
                btnOk = new JButtonExt("OK");
                getRootPane().setDefaultButton(btnOk);
                btnOk.setEnabled(false);
                btnOk.addActionListener(new BtnOkActionListener());
                btnOk.setMnemonic(KeyEvent.VK_O);
                btnOk.setName("btnOk");
                pnlCurveAssignment.add(btnOk, "cell 0 1,alignx right");
            }
            {
                btnCancel = new JButtonExt("Cancel");
                btnCancel.setEnabled(false);
                btnCancel.addActionListener(new BtnCancelActionListener());
                btnCancel.setMnemonic(KeyEvent.VK_C);
                btnCancel.setName("btnCancel");
                pnlCurveAssignment.add(btnCancel, "cell 0 1,alignx right");
            }
        }
    }
}

From source file:info.puzz.trackprofiler.gui.TrackProfilerFrame.java

private JToolBar getTopToolBar() {
    if (topToolBar == null) {
        topToolBar = new JToolBar();
        topToolBar.setFloatable(false);/*from w  ww  .  ja v  a2  s .c om*/
        topToolBar.add(getLoadFiles());
        topToolBar.add(getResetButton());
        topToolBar.add(getIzravnajButton());
        topToolBar.add(getExtreemesButton());
        topToolBar.add(getWaypointsButton());
        topToolBar.add(getPreferencesButton());
        topToolBar.add(getAboutButton());
        topToolBar.add(getExitButton());
    }
    return topToolBar;
}

From source file:net.pms.newgui.LooksFrame.java

public JComponent buildContent() {
    JPanel panel = new JPanel(new BorderLayout());
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);/*from www .j  av  a2  s. c  o  m*/
    toolBar.setRollover(true);

    toolBar.add(new JPanel());

    if (PMS.getConfiguration().useWebInterface()) {
        webinterface = createToolBarButton(Messages.getString("LooksFrame.29"), "button-wif.png");
        webinterface.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String error = null;
                if (PMS.get().getWebInterface() != null && isNotBlank(PMS.get().getWebInterface().getUrl())) {
                    try {
                        URI uri = new URI(PMS.get().getWebInterface().getUrl());
                        try {
                            Desktop.getDesktop().browse(uri);
                        } catch (RuntimeException | IOException be) {
                            LOGGER.error("Cound not open the default web browser: {}", be.getMessage());
                            LOGGER.trace("", be);
                            error = Messages.getString("LooksFrame.BrowserError") + "\n" + be.getMessage();
                        }
                    } catch (URISyntaxException se) {
                        LOGGER.error("Could not form a valid web interface URI from \"{}\": {}",
                                PMS.get().getWebInterface().getUrl(), se.getMessage());
                        LOGGER.trace("", se);
                        error = Messages.getString("LooksFrame.URIError");
                    }
                } else {
                    error = Messages.getString("LooksFrame.URIError");
                }
                if (error != null) {
                    JOptionPane.showMessageDialog(null, error, Messages.getString("Dialog.Error"),
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        });
        webinterface.setToolTipText(Messages.getString("LooksFrame.30"));
        webinterface.setEnabled(configuration.useWebInterface());
        toolBar.add(webinterface);
        toolBar.addSeparator(new Dimension(20, 1));
    }

    restartIcon = (AnimatedIcon) reload.getIcon();
    restartRequredIcon.start();
    setReloadable(false);
    reload.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            reload.setEnabled(false);
            PMS.get().reset();
        }
    });
    reload.setToolTipText(Messages.getString("LooksFrame.28"));
    toolBar.add(reload);

    toolBar.addSeparator(new Dimension(20, 1));
    AbstractButton quit = createToolBarButton(Messages.getString("LooksFrame.5"), "button-quit.png");
    quit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            quit();
        }
    });
    toolBar.add(quit);
    if (System.getProperty(START_SERVICE) != null) {
        quit.setEnabled(false);
    }
    toolBar.add(new JPanel());

    // Apply the orientation to the toolbar and all components in it
    ComponentOrientation orientation = ComponentOrientation.getOrientation(PMS.getLocale());
    toolBar.applyComponentOrientation(orientation);
    toolBar.setBorder(new EmptyBorder(new Insets(8, 0, 0, 0)));

    panel.add(toolBar, BorderLayout.NORTH);
    panel.add(buildMain(), BorderLayout.CENTER);
    status = new JLabel("");
    status.setBorder(BorderFactory.createEmptyBorder());
    status.setComponentOrientation(orientation);

    // Calling applyComponentOrientation() here would be ideal.
    // Alas it horribly mutilates the layout of several tabs.
    //panel.applyComponentOrientation(orientation);
    panel.add(status, BorderLayout.SOUTH);

    return panel;
}

From source file:de.codesourcery.jasm16.utils.ASTInspector.java

private void setupUI() throws MalformedURLException {
    // editor pane
    editorPane = new JTextPane();
    editorScrollPane = new JScrollPane(editorPane);
    editorPane.addCaretListener(listener);

    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    editorScrollPane.setPreferredSize(new Dimension(400, 600));
    editorScrollPane.setMinimumSize(new Dimension(100, 100));

    final AdjustmentListener adjustmentListener = new AdjustmentListener() {

        @Override/*w w w  . ja  v  a 2  s .  co  m*/
        public void adjustmentValueChanged(AdjustmentEvent e) {
            if (!e.getValueIsAdjusting()) {
                if (currentUnit != null) {
                    doSemanticHighlighting(currentUnit);
                }
            }
        }
    };
    editorScrollPane.getVerticalScrollBar().addAdjustmentListener(adjustmentListener);
    editorScrollPane.getHorizontalScrollBar().addAdjustmentListener(adjustmentListener);

    // button panel
    final JPanel topPanel = new JPanel();

    final JToolBar toolbar = new JToolBar();
    final JButton showASTButton = new JButton("Show AST");
    showASTButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean currentlyVisible = astInspector != null ? astInspector.isVisible() : false;
            if (currentlyVisible) {
                showASTButton.setText("Show AST");
            } else {
                showASTButton.setText("Hide AST");
            }
            if (currentlyVisible) {
                astInspector.setVisible(false);
            } else {
                showASTInspector();
            }

        }
    });

    fileChooser.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final JFileChooser chooser;
            if (lastOpenDirectory != null && lastOpenDirectory.isDirectory()) {
                chooser = new JFileChooser(lastOpenDirectory);
            } else {
                lastOpenDirectory = null;
                chooser = new JFileChooser();
            }

            final FileFilter filter = new FileFilter() {

                @Override
                public boolean accept(File f) {
                    if (f.isDirectory()) {
                        return true;
                    }
                    return f.isFile() && (f.getName().endsWith(".asm") || f.getName().endsWith(".dasm")
                            || f.getName().endsWith(".dasm16"));
                }

                @Override
                public String getDescription() {
                    return "DCPU-16 assembler sources";
                }
            };
            chooser.setFileFilter(filter);
            int returnVal = chooser.showOpenDialog(frame);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File newFile = chooser.getSelectedFile();
                if (newFile.isFile()) {
                    lastOpenDirectory = newFile.getParentFile();
                    try {
                        openFile(newFile);
                    } catch (IOException e1) {
                        statusModel.addError("Failed to read from file " + newFile.getAbsolutePath(), e1);
                    }
                }
            }
        }
    });
    toolbar.add(fileChooser);
    toolbar.add(showASTButton);

    final ComboBoxModel<String> model = new ComboBoxModel<String>() {

        private ICompilerPhase selected;

        private final List<String> realModel = new ArrayList<String>();

        {
            for (ICompilerPhase p : compiler.getCompilerPhases()) {
                realModel.add(p.getName());
                if (p.getName().equals(ICompilerPhase.PHASE_GENERATE_CODE)) {
                    selected = p;
                }
            }
        }

        @Override
        public Object getSelectedItem() {
            return selected != null ? selected.getName() : null;
        }

        private ICompilerPhase getPhaseByName(String name) {
            for (ICompilerPhase p : compiler.getCompilerPhases()) {
                if (p.getName().equals(name)) {
                    return p;
                }
            }
            return null;
        }

        @Override
        public void setSelectedItem(Object name) {
            selected = getPhaseByName((String) name);
        }

        @Override
        public void addListDataListener(ListDataListener l) {
        }

        @Override
        public String getElementAt(int index) {
            return realModel.get(index);
        }

        @Override
        public int getSize() {
            return realModel.size();
        }

        @Override
        public void removeListDataListener(ListDataListener l) {
        }

    };
    comboBox.setModel(model);
    comboBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (model.getSelectedItem() != null) {
                ICompilerPhase oldPhase = findDisabledPhase();
                if (oldPhase != null) {
                    oldPhase.setStopAfterExecution(false);
                }
                compiler.getCompilerPhaseByName((String) model.getSelectedItem()).setStopAfterExecution(true);
                try {
                    compile();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        }

        private ICompilerPhase findDisabledPhase() {
            for (ICompilerPhase p : compiler.getCompilerPhases()) {
                if (p.isStopAfterExecution()) {
                    return p;
                }
            }
            return null;
        }
    });

    toolbar.add(new JLabel("Stop compilation after: "));
    toolbar.add(comboBox);

    cursorPosition.setSize(new Dimension(400, 15));
    cursorPosition.setEditable(false);

    statusArea.setPreferredSize(new Dimension(400, 100));
    statusArea.setModel(statusModel);

    /**
     * TOOLBAR
     * SOURCE
     * cursor position
     * status area 
     */
    topPanel.setLayout(new GridBagLayout());

    GridBagConstraints cnstrs = constraints(0, 0, GridBagConstraints.HORIZONTAL);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 0;
    topPanel.add(toolbar, cnstrs);

    cnstrs = constraints(0, 1, GridBagConstraints.BOTH);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    topPanel.add(editorScrollPane, cnstrs);

    cnstrs = constraints(0, 2, GridBagConstraints.HORIZONTAL);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 0;
    topPanel.add(cursorPosition, cnstrs);

    cnstrs = constraints(0, 3, GridBagConstraints.HORIZONTAL);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 0;

    final JPanel bottomPanel = new JPanel();
    bottomPanel.setLayout(new GridBagLayout());

    statusArea.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

    statusArea.addMouseListener(new MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                final int row = statusArea.rowAtPoint(e.getPoint());
                StatusMessage message = statusModel.getMessage(row);
                if (message.getLocation() != null) {
                    moveCursorTo(message.getLocation());
                }
            }
        };
    });

    statusArea.setFillsViewportHeight(true);
    statusArea.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    final JScrollPane statusPane = new JScrollPane(statusArea);
    statusPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    statusPane.setPreferredSize(new Dimension(400, 100));
    statusPane.setMinimumSize(new Dimension(100, 20));

    cnstrs = constraints(0, 0, GridBagConstraints.BOTH);
    cnstrs.weightx = 1;
    cnstrs.weighty = 1;
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridheight = GridBagConstraints.REMAINDER;

    bottomPanel.add(statusPane, cnstrs);

    // setup frame
    frame = new JFrame(
            "DCPU-16 assembler " + Compiler.VERSION + "   (c) 2012 by tobias.gierke@code-sourcery.de");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, bottomPanel);
    splitPane.setBackground(Color.WHITE);
    frame.getContentPane().add(splitPane);

    frame.pack();
    frame.setVisible(true);

    splitPane.setDividerLocation(0.9);
}

From source file:cl.almejo.vsim.gui.SimWindow.java

private void addMainToolbar() {
    JToolBar toolBar = new JToolBar();
    toolBar.add(newToolbarButton(NEW_ACTION));
    toolBar.add(newToolbarButton(OPEN_ACTION));
    toolBar.add(newToolbarButton(SAVE_ACTION));

    toolBar.addSeparator();// w  ww  .  j  av a 2  s . co m

    toolBar.add(newToolbarButton(UNDO_ACTION));
    toolBar.add(newToolbarButton(REDO_ACTION));
    toolBar.add(newToolbarButton(CUT_ACTION));
    toolBar.add(newToolbarButton(COPY_ACTION));
    toolBar.add(newToolbarButton(PASTE_ACTION));

    toolBar.addSeparator();
    ButtonGroup group = new ButtonGroup();

    toolBar.add(newGrouppedButton(START_ACTION, group));
    toolBar.add(newGrouppedButton(PAUSE_ACTION, group));

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

From source file:com.declarativa.interprolog.gui.ListenerWindow.java

private void UpdategraphComponents() throws IOException {
    jLayeredPane1.removeAll();/* w  w  w .  j a v  a  2  s  .c  om*/

    List<String> heads = new ArrayList<>();
    List<String> subgrph = new ArrayList<>();
    ArgBuildManager manag = new ArgBuildManager();
    Forest<String, Integer> graphGUI = new DelegateForest<>();
    graphGUI = manag.getGraphJung();

    System.out.println("\t \t NUM UF VERT:" + graphGUI.getVertexCount());

    Forest<String, Integer> forest = new DelegateForest<>();
    //ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest));
    ObservableGraph g = new ObservableGraph(graphGUI);

    //Layout layout = new BalloonLayout(forest);
    Layout layout = new BalloonLayout(graphGUI);
    //Layout layout = new TreeLayout(forest, 70, 70);

    final BaseJungScene scene2 = new SceneImpl(g, layout);

    //  jLayeredPane1.setLayout(new BorderLayout());     
    //jf.setLayout(new BorderLayout());
    jLayeredPane1.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER);
    //jf.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER);

    JToolBar bar = new JToolBar();
    bar.setMargin(new Insets(5, 5, 5, 5));
    bar.setLayout(new FlowLayout(5));
    DefaultComboBoxModel<Layout> mdl = new DefaultComboBoxModel<>();
    mdl.addElement(new KKLayout(g));
    mdl.addElement(layout);
    mdl.addElement(new BalloonLayout(forest));
    mdl.addElement(new RadialTreeLayout(forest));
    mdl.addElement(new CircleLayout(g));
    mdl.addElement(new FRLayout(g));
    mdl.addElement(new FRLayout2(g));
    mdl.addElement(new ISOMLayout(g));
    mdl.addElement(new edu.uci.ics.jung.algorithms.layout.SpringLayout(g));
    mdl.addElement(new SpringLayout2(g));
    mdl.addElement(new DAGLayout(g));
    mdl.addElement(new XLayout(g));
    mdl.setSelectedItem(layout);
    final JCheckBox checkbox = new JCheckBox("Animate iterative layouts");

    scene2.setLayoutAnimationFramesPerSecond(48);

    final JComboBox<Layout> layouts = new JComboBox(mdl);
    layouts.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln,
                boolean bln1) {
            o = o.getClass().getSimpleName();
            return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates.
        }
    });
    bar.add(new JLabel(" Layout Type"));
    bar.add(layouts);
    layouts.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            Layout layout = (Layout) layouts.getSelectedItem();
            // These two layouts implement IterativeContext, but they do
            // not evolve toward anything, they just randomly rearrange
            // themselves.  So disable animation for these.
            if (layout instanceof ISOMLayout || layout instanceof DAGLayout) {
                checkbox.setSelected(false);
            }
            scene2.setGraphLayout(layout, true);
        }
    });

    bar.add(new JLabel(" Connection Shape"));
    DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>();
    shapes.addElement(new EdgeShape.QuadCurve<String, Number>());
    shapes.addElement(new EdgeShape.BentLine<String, Number>());
    shapes.addElement(new EdgeShape.CubicCurve<String, Number>());
    shapes.addElement(new EdgeShape.Line<String, Number>());
    shapes.addElement(new EdgeShape.Box<String, Number>());
    shapes.addElement(new EdgeShape.Orthogonal<String, Number>());
    shapes.addElement(new EdgeShape.Wedge<String, Number>(10));

    final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>(
            shapes);
    shapesBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox
                    .getSelectedItem();
            scene2.setConnectionEdgeShape(xform);
        }
    });
    shapesBox.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln,
                boolean bln1) {
            o = o.getClass().getSimpleName();
            return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates.
        }
    });
    shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>());
    bar.add(shapesBox);

    //jf.add(bar, BorderLayout.NORTH);
    bar.add(new ListenerWindow.MinSizePanel(scene2.createSatelliteView()));
    bar.setFloatable(false);
    bar.setRollover(true);

    final JLabel selectionLabel = new JLabel("<html>&nbsp;</html>");
    System.out.println("LOOKUP IS " + scene2.getLookup());
    Lookup.Result<String> selectedNodes = scene2.getLookup().lookupResult(String.class);
    LookupListener listener = new LookupListener() {
        @Override
        public void resultChanged(LookupEvent le) {
            System.out.println("RES CHANGED");
            Lookup.Result<String> res = (Lookup.Result<String>) le.getSource();
            StringBuilder sb = new StringBuilder("<html>");
            List<String> l = new ArrayList<>(res.allInstances());
            Collections.sort(l);
            for (String s : l) {
                if (sb.length() != 0) {
                    sb.append(", ");
                }
                sb.append(s);
            }
            sb.append("</html>");
            selectionLabel.setText(sb.toString());
            System.out.println("LOOKUP EVENT " + sb);
        }
    };
    selectedNodes.addLookupListener(listener);
    selectedNodes.allInstances();

    bar.add(selectionLabel);

    checkbox.setSelected(true);
    checkbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            scene2.setAnimateIterativeLayouts(checkbox.isSelected());
        }
    });
    bar.add(checkbox);
    jLayeredPane3.setLayout(new BorderLayout());

    jLayeredPane3.add(bar);
    //        jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700);
    //        jf.setSize(new Dimension(1280, 720));
    //        jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    this.repaint();
    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent we) {
            scene2.relayout(true);
            scene2.validate();
        }
    });

}

From source file:com._17od.upm.gui.MainWindow.java

private JToolBar createToolBar() {

    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);//  ww w  .j  a v  a 2  s. c  o  m
    toolbar.setRollover(true);

    // The "Add Account" button
    addAccountButton = new JButton();
    addAccountButton.setToolTipText(Translator.translate(ADD_ACCOUNT_TXT));
    addAccountButton.setIcon(Util.loadImage("add_account.gif"));
    addAccountButton.setDisabledIcon(Util.loadImage("add_account_d.gif"));
    ;
    addAccountButton.addActionListener(this);
    addAccountButton.setEnabled(false);
    addAccountButton.setActionCommand(ADD_ACCOUNT_TXT);
    toolbar.add(addAccountButton);

    // The "Edit Account" button
    editAccountButton = new JButton();
    editAccountButton.setToolTipText(Translator.translate(EDIT_ACCOUNT_TXT));
    editAccountButton.setIcon(Util.loadImage("edit_account.gif"));
    editAccountButton.setDisabledIcon(Util.loadImage("edit_account_d.gif"));
    ;
    editAccountButton.addActionListener(this);
    editAccountButton.setEnabled(false);
    editAccountButton.setActionCommand(EDIT_ACCOUNT_TXT);
    toolbar.add(editAccountButton);

    // The "Delete Account" button
    deleteAccountButton = new JButton();
    deleteAccountButton.setToolTipText(Translator.translate(DELETE_ACCOUNT_TXT));
    deleteAccountButton.setIcon(Util.loadImage("delete_account.gif"));
    deleteAccountButton.setDisabledIcon(Util.loadImage("delete_account_d.gif"));
    ;
    deleteAccountButton.addActionListener(this);
    deleteAccountButton.setEnabled(false);
    deleteAccountButton.setActionCommand(DELETE_ACCOUNT_TXT);
    toolbar.add(deleteAccountButton);

    toolbar.addSeparator();

    // The "Copy Username" button
    copyUsernameButton = new JButton();
    copyUsernameButton.setToolTipText(Translator.translate(COPY_USERNAME_TXT));
    copyUsernameButton.setIcon(Util.loadImage("copy_username.gif"));
    copyUsernameButton.setDisabledIcon(Util.loadImage("copy_username_d.gif"));
    ;
    copyUsernameButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            copyUsernameToClipboard();
        }
    });
    copyUsernameButton.setEnabled(false);
    toolbar.add(copyUsernameButton);

    // The "Copy Password" button
    copyPasswordButton = new JButton();
    copyPasswordButton.setToolTipText(Translator.translate(COPY_PASSWORD_TXT));
    copyPasswordButton.setIcon(Util.loadImage("copy_password.gif"));
    copyPasswordButton.setDisabledIcon(Util.loadImage("copy_password_d.gif"));
    ;
    copyPasswordButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            copyPasswordToClipboard();
        }
    });
    copyPasswordButton.setEnabled(false);
    toolbar.add(copyPasswordButton);

    // The "Launch URL" button
    launchURLButton = new JButton();
    launchURLButton.setToolTipText(Translator.translate(LAUNCH_URL_TXT));
    launchURLButton.setIcon(Util.loadImage("launch_URL.gif"));
    launchURLButton.setDisabledIcon(Util.loadImage("launch_URL_d.gif"));
    ;
    launchURLButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            AccountInformation accInfo = dbActions.getSelectedAccount();
            String uRl = accInfo.getUrl();

            // Check if the selected url is null or emty and inform the user
            // via JoptioPane message
            if ((uRl == null) || (uRl.length() == 0)) {
                JOptionPane.showMessageDialog(launchURLButton.getParent(),
                        Translator.translate("EmptyUrlJoptionpaneMsg"),
                        Translator.translate("UrlErrorJoptionpaneTitle"), JOptionPane.WARNING_MESSAGE);

                // Check if the selected url is a valid formated url(via
                // urlIsValid() method) and inform the user via JoptioPane
                // message
            } else if (!(urlIsValid(uRl))) {
                JOptionPane.showMessageDialog(launchURLButton.getParent(),
                        Translator.translate("InvalidUrlJoptionpaneMsg"),
                        Translator.translate("UrlErrorJoptionpaneTitle"), JOptionPane.WARNING_MESSAGE);

                // Call the method LaunchSelectedURL() using the selected
                // url as input
            } else {
                LaunchSelectedURL(uRl);

            }
        }
    });
    launchURLButton.setEnabled(false);
    toolbar.add(launchURLButton);

    toolbar.addSeparator();

    // The "Option" button
    optionsButton = new JButton();
    optionsButton.setToolTipText(Translator.translate(OPTIONS_TXT));
    optionsButton.setIcon(Util.loadImage("options.gif"));
    optionsButton.setDisabledIcon(Util.loadImage("options_d.gif"));
    ;
    optionsButton.addActionListener(this);
    optionsButton.setEnabled(true);
    optionsButton.setActionCommand(OPTIONS_TXT);
    toolbar.add(optionsButton);

    toolbar.addSeparator();

    // The Sync database button
    syncDatabaseButton = new JButton();
    syncDatabaseButton.setToolTipText(Translator.translate(SYNC_DATABASE_TXT));
    syncDatabaseButton.setIcon(Util.loadImage("sync.png"));
    syncDatabaseButton.setDisabledIcon(Util.loadImage("sync_d.png"));
    ;
    syncDatabaseButton.addActionListener(this);
    syncDatabaseButton.setEnabled(false);
    syncDatabaseButton.setActionCommand(SYNC_DATABASE_TXT);
    toolbar.add(syncDatabaseButton);

    return toolbar;
}