Example usage for javax.swing JToolBar add

List of usage examples for javax.swing JToolBar add

Introduction

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

Prototype

public JButton add(Action a) 

Source Link

Document

Adds a new JButton which dispatches the action.

Usage

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

private JComponent createPaletteToolBar() {
    final JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);/*from   ww w.j a  v a  2s. 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.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./*w  w  w.  j  av  a2  s.c om*/
 */
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.
 *//*ww w .  j  a  va2s. 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.rdv.datapanel.AbstractDataPanel.java

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

    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   w  w w. j  ava 2  s .  c o m
 * 
 * @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);/*from  w w w .ja  v  a2s .c o  m*/
    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;
}

From source file:org.rimudb.editor.RimuDBEditor.java

/**
 * Create and return a toolbar.//from w  ww . j  a va2 s. c om
 */
protected JToolBar createToolbar() {
    log.debug("createToolbar()");
    JToolBar toolbar = new JToolBar();

    // Open
    openBtn = new ToolbarButton(new OpenDescriptorAction(this, loadIcon("/images/famfamfam/folder.png")),
            "Open Table Descriptor");
    openBtn.setText("Open");
    openBtn.setName("openBtn");
    toolbar.add(openBtn);

    // Save
    saveBtn = new ToolbarButton(new SaveDescriptorAction(this, loadIcon("/images/famfamfam/disk.png")),
            "Save Table Descriptor");
    saveBtn.setText("Save");
    saveBtn.setName("saveBtn");
    toolbar.add(saveBtn);

    // A space
    //      toolbar.add(Box.createHorizontalStrut(5));

    // Clear
    clearBtn = new ToolbarButton(new ClearTableAction(this, loadIcon("/images/famfamfam/bin_closed.png")),
            "Clear");
    clearBtn.setText("Clear");
    clearBtn.setName("clearBtn");
    toolbar.add(clearBtn);

    // Save as
    //      saveAsBtn = new ToolbarButton(new SaveAsDescriptorAction(this, loadIcon("/images/sun/SaveAs24.gif")), "Save Table Descriptor as");
    //      saveAsBtn.setName("saveAsBtn");
    //      toolbar.add(saveAsBtn);

    // A space
    toolbar.addSeparator();

    // Import from a database
    importBtn = new ToolbarButton(new ImportAction(this, loadIcon("/images/famfamfam/database_go.png")),
            "Import from database");
    importBtn.setText("Import");
    importBtn.setName("importBtn");
    importBtn.setEnabled(false);
    toolbar.add(importBtn);

    // A space
    toolbar.add(Box.createHorizontalStrut(5));

    // Create classes
    createBtn = new ToolbarButton(
            new GenerateJavaAction(this, loadIcon("/images/famfamfam/page_white_cup.png")), "Create classes");
    createBtn.setText("Create");
    createBtn.setName("createBtn");
    toolbar.add(createBtn);

    // Finish up the tool bar
    toolbar.add(Box.createHorizontalGlue());
    toolbar.setFloatable(false);

    return toolbar;
}

From source file:org.rivalry.swingui.RivalryUI.java

/**
 * @return a new tool bar./*from  ww w  .  j a v  a  2 s . c o  m*/
 */
private JToolBar createToolBar() {
    final JButton openButton = createButton("Open24.gif", "Open a rivalry data file", "Open...",
            createOpenActionListener());

    final JButton bestPlaceButton = createButton("PalmTree24.png", "Load best place data", "Best Places",
            createBestPlaceActionListener());
    final JButton boardgameButton = createButton("Boardgame24.png", "Load board game data", "Boardgames",
            createBoardgameActionListener());
    final JButton dogButton = createButton("Dog24.png", "Load dog breed data", "Dog Breeds",
            createDogBreedActionListener());
    final JButton mysteryAwardButton = createButton("MysteryBook24.png", "Load mystery book award data",
            "Mystery Book Awards", createMysteryAwardActionListener());
    final JButton skillDemandButton = createButton("Brain24.png", "Load skill demand data", "Skill Demand",
            createSkillDemandActionListener());
    final JButton stockButton = createButton("Money24.png", "Load stock data", "Stocks",
            createStockActionListener());

    final JButton aboutButton = createButton("About24.gif", "View information about this application.", "About",
            createAboutActionListener());

    final JToolBar answer = new JToolBar("Rivalry Tool Bar");

    answer.add(openButton);
    answer.addSeparator();
    answer.add(bestPlaceButton);
    answer.add(boardgameButton);
    answer.add(dogButton);
    answer.add(mysteryAwardButton);
    answer.add(skillDemandButton);
    answer.add(stockButton);
    answer.addSeparator();
    answer.add(aboutButton);

    return answer;
}

From source file:org.sikuli.ide.SikuliIDE.java

private JToolBar initCmdToolbar() {
    JToolBar toolbar = new JToolBar(JToolBar.VERTICAL);
    toolbar.add(createCommandPane());
    return toolbar;
}

From source file:org.sikuli.ide.SikuliIDE.java

private JToolBar initToolbar() {
    if (ENABLE_UNIFIED_TOOLBAR) {
        MacUtils.makeWindowLeopardStyle(this.getRootPane());
    }//  w w  w . j av  a  2s  .c  o  m

    JToolBar toolbar = new JToolBar();
    JButton btnInsertImage = new ButtonInsertImage();
    _btnCapture = new ButtonCapture();
    JButton btnSubregion = new ButtonSubregion();
    toolbar.add(_btnCapture);
    toolbar.add(btnInsertImage);
    toolbar.add(btnSubregion);
    toolbar.add(Box.createHorizontalGlue());
    _btnRun = new ButtonRun();
    toolbar.add(_btnRun);
    _btnRunViz = new ButtonRunViz();
    toolbar.add(_btnRunViz);
    toolbar.add(Box.createHorizontalGlue());

    //TODO get it working for OSX 10.10
    if (!Settings.isMac10()) {
        toolbar.add(createSearchField());
    }

    toolbar.add(Box.createRigidArea(new Dimension(7, 0)));
    toolbar.setFloatable(false);
    //toolbar.setMargin(new Insets(0, 0, 0, 5));
    return toolbar;
}