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.declarativa.interprolog.gui.ListenerWindow.java

private void UpdategraphComponents(Forest<String, Integer> graph) throws IOException {
    jLayeredPane1.removeAll();/*from   w ww . java 2 s  .co m*/

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

    graphGUI = graph;

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

    //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.isencia.passerelle.hmi.HMIBase.java

public JToolBar createDefaultToolbar() {
    final JToolBar toolBar = new JToolBar();

    if (modelExecutor == null) {
        modelExecutor = new ModelExecutor(this);
    }/*from  w  w w.  j  a v a2s  .  c  o m*/
    if (modelStopper == null) {
        modelStopper = new ModelStopper(this);
    }
    if (modelDebugger == null) {
        modelDebugger = new ModelDebugger(this);
    }
    if (modelDebugStepper == null) {
        modelDebugStepper = new ModelDebugStepper(this);
    }
    if (modelSuspender == null) {
        modelSuspender = new ModelSuspender(this);
    }
    if (modelResumer == null) {
        modelResumer = new ModelResumer(this);
    }
    if (saveAction == null) {
        saveAction = new SaveAction(this);
    }
    // DBA : add tooltip for each button
    createToolbarButton(modelExecutor, toolBar, HMIMessages.getString(HMIMessages.MENU_EXECUTE));
    createToolbarButton(modelSuspender, toolBar, HMIMessages.getString(HMIMessages.MENU_SUSPEND));
    createToolbarButton(modelResumer, toolBar, HMIMessages.getString(HMIMessages.MENU_RESUME));
    createToolbarButton(modelStopper, toolBar, HMIMessages.getString(HMIMessages.MENU_STOP));
    toolBar.addSeparator();
    createToolbarButton(modelDebugger, toolBar, HMIMessages.getString(HMIMessages.MENU_DEBUG));
    createToolbarButton(modelDebugStepper, toolBar, HMIMessages.getString(HMIMessages.MENU_DEBUG_STEP));
    toolBar.addSeparator();
    toolBar.addSeparator();
    createToolbarButton(saveAction, toolBar, HMIMessages.getString(HMIMessages.MENU_SAVE));

    StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, HMIMessages.MENU_EXECUTE,
            modelExecutor);
    StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, HMIMessages.MENU_DEBUG,
            modelDebugger);
    StateMachine.getInstance().registerActionForState(StateMachine.MODEL_DEBUGGING, HMIMessages.MENU_DEBUG_STEP,
            modelDebugStepper);
    StateMachine.getInstance().registerActionForState(StateMachine.MODEL_DEBUGGING, HMIMessages.MENU_STOP,
            modelStopper);
    StateMachine.getInstance().registerActionForState(StateMachine.MODEL_EXECUTING, HMIMessages.MENU_STOP,
            modelStopper);
    StateMachine.getInstance().registerActionForState(StateMachine.MODEL_EXECUTING_SUSPENDED,
            HMIMessages.MENU_STOP, modelStopper);
    StateMachine.getInstance().registerActionForState(StateMachine.MODEL_EXECUTING, HMIMessages.MENU_SUSPEND,
            modelSuspender);
    StateMachine.getInstance().registerActionForState(StateMachine.MODEL_EXECUTING_SUSPENDED,
            HMIMessages.MENU_RESUME, modelResumer);
    StateMachine.getInstance().registerActionForState(StateMachine.MODEL_DEBUGGING, HMIMessages.MENU_RESUME,
            modelResumer);

    StateMachine.getInstance().compile();
    StateMachine.getInstance().transitionTo(StateMachine.READY);

    return toolBar;
}

From source file:de.codesourcery.jasm16.ide.ui.views.SourceEditorView.java

protected JPanel createPanel() {
    // button panel
    final JToolBar toolbar = new JToolBar();
    toolbar.setLayout(new GridBagLayout());
    setColors(toolbar);//from  ww  w  . j a v  a2s.  co m

    final JButton showASTButton = new JButton("Show AST");
    setColors(showASTButton);

    showASTButton.addActionListener(new ActionListener() {

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

        }
    });

    GridBagConstraints cnstrs = constraints(0, 0, false, true, GridBagConstraints.NONE);
    toolbar.add(showASTButton, cnstrs);

    // navigation history back button
    cnstrs = constraints(1, 0, false, true, GridBagConstraints.NONE);
    toolbar.add(navigationHistoryBack, cnstrs);
    navigationHistoryBack.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            navigationHistoryBack();
        }
    });

    navigationHistoryBack.setEnabled(false);

    // navigation history forward button
    cnstrs = constraints(2, 0, true, true, GridBagConstraints.NONE);
    toolbar.add(navigationHistoryForward, cnstrs);
    navigationHistoryForward.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            navigationHistoryForward();
        }
    });
    navigationHistoryForward.setEnabled(false);

    // create status area
    statusArea.setPreferredSize(new Dimension(400, 100));
    statusArea.setModel(statusModel);
    setColors(statusArea);

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

    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;
    cnstrs.weighty = 1.0;
    topPanel.add(super.getPanel(), cnstrs);

    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 viewRow = statusArea.rowAtPoint(e.getPoint());
                if (viewRow != -1) {
                    final int modelRow = statusArea.convertRowIndexToModel(viewRow);
                    StatusMessage message = statusModel.getMessage(modelRow);
                    if (message.getLocation() != null) {
                        moveCursorTo(message.getLocation(), true);
                    }
                }
            }
        };
    });

    EditorContainer.addEditorCloseKeyListener(statusArea, this);

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

    final JScrollPane statusPane = new JScrollPane(statusArea);
    setColors(statusPane);

    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 result panel
    final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, bottomPanel);
    setColors(splitPane);

    final JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    setColors(panel);
    cnstrs = constraints(0, 0, true, true, GridBagConstraints.BOTH);
    panel.add(splitPane, cnstrs);

    final AncestorListener l = new AncestorListener() {

        @Override
        public void ancestorRemoved(AncestorEvent event) {
        }

        @Override
        public void ancestorMoved(AncestorEvent event) {
        }

        @Override
        public void ancestorAdded(AncestorEvent event) {
            splitPane.setDividerLocation(0.8d);
        }
    };
    panel.addAncestorListener(l);
    return panel;
}

From source file:com.nbt.TreeFrame.java

protected JToolBar createToolBar() {
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);// ww  w .  j  a v  a  2s  .c  om

    Action[] actions = { /* newAction, */browseAction, saveAction, /* saveAsAction, */refreshAction, null,
            deleteAction, null, openAction, null, addByteAction, addShortAction, addIntAction, addLongAction,
            addFloatAction, addDoubleAction, addByteArrayAction, addStringAction, addListAction,
            addCompoundAction };
    for (Action action : actions) {
        if (action == null) {
            toolBar.addSeparator();
        } else {
            ToolBarButton button = new ToolBarButton(action);
            toolBar.add(button);
        }
    }

    return toolBar;
}

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

private void UpdategraphComponents2(Forest<String, Integer> graph) throws IOException {
    jLayeredPane5.removeAll();/*  w  w w.j  a v  a2  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();
     */
    Forest<String, Integer> graphGUI = new DelegateForest<>();

    graphGUI = graph;

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

    //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);

    jLayeredPane5.setLayout(new BorderLayout());
    //jf.setLayout(new BorderLayout());

    jLayeredPane5.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);
    jLayeredPane6.setLayout(new BorderLayout());

    jLayeredPane6.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.peterbochs.sourceleveldebugger.SourceLevelDebugger3.java

private JToolBar getJProjectToolBar() {
    if (jProjectToolBar == null) {
        jProjectToolBar = new JToolBar();
        jProjectToolBar.add(getJSearchProjectTextField());
        jProjectToolBar.add(getJExactMatchCheckBox());
    }//from   w w  w  .  j  a  v a  2s.  c om
    return jProjectToolBar;
}

From source file:com.peterbochs.sourceleveldebugger.SourceLevelDebugger3.java

private JToolBar getJToolBar1() {
    if (jToolBar1 == null) {
        jToolBar1 = new JToolBar();
        jToolBar1.add(getSearchSymbolTextField());
        jToolBar1.add(getSymbolExactCheckBox());
    }//from   w ww .jav  a2 s. com
    return jToolBar1;
}

From source file:de.tbuchloh.kiskis.gui.MainFramePanel.java

private void initToolBar() {
    final JPanel bars = new JPanel(new FlowLayout(FlowLayout.LEFT));
    _toolbar = new JToolBar();
    _toolbar.setFloatable(false);//w w w  .  j ava 2  s  .co  m
    final Action[] actions = { _newFileAction, _openFileAction, _saveAction, _saveAsAction, _closeDocAction,
            null, _lockScreenAction, null, _quitAction };
    addActions(_toolbar, actions);
    _toolbar.addSeparator();
    bars.add(_toolbar);
    bars.add(_editHandler.getToolBar());
    bars.add(_reportHandler.getToolBar());
    this.add(bars, BorderLayout.NORTH);
}

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

private void graphComponents() throws IOException {

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

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

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

    jLayeredPane1.setLayout(new BorderLayout());
    //jf.setLayout(new BorderLayout());

    jLayeredPane1.add(new JScrollPane(scene.createView()), BorderLayout.CENTER);
    //jf.add(new JScrollPane(scene.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);//from  ww w  . j a  v a2 s . com
    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 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");

    scene.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);
            }
            scene.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();
            scene.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 MinSizePanel(scene.createSatelliteView()));
    bar.setFloatable(false);
    bar.setRollover(true);

    final JLabel selectionLabel = new JLabel("<html>&nbsp;</html>");
    System.out.println("LOOKUP IS " + scene.getLookup());
    Lookup.Result<String> selectedNodes = scene.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) {
            scene.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.addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent we) {
            scene.relayout(true);
            scene.validate();
        }
    });

}

From source file:edu.ku.brc.specify.Specify.java

/**
 *
 * @return the toolbar for the app//ww w.  j  a v  a  2 s . c o  m
 */
public JToolBar createToolBar() {

    JToolBar toolBar;
    SkinItem skinItem = SkinsMgr.getSkinItem("ToolBar");
    if (SkinsMgr.hasSkins() && skinItem != null
            && (skinItem.getBGImage() != null || skinItem.getBgColor() != null)) {
        JTiledToolbar ttb = new JTiledToolbar(skinItem.getBGImage());
        if (skinItem.getBgColor() != null) {
            ttb.setBackground(skinItem.getBgColor());
            ttb.setOpaque(true);
        } else {
            ttb.setOpaque(false);
        }
        toolBar = ttb;
    } else {
        toolBar = new JToolBar();
    }
    toolBar.setLayout(new ToolbarLayoutManager(2, 2));

    appIcon = new JLabel("  "); //$NON-NLS-1$

    setAppIcon(AppPreferences.getRemote().get("ui.formatting.user_icon_image", null)); //$NON-NLS-1$

    CommandDispatcher.register("Preferences", new CommandListener() { //$NON-NLS-1$
        public void doCommand(CommandAction cmdAction) {
            if (cmdAction.isAction("Updated")) //$NON-NLS-1$
            {
                setAppIcon(AppPreferences.getRemote().get("ui.formatting.user_icon_image", null)); //$NON-NLS-1$
            }
        }
    });

    return toolBar;
}