Search in sources :

Example 26 with JToolBar

use of javax.swing.JToolBar in project archi by archimatetool.

the class SimpleSwingExample method start.

public void start() {
    // $NON-NLS-1$
    mainFrame = new JFrame("Simple Swing Layout Example");
    toolBar = new JToolBar();
    mainFrame.getContentPane().setLayout(new BorderLayout());
    mainFrame.getContentPane().add(toolBar, BorderLayout.NORTH);
    // $NON-NLS-1$
    lblProgress = new JLabel("Progress: ");
    mainFrame.getContentPane().add(lblProgress, BorderLayout.SOUTH);
    createMainPanel();
    mainFrame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            stop();
            mainFrame.dispose();
        }
    });
    // $NON-NLS-1$
    btnContinuous = new JToggleButton("continuous", false);
    // $NON-NLS-1$
    btnAsynchronous = new JToggleButton("asynchronous", false);
    toolBar.add(btnContinuous);
    toolBar.add(btnAsynchronous);
    // $NON-NLS-1$
    btnStop = new JButton("Stop");
    btnStop.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            stop();
        }
    });
    toolBar.add(btnStop);
    // $NON-NLS-1$
    JButton btnCreateGraph = new JButton("New graph");
    btnCreateGraph.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            stop();
            createGraph(true);
        }
    });
    toolBar.add(btnCreateGraph);
    // $NON-NLS-1$
    JButton btnCreateTree = new JButton("New tree");
    btnCreateTree.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            stop();
            createGraph(false);
        }
    });
    toolBar.add(btnCreateTree);
    createGraph(false);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    mainFrame.setLocation((int) (screenSize.getWidth() - INITIAL_PANEL_WIDTH) / 2, (int) (screenSize.getHeight() - INITIAL_PANEL_HEIGHT) / 2);
    mainFrame.pack();
    mainFrame.setVisible(true);
    mainFrame.repaint();
    try {
        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                SPRING = new SpringLayoutAlgorithm(LayoutStyles.NONE);
                TREE_VERT = new TreeLayoutAlgorithm(LayoutStyles.NONE);
                TREE_HORIZ = new HorizontalTreeLayoutAlgorithm(LayoutStyles.NONE);
                RADIAL = new RadialLayoutAlgorithm(LayoutStyles.NONE);
                GRID = new GridLayoutAlgorithm(LayoutStyles.NONE);
                HORIZ = new HorizontalLayoutAlgorithm(LayoutStyles.NONE);
                VERT = new VerticalLayoutAlgorithm(LayoutStyles.NONE);
                SPRING.setIterations(1000);
                // initialize layouts
                TREE_VERT.setComparator(new Comparator() {

                    @Override
                    public int compare(Object o1, Object o2) {
                        if (o1 instanceof Comparable && o2 instanceof Comparable) {
                            return ((Comparable) o1).compareTo(o2);
                        }
                        return 0;
                    }
                });
                GRID.setRowPadding(20);
                // $NON-NLS-1$
                addAlgorithm(SPRING, "Spring", false);
                // $NON-NLS-1$
                addAlgorithm(TREE_VERT, "Tree-V", false);
                // $NON-NLS-1$
                addAlgorithm(TREE_HORIZ, "Tree-H", false);
                // $NON-NLS-1$
                addAlgorithm(RADIAL, "Radial", false);
                // $NON-NLS-1$
                addAlgorithm(GRID, "Grid", false);
                // $NON-NLS-1$
                addAlgorithm(HORIZ, "Horiz", false);
                // $NON-NLS-1$
                addAlgorithm(VERT, "Vert", false);
                for (int i = 0; i < algorithms.size(); i++) {
                    final LayoutAlgorithm algorithm = (LayoutAlgorithm) algorithms.get(i);
                    final String algorithmName = (String) algorithmNames.get(i);
                    // final boolean algorithmAnimate = ((Boolean)algorithmAnimates.get(i)).booleanValue();
                    JButton algorithmButton = new JButton(algorithmName);
                    algorithmButton.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            currentLayoutAlgorithm = algorithm;
                            currentLayoutAlgorithmName = algorithmName;
                            algorithm.setEntityAspectRatio((double) mainPanel.getWidth() / (double) mainPanel.getHeight());
                            // animate = algorithmAnimate;
                            performLayout();
                        }
                    });
                    toolBar.add(algorithmButton);
                }
            }
        });
    } catch (InterruptedException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (InvocationTargetException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
}
Also used : ActionEvent(java.awt.event.ActionEvent) HorizontalTreeLayoutAlgorithm(org.eclipse.zest.layouts.algorithms.HorizontalTreeLayoutAlgorithm) TreeLayoutAlgorithm(org.eclipse.zest.layouts.algorithms.TreeLayoutAlgorithm) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) RadialLayoutAlgorithm(org.eclipse.zest.layouts.algorithms.RadialLayoutAlgorithm) VerticalLayoutAlgorithm(org.eclipse.zest.layouts.algorithms.VerticalLayoutAlgorithm) HorizontalLayoutAlgorithm(org.eclipse.zest.layouts.algorithms.HorizontalLayoutAlgorithm) Comparator(java.util.Comparator) BorderLayout(java.awt.BorderLayout) JToggleButton(javax.swing.JToggleButton) HorizontalTreeLayoutAlgorithm(org.eclipse.zest.layouts.algorithms.HorizontalTreeLayoutAlgorithm) VerticalLayoutAlgorithm(org.eclipse.zest.layouts.algorithms.VerticalLayoutAlgorithm) LayoutAlgorithm(org.eclipse.zest.layouts.LayoutAlgorithm) TreeLayoutAlgorithm(org.eclipse.zest.layouts.algorithms.TreeLayoutAlgorithm) GridLayoutAlgorithm(org.eclipse.zest.layouts.algorithms.GridLayoutAlgorithm) SpringLayoutAlgorithm(org.eclipse.zest.layouts.algorithms.SpringLayoutAlgorithm) HorizontalLayoutAlgorithm(org.eclipse.zest.layouts.algorithms.HorizontalLayoutAlgorithm) RadialLayoutAlgorithm(org.eclipse.zest.layouts.algorithms.RadialLayoutAlgorithm) JFrame(javax.swing.JFrame) SpringLayoutAlgorithm(org.eclipse.zest.layouts.algorithms.SpringLayoutAlgorithm) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) Dimension(java.awt.Dimension) HorizontalTreeLayoutAlgorithm(org.eclipse.zest.layouts.algorithms.HorizontalTreeLayoutAlgorithm) InvocationTargetException(java.lang.reflect.InvocationTargetException) GridLayoutAlgorithm(org.eclipse.zest.layouts.algorithms.GridLayoutAlgorithm) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent)

Example 27 with JToolBar

use of javax.swing.JToolBar in project cytoscape-impl by cytoscape.

the class CytoscapeMenus method createViewFrameToolBar.

public JToolBar createViewFrameToolBar() {
    JToolBar viewToolBar = null;
    final int total = toolBar.getComponentCount();
    boolean addSeparator = false;
    int buttonsAfterSeparator = 0;
    for (int i = 0; i < total; i++) {
        final Component c = toolBar.getComponent(i);
        if (c instanceof JButton && ((JButton) c).getAction() instanceof CyAction) {
            final JButton btn = ((JButton) c);
            final CyAction action = (CyAction) btn.getAction();
            if (viewFrameActions.contains(action)) {
                if (viewToolBar == null) {
                    viewToolBar = new JToolBar();
                    viewToolBar.setBorder(toolBar.getBorder());
                }
                if (addSeparator) {
                    viewToolBar.addSeparator();
                    addSeparator = false;
                    buttonsAfterSeparator = 0;
                }
                final JButton newBtn = CytoscapeToolBar.createToolBarButton(action);
                viewToolBar.add(newBtn);
                buttonsAfterSeparator++;
            }
        } else if (c instanceof JSeparator && buttonsAfterSeparator > 0) {
            addSeparator = true;
        }
    }
    if (viewToolBar != null && viewToolBar.getComponentCount() > 0 && viewToolBar.getComponentAtIndex(viewToolBar.getComponentCount() - 1) instanceof JSeparator)
        viewToolBar.remove(viewToolBar.getComponentCount() - 1);
    return viewToolBar;
}
Also used : JButton(javax.swing.JButton) CyAction(org.cytoscape.application.swing.CyAction) JToolBar(javax.swing.JToolBar) Component(java.awt.Component) JSeparator(javax.swing.JSeparator)

Example 28 with JToolBar

use of javax.swing.JToolBar in project cytoscape-impl by cytoscape.

the class CytoscapeDesktop method setupStatusPanel.

private JToolBar setupStatusPanel(StatusBarPanelFactory jobStatusPanelFactory, StatusBarPanelFactory taskStatusPanelFactory) {
    final JPanel taskStatusPanel = taskStatusPanelFactory.createTaskStatusPanel();
    final JPanel jobStatusPanel = jobStatusPanelFactory.createTaskStatusPanel();
    final JToolBar statusToolBar = new JToolBar();
    final MemStatusPanel memStatusPanel = new MemStatusPanel();
    if (LookAndFeelUtil.isNimbusLAF()) {
        jobStatusPanel.setOpaque(false);
        taskStatusPanel.setOpaque(false);
        statusToolBar.setOpaque(false);
        memStatusPanel.setOpaque(false);
    }
    final JPanel statusPanel = new JPanel();
    statusPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, UIManager.getColor("Separator.foreground")));
    final GroupLayout layout = new GroupLayout(statusPanel);
    statusPanel.setLayout(layout);
    layout.setAutoCreateContainerGaps(false);
    layout.setAutoCreateGaps(false);
    layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap().addComponent(jobStatusPanel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addComponent(taskStatusPanel, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addPreferredGap(ComponentPlacement.UNRELATED).addComponent(statusToolBar, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addPreferredGap(ComponentPlacement.UNRELATED).addComponent(memStatusPanel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addContainerGap());
    layout.setVerticalGroup(layout.createSequentialGroup().addGap(LookAndFeelUtil.isWinLAF() ? 5 : 0).addGroup(layout.createParallelGroup(Alignment.CENTER, false).addComponent(jobStatusPanel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(taskStatusPanel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(statusToolBar, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(memStatusPanel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)).addGap(LookAndFeelUtil.isWinLAF() ? 5 : 0));
    getMainPanel().add(statusPanel, BorderLayout.SOUTH);
    return statusToolBar;
}
Also used : JPanel(javax.swing.JPanel) GroupLayout(javax.swing.GroupLayout) JToolBar(javax.swing.JToolBar)

Example 29 with JToolBar

use of javax.swing.JToolBar in project Spark by igniterealtime.

the class CoBrowser method buildUI.

private void buildUI() {
    if (!isShowing) {
        update(getGraphics());
        isShowing = true;
        final JToolBar toolbar = new JToolBar();
        toolbar.setFloatable(false);
        toolbar.add(backButton);
        toolbar.add(urlField);
        toolbar.add(goButton);
        toolbar.setOpaque(false);
        final BackgroundPane titlePanel = new BackgroundPane();
        titlePanel.setLayout(new GridBagLayout());
        JLabel cobrowsingLabel = new JLabel();
        cobrowsingLabel.setText(FpRes.getString("cobrowsing.session"));
        cobrowsingLabel.setFont(new Font("Dialog", Font.BOLD, 11));
        titlePanel.add(cobrowsingLabel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0));
        titlePanel.add(pushCurrentPageButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0));
        titlePanel.add(followMeButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0));
        titlePanel.add(toolbar, new GridBagConstraints(0, 1, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 5, 0), 0, 0));
        add(titlePanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
        updateLinkLabel(getStartLocation());
        goButton.addActionListener(this);
        backButton.addActionListener(this);
        pushCurrentPageButton.addActionListener(this);
    }
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) BackgroundPane(org.jivesoftware.fastpath.workspace.panes.BackgroundPane) Font(java.awt.Font)

Example 30 with JToolBar

use of javax.swing.JToolBar in project beast2 by CompEvol.

the class ModelBuilder method makeToolbar.

void makeToolbar() {
    m_jTbTools = new JToolBar();
    m_jTbTools.setFloatable(false);
    // m_jTbTools.setLayout(new GridBagLayout());
    m_jTbTools.add(a_new);
    m_jTbTools.add(a_save);
    m_jTbTools.add(a_load);
    m_jTbTools.addSeparator(new Dimension(2, 2));
    m_jTbTools.add(a_cutnode);
    m_jTbTools.add(a_copynode);
    m_jTbTools.add(a_pastenode);
    m_jTbTools.addSeparator(new Dimension(2, 2));
    m_jTbTools.add(a_undo);
    m_jTbTools.add(a_redo);
    m_jTbTools.addSeparator(new Dimension(2, 2));
    m_jTbTools.add(a_select);
    m_jTbTools.add(a_function);
    // m_jTbTools.add(a_rect);
    // m_jTbTools.add(a_rrect);
    // m_jTbTools.add(a_ellipse);
    // m_jTbTools.add(a_line);
    // m_jTbTools.add(a_poly);
    m_jTbTools.add(a_arrow);
    m_jTbTools.addSeparator(new Dimension(2, 2));
    m_jTbTools.add(a_alignleft);
    m_jTbTools.add(a_alignright);
    m_jTbTools.add(a_aligntop);
    m_jTbTools.add(a_alignbottom);
    m_jTbTools.add(a_centerhorizontal);
    m_jTbTools.add(a_centervertical);
    m_jTbTools.add(a_spacehorizontal);
    m_jTbTools.add(a_spacevertical);
    setLayout(new BorderLayout());
    // add("North", m_jTbTools);
    // add("Center", g_panel);
    m_jTbTools2 = new JToolBar();
    m_jTbTools2.setFloatable(false);
    m_jTbTools2.add(a_relax);
    m_jTbTools2.add(a_viewLoggers);
    m_jTbTools2.add(a_viewOperators);
    m_jTbTools2.add(a_viewSequences);
    m_jTbTools2.add(a_layout);
}
Also used : BorderLayout(java.awt.BorderLayout) JToolBar(javax.swing.JToolBar) Dimension(java.awt.Dimension)

Aggregations

JToolBar (javax.swing.JToolBar)124 JButton (javax.swing.JButton)51 BorderLayout (java.awt.BorderLayout)45 JPanel (javax.swing.JPanel)37 JScrollPane (javax.swing.JScrollPane)30 Dimension (java.awt.Dimension)25 Insets (java.awt.Insets)25 ActionEvent (java.awt.event.ActionEvent)24 JLabel (javax.swing.JLabel)23 ActionListener (java.awt.event.ActionListener)19 ImageIcon (javax.swing.ImageIcon)17 Component (java.awt.Component)14 JSplitPane (javax.swing.JSplitPane)14 JTable (javax.swing.JTable)14 JTextField (javax.swing.JTextField)14 JPopupMenu (javax.swing.JPopupMenu)13 JToggleButton (javax.swing.JToggleButton)12 GridBagConstraints (java.awt.GridBagConstraints)10 GridBagLayout (java.awt.GridBagLayout)10 JComponent (javax.swing.JComponent)10