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:org.parosproxy.paros.extension.manualrequest.http.impl.ManualHttpRequestEditorDialog.java

/**
 * Return the footer status bar object//from   w  w w  .  j a  va  2  s. c o m
 * @return
 */
protected JToolBar getFooterStatusBar() {
    if (footerToolbar == null) {
        footerToolbar = new JToolBar();
        footerToolbar.setEnabled(true);
        footerToolbar.setFloatable(false);
        footerToolbar.setRollover(true);
        footerToolbar.setName("Footer Toolbar Left");
        footerToolbar.setBorder(BorderFactory.createEtchedBorder());
    }
    return footerToolbar;
}

From source file:org.parosproxy.paros.view.OutputPanel.java

private JToolBar getToolBar() {
    if (mainToolBar == null) {
        mainToolBar = new JToolBar();
        mainToolBar.setEnabled(true);//from   w ww . j a v a  2  s  .  co  m
        mainToolBar.setFloatable(false);
        mainToolBar.setRollover(true);

        JButton clearButton = new JButton(CLEAR_BUTTON_LABEL);
        clearButton.setToolTipText(CLEAR_BUTTON_TOOL_TIP);
        clearButton.setIcon(new ImageIcon(OutputPanel.class.getResource("/resource/icon/fugue/broom.png")));
        clearButton.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                getTxtOutput().setText("");
            };
        });

        mainToolBar.add(clearButton);
    }
    return mainToolBar;
}

From source file:org.pentaho.reporting.designer.core.ReportDesignerFrame.java

private JComponent createPaletteToolBar() {
    final JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);//from   www. ja v  a  2  s.  c o  m
    toolBar.setOrientation(JToolBar.VERTICAL);

    final ElementMetaData[] datas = ElementTypeRegistry.getInstance().getAllElementTypes();
    Arrays.sort(datas, new GroupedMetaDataComparator());
    Object grouping = null;
    boolean firstElement = true;
    for (int i = 0; i < datas.length; i++) {
        final ElementMetaData data = datas[i];
        if (data.isHidden()) {
            continue;
        }

        if (!WorkspaceSettings.getInstance().isVisible(data)) {
            continue;
        }

        final String currentGrouping = data.getGrouping(Locale.getDefault());
        if (firstElement == false) {
            if (ObjectUtilities.equal(currentGrouping, grouping) == false) {
                grouping = currentGrouping;
                toolBar.addSeparator();
            }
        } else {
            grouping = currentGrouping;
            firstElement = false;
        }
        final InsertElementAction action = new InsertElementAction(data);
        action.setReportDesignerContext(context);
        toolBar.add(new PaletteButton(data, context));
    }

    final JScrollPane paletteScrollpane = new JScrollPane(toolBar);
    paletteScrollpane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    paletteScrollpane
            .addComponentListener(new ScrollbarSyncHandler(paletteScrollpane.getVerticalScrollBar(), toolBar));
    return paletteScrollpane;
}

From source file:org.pentaho.reporting.engine.classic.core.modules.gui.base.PreviewPane.java

protected JToolBar buildToolbar(final boolean floatable) {
    toolBar = new JToolBar();
    toolBar.setFloatable(floatable);//from www  .  j a  va2  s.  c o m

    final Action[] preActions = getToolbarPreActions();
    if (preActions != null && preActions.length > 0) {
        for (int i = 0; i < preActions.length; i++) {
            toolBar.add(preActions[i]);
        }
        toolBar.addSeparator();
    }

    final ArrayList<ActionPlugin> list = new ArrayList<ActionPlugin>();
    for (final ActionPlugin[] plugins : actionPlugins.values()) {
        list.addAll(Arrays.asList(plugins));
    }
    final ActionPlugin[] plugins = list.toArray(new ActionPlugin[list.size()]);
    Arrays.sort(plugins, new ActionPluginComparator());
    PreviewPaneUtilities.addActionsToToolBar(toolBar, plugins, zoomSelectorBox, this);
    return toolBar;
}

From source file:org.pentaho.reporting.tools.configeditor.ConfigDescriptionEditor.java

/**
 * Creates and returns the entry list component that will hold all config description entries within a list.
 *
 * @return the created entry list./*from  w  ww.j  ava2s .  c o  m*/
 */
private JPanel createEntryList() {
    final Action addEntryAction = new AddEntryAction();
    final Action removeEntryAction = new RemoveEntryAction();

    model = new ConfigDescriptionModel();
    entryList = new JList(model);
    entryList.addListSelectionListener(new ConfigListSelectionListener());

    final JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);
    toolbar.add(addEntryAction);
    toolbar.add(removeEntryAction);

    final JPanel panel = new JPanel();
    panel.setMinimumSize(new Dimension(200, 0));
    panel.setLayout(new BorderLayout());
    panel.add(toolbar, BorderLayout.NORTH);
    panel.add(new JScrollPane(entryList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
    return panel;
}

From source file:org.photovault.swingui.BrowserWindow.java

/**
 Create the toolbar for this browser window.
 *///from   www .j  a  v a2  s. c  o  m
protected JToolBar createToolbar() {
    JToolBar tb = new JToolBar();

    JButton importBtn = new JButton(importAction);
    importBtn.setText("");
    JButton indexBtn = new JButton(viewCtrl.getActionAdapter("new_ext_vol"));
    indexBtn.setText("");
    JButton updateBtn = new JButton(viewCtrl.getActionAdapter("update_indexed_dirs"));
    updateBtn.setText("");
    JButton exportBtn = new JButton(viewPane.getExportSelectedAction());
    exportBtn.setText("");
    JButton deleteBtn = new JButton(viewPane.getDeleteSelectedAction());
    deleteBtn.setText("");

    JButton rotCWBtn = new JButton(viewCtrl.getActionAdapter("rotate_cw"));
    rotCWBtn.setText("");
    JButton rotCCWBtn = new JButton(viewCtrl.getActionAdapter("rotate_ccw"));
    rotCCWBtn.setText("");
    JButton rot180Btn = new JButton(viewCtrl.getActionAdapter("rotate_180"));
    rot180Btn.setText("");
    JButton cropBtn = new JButton(previewPane.getCropAction());
    cropBtn.setText("");
    JButton colorsBtn = new JButton(viewPane.getEditSelectionColorsAction());
    colorsBtn.setText("");

    JButton nextBtn = new JButton(viewPane.getSelectNextAction());
    nextBtn.setText("");
    JButton prevBtn = new JButton(viewPane.getSelectPreviousAction());
    prevBtn.setText("");
    JButton previewRightBtn = new JButton(getActionAdapter("view_preview_right"));
    previewRightBtn.setText("");
    JButton previewTopBtn = new JButton(getActionAdapter("view_preview_top"));
    previewTopBtn.setText("");
    JButton previewNoneBtn = new JButton(getActionAdapter("view_no_preview"));
    previewNoneBtn.setText("");

    ZoomComboBox zoomCombo = new ZoomComboBox(previewPane);

    tb.add(importBtn);
    tb.add(indexBtn);
    tb.add(updateBtn);
    tb.add(exportBtn);
    tb.add(deleteBtn);
    tb.addSeparator();
    tb.add(prevBtn);
    tb.add(nextBtn);
    tb.add(previewRightBtn);
    tb.add(previewTopBtn);
    tb.add(previewNoneBtn);
    tb.add(zoomCombo);
    tb.addSeparator();
    tb.add(rotCWBtn);
    tb.add(rotCCWBtn);
    tb.add(rot180Btn);
    tb.add(cropBtn);
    tb.add(colorsBtn);

    return tb;
}

From source file:org.pmedv.core.provider.ApplicationToolbarProviderImpl.java

@SuppressWarnings("unused")
public ApplicationToolbarProviderImpl() {

    toolbar = new JToolBar();
    toolbar.setFloatable(true);/*from   w  ww.  j a va2s . com*/

    try {
        JAXBContext c = JAXBContext.newInstance(ApplicationToolbar.class);

        Unmarshaller u = c.createUnmarshaller();

        ApplicationToolbar appToolBar = (ApplicationToolbar) u
                .unmarshal(getClass().getClassLoader().getResourceAsStream("toolbar.xml"));

        for (ApplicationToolbarItem currentItem : appToolBar.getItems()) {
            try {

                if (currentItem.getActionClass() != null) {

                    if (currentItem.getActionClass().equals("separator")) {
                        toolbar.add(UIUtils.createToolbarSeparator());
                        continue;
                    }

                    log.info("Mapping action class : " + currentItem.getActionClass());

                    try {

                        AbstractCommand command = null;
                        Class<?> clazz = Class.forName(currentItem.getActionClass());

                        if (currentItem.isBean()) {
                            command = (AbstractCommand) ctx.getBean(clazz);
                        } else {
                            command = (AbstractCommand) clazz.newInstance();
                        }

                        ImageIcon icon = null;
                        String toolTipText = null;
                        String text = null;

                        if (currentItem.getImageIcon() != null) {

                            InputStream is = getClass().getClassLoader()
                                    .getResourceAsStream(currentItem.getImageIcon());

                            if (is == null) {
                                is = getClass().getClassLoader()
                                        .getResourceAsStream("icons/noresource_16x16.png");
                            }

                            icon = new ImageIcon(ImageIO.read(is));

                        }
                        if (currentItem.getToolTipText() != null) {
                            toolTipText = currentItem.getToolTipText();
                        }
                        if (currentItem.getText() != null) {
                            text = currentItem.getText();
                        }

                        CmdJButton button = new CmdJButton(command);
                        button.putClientProperty("hideActionText", Boolean.TRUE);
                        button.setContentAreaFilled(false);
                        button.setBorderPainted(false);
                        button.setSize(16, 16);
                        button.setAction(command);
                        button.setId("common");
                        button.setFocusable(false);

                        toolbar.add(button);

                    } catch (InstantiationException e) {
                        log.info("could not instanciate menuitem, skipping.");
                    } catch (IllegalAccessException e) {
                        log.info("could not access menuitem, skipping.");
                    }

                }

            } catch (ClassNotFoundException e) {
                log.error("Could not instantiate class " + currentItem.getActionClass() + ". Skipping.");
            }

        }

        ApplicationPerspectiveProvider perspectiveProvider = ctx.getBean(ApplicationPerspectiveProvider.class);
        ArrayList<ApplicationPerspective> perspectives = perspectiveProvider.getPerspectives();

        for (ApplicationPerspective perspective : perspectives) {

            if (perspective.getToolbarContributions() != null) {

                for (ApplicationToolbarItem toolbarItem : perspective.getToolbarContributions()) {

                    if (toolbarItem.getActionClass() != null) {

                        if (toolbarItem.getActionClass().equals("separator")) {
                            toolbar.add(UIUtils.createToolbarSeparator());
                            continue;
                        }

                        log.info("Mapping action class : " + toolbarItem.getActionClass());

                        try {

                            AbstractCommand command = null;
                            Class<?> clazz = Class.forName(toolbarItem.getActionClass());

                            if (toolbarItem.isBean()) {
                                command = (AbstractCommand) ctx.getBean(clazz);
                            } else {
                                command = (AbstractCommand) clazz.newInstance();
                            }
                            ImageIcon icon = null;
                            String toolTipText = null;
                            String text = null;

                            if (toolbarItem.getImageIcon() != null) {
                                InputStream is = getClass().getClassLoader()
                                        .getResourceAsStream(toolbarItem.getImageIcon());
                                icon = new ImageIcon(ImageIO.read(is));
                            }
                            if (toolbarItem.getToolTipText() != null) {
                                toolTipText = toolbarItem.getToolTipText();
                            }
                            if (toolbarItem.getText() != null) {
                                text = toolbarItem.getText();
                            }

                            CmdJButton button = new CmdJButton(command);
                            button.putClientProperty("hideActionText", Boolean.TRUE);
                            button.setContentAreaFilled(false);
                            button.setBorderPainted(false);
                            button.setSize(16, 16);
                            button.setAction(command);
                            button.setId(perspective.getId());
                            button.setFocusable(false);

                            toolbar.add(button);

                        } catch (InstantiationException e) {
                            log.info("could not instanciate menuitem, skipping.");
                        } catch (IllegalAccessException e) {
                            log.info("could not access menuitem, skipping.");
                        } catch (ClassNotFoundException e) {
                            log.info("could not find action class, skipping.");
                        }

                    }

                }

            }

        }

    } catch (JAXBException e) {
        log.error("could not deserialize menus.");
        throw new RuntimeException("could not deserialize menus.");
    } catch (IOException e) {
        log.error("could not load menus, exiting.");
        throw new RuntimeException("could not load menus.");
    }

}

From source file:org.rdv.datapanel.AbstractDataPanel.java

JToolBar createToolBar() {
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);/*from w  w  w .  j a v a  2s .com*/

    final DataPanel dataPanel = this;

    achButton = new ToolBarButton(detachIconFileName, "Detach data panel");
    achButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            toggleDetach();
        }
    });
    toolBar.add(achButton);
    JButton button = new ToolBarButton(closeIconFileName, "Close data panel");
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            dataPanelManager.closeDataPanel(dataPanel);
        }
    });
    toolBar.add(button);

    return toolBar;
}

From source file:org.rdv.ui.ChannelListPanel.java

/**
 * Create the tool bar./*from   www  . j  ava2  s  .c  om*/
 * 
 * @return  the tool bar for the channel list panel
 */
private JToolBar createToolBar() {
    JToolBar channelToolBar = new JToolBar();
    channelToolBar.setFloatable(false);

    JButton button = new ToolBarButton("icons/expandall.gif", "Expand channel list");
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            expandTree();
        }
    });
    channelToolBar.add(button);

    button = new ToolBarButton("icons/collapseall.gif", "Collapse channel list");
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            collapseTree();
        }
    });
    channelToolBar.add(button);

    metadataUpdateButton = new ToolBarButton("icons/refresh.gif", "Update channel list");
    metadataUpdateButton.setEnabled(false);
    metadataUpdateButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            rbnb.updateMetadata();
        }
    });
    channelToolBar.add(metadataUpdateButton);

    return channelToolBar;
}

From source file:org.richie.codeGen.ui.GenAndPreviewUI.java

public JSplitPane getCenterPanel() {
    JToolBar logToolBar = new JToolBar();
    logToolBar.setFloatable(false);/* w w w . ja  v  a 2  s  .  c  om*/
    clearLogBtn = new JButton("");
    clearLogBtn.setIcon(new ImageIcon(ClassLoader.getSystemResource("resources/images/clear.gif")));
    clearLogBtn.addActionListener(this);
    clearLogBtn.addActionListener(this);
    logToolBar.add(clearLogBtn);
    logToolBar.addSeparator();
    JPanel logPanel = new JPanel();
    logPanel.setLayout(new BorderLayout());
    JScrollPane textPanel = new JScrollPane();
    logTextArea = new JTextArea();
    logTextArea.setMinimumSize(new Dimension(1, 1));
    textPanel.setViewportView(logTextArea);
    logPanel.add(logToolBar, BorderLayout.NORTH);
    logPanel.add(textPanel, BorderLayout.CENTER);
    split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, getTemplatePanel(), logPanel);
    split.setContinuousLayout(false);
    split.setOneTouchExpandable(true);
    split.setDividerLocation(400);
    return split;
}