Example usage for javax.swing JToolBar setFloatable

List of usage examples for javax.swing JToolBar setFloatable

Introduction

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

Prototype

@BeanProperty(preferred = true, description = "Can the tool bar be made to float by the user?")
public void setFloatable(boolean b) 

Source Link

Document

Sets the floatable property, which must be true for the user to move the tool bar.

Usage

From source file:io.github.tavernaextras.biocatalogue.ui.filtertree.FilterTreePane.java

/**
 * @return A toolbar that replicates all actions available in the contextual menu of
 *         the filtering tree - mainly: saving current filter, reloading filter tree,
 *         expanding/collapsing and selecting/deselecting everything in the tree.
 *///from www  .  jav a2s . c o m
private JToolBar createTreeActionToolbar() {

    // the actual toolbar - no actions are added to it yet: done in a separate method
    JToolBar tbTreeActions = new JToolBar(JToolBar.HORIZONTAL);
    tbTreeActions.setAlignmentX(RIGHT_ALIGNMENT);
    tbTreeActions.setBorderPainted(true);
    tbTreeActions.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    tbTreeActions.setFloatable(false);
    return (tbTreeActions);
}

From source file:dk.dma.epd.common.prototype.gui.voct.VOCTAdditionalInfoPanel.java

/**
 * Constructor/*from w  w  w.jav  a 2  s  .c o m*/
 * 
 * @param compactLayout
 *            if false, there will be message type selectors in the panel
 */
public VOCTAdditionalInfoPanel(boolean compactLayout) {
    super(new BorderLayout());

    EPD.getInstance().getVoctHandler().addVoctSarInfoListener(this);

    // Prepare the title header
    titleHeader.setBackground(getBackground().darker());
    titleHeader.setOpaque(true);
    titleHeader.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    titleHeader.setHorizontalAlignment(SwingConstants.CENTER);
    add(titleHeader, BorderLayout.NORTH);

    // Add messages panel
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    messagesPanel.setBackground(UIManager.getColor("List.background"));
    messagesPanel.setOpaque(false);
    messagesPanel.setLayout(new GridBagLayout());
    messagesPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(scrollPane, BorderLayout.CENTER);

    JPanel sendPanel = new JPanel(new GridBagLayout());
    add(sendPanel, BorderLayout.SOUTH);
    Insets insets = new Insets(2, 2, 2, 2);

    // Add text area
    // if (false) {
    // messageText = new JTextField();
    // ((JTextField) messageText).addActionListener(this);
    // sendPanel.add(messageText, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));
    //
    // } else {
    messageText = new JTextArea();
    JScrollPane scrollPane2 = new JScrollPane(messageText);
    scrollPane2.setPreferredSize(new Dimension(100, 50));
    scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    sendPanel.add(scrollPane2, new GridBagConstraints(0, 0, 1, 2, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));
    // }

    // Add buttons
    // ButtonGroup group = new ButtonGroup();

    if (!compactLayout) {
        JToolBar msgTypePanel = new JToolBar();
        msgTypePanel.setBorderPainted(false);
        msgTypePanel.setOpaque(true);
        msgTypePanel.setFloatable(false);
        sendPanel.add(msgTypePanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));

    }

    if (compactLayout) {
        addBtn = new JButton("Add to Log");
        sendPanel.add(addBtn, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
    }
    // addBtn.setEnabled(false);
    // messageText.setEditable(false);
    addBtn.addActionListener(this);
}

From source file:com.employee.scheduler.common.swingui.SolverAndPersistenceFrame.java

private JComponent createToolBar() {
    JToolBar toolBar = new JToolBar("File operations");
    toolBar.setFloatable(false);

    importAction = new ImportAction();
    importAction.setEnabled(solutionBusiness.hasImporter());
    toolBar.add(new JButton(importAction));
    openAction = new OpenAction();
    openAction.setEnabled(true);//  www. j av  a 2 s . c o  m
    toolBar.add(new JButton(openAction));
    saveAction = new SaveAction();
    saveAction.setEnabled(false);
    toolBar.add(new JButton(saveAction));
    exportAction = new ExportAction();
    exportAction.setEnabled(false);
    toolBar.add(new JButton(exportAction));
    toolBar.addSeparator();

    progressBar = new JProgressBar(0, 100);
    progressBar.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    toolBar.add(progressBar);
    toolBar.addSeparator();

    solveAction = new SolveAction();
    solveAction.setEnabled(false);
    solveButton = new JButton(solveAction);
    terminateSolvingEarlyAction = new TerminateSolvingEarlyAction();
    terminateSolvingEarlyAction.setEnabled(false);
    terminateSolvingEarlyButton = new JButton(terminateSolvingEarlyAction);
    terminateSolvingEarlyButton.setVisible(false);
    toolBar.add(solveButton, "solveAction");
    toolBar.add(terminateSolvingEarlyButton, "terminateSolvingEarlyAction");
    solveButton.setMinimumSize(terminateSolvingEarlyButton.getMinimumSize());
    solveButton.setPreferredSize(terminateSolvingEarlyButton.getPreferredSize());
    return toolBar;
}

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

private JToolBar createToolBarEdit() {
    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);

    toolbar.addSeparator();/*ww w  .  ja  va2s .c  o  m*/

    toolbar.add(theActionManager.get("arrow"));
    toolbar.add(theActionManager.get("hand"));

    toolbar.addSeparator();

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

    return toolbar;
}

From source file:fxts.stations.ui.help.HelpPane.java

/**
 * Inits all components.// ww w.  j a  v a 2  s.  c o m
 */
private void initComponents() {
    //creates history
    mHistory = new HelpContentHistory();
    //Create the text area for contents
    mTabbedPane = new JTabbedPane();

    //creates content tree
    mContentTree = new ContentTree("fxts/stations/trader/resources/help/contents.xml");
    mContentTree.addListener(this);

    //Create the scroll pane and add the tree to it.
    JScrollPane treeView = new JScrollPane(mContentTree.getTree());
    mTabbedPane.addTab(mResMan.getString("IDS_HELP_CONTENTS", "Contents"), treeView);

    //xxx workaround for bug #6424509, memory leak
    JEditorPane.registerEditorKitForContentType("text/html", WeakHTMLEditorKit.class.getName());
    //creates the text area for the showing of the help.
    mHtmlPage = new JEditorPane();
    mHtmlPage.setEditable(false);
    mHtmlPage.putClientProperty("charset", "UTF-16");
    mHtmlPage.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent aEvent) {
            if (aEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                try {
                    onSelectContentByHyperlink(aEvent.getURL());
                    mHtmlPage.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                } catch (Exception e) {
                    mLogger.error("Hiperlink not processed!");
                    e.printStackTrace();
                }
            }
        }
    });
    JScrollPane scrollPane = new JScrollPane(mHtmlPage);

    //creates a split pane for the change log and the text area.
    mSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mTabbedPane, scrollPane);
    mSplitPane.setOneTouchExpandable(true);

    //Creates the toolbar area.
    JToolBar toolbar = UIManager.getInst().createToolBar();
    toolbar.setFloatable(false);

    //creates label with left arrow
    UIManager uiMan = UIManager.getInst();
    mBackButton = uiMan.createButton(null, "ID_HELP_LEFT_ARROW", "ID_HELP_LEFT_ARROW_DESC",
            "ID_HELP_LEFT_ARROW_DESC");
    mBackButton.setEnabled(false);
    mBackButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent aEvent) {
            if (mHistory.hasBackStep()) {
                mIsHistorycalStep = true;
                onSelectContent(mHistory.back());
                mBackButton.setEnabled(mHistory.hasBackStep());
                mForwardButton.setEnabled(mHistory.hasForwardStep());
            }
        }
    });
    toolbar.add(mBackButton);

    //creates label with right arrow
    mForwardButton = uiMan.createButton(null, "ID_HELP_RIGHT_ARROW", "ID_HELP_RIGHT_ARROW_DESC",
            "ID_HELP_RIGHT_ARROW_DESC");
    mForwardButton.setEnabled(false);
    mForwardButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent aEvent) {
            if (mHistory.hasForwardStep()) {
                mIsHistorycalStep = true;
                onSelectContent(mHistory.forward());
                mBackButton.setEnabled(mHistory.hasBackStep());
                mForwardButton.setEnabled(mHistory.hasForwardStep());
            }
        }
    });
    toolbar.add(mForwardButton);

    //creates label with up arrow
    mUpButton = uiMan.createButton(null, "ID_HELP_UP_ARROW", "ID_HELP_UP_ARROW_DESC", "ID_HELP_UP_ARROW_DESC");
    mUpButton.setEnabled(mContentTree.getIterator().hasPrevious());
    mUpButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent aEvent) {
            mContentsBrowsing = true;
            onSelectContent(mContentTree.getIterator().previous());
            mUpButton.setEnabled(mContentTree.getIterator().hasPrevious());
            mDownButton.setEnabled(mContentTree.getIterator().hasNext());
        }
    });
    toolbar.add(mUpButton);

    //creates label with down arrow
    mDownButton = uiMan.createButton(null, "ID_HELP_DOWN_ARROW", "ID_HELP_DOWN_ARROW_DESC",
            "ID_HELP_DOWN_ARROW_DESC");
    mDownButton.setEnabled(mContentTree.getIterator().hasNext());
    mDownButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent aEvent) {
            mContentsBrowsing = true;
            onSelectContent(mContentTree.getIterator().next());
            mUpButton.setEnabled(mContentTree.getIterator().hasPrevious());
            mDownButton.setEnabled(mContentTree.getIterator().hasNext());
        }
    });
    toolbar.add(mDownButton);

    //sets layout
    setLayout(new BorderLayout());

    //add the components to the frame.
    add(mSplitPane, BorderLayout.CENTER);
    add(toolbar, BorderLayout.NORTH);

    //sets first page
    onSelectContent(mContentTree.getIterator().toBegin());
}

From source file:net.schweerelos.parrot.CombinedParrotApp.java

private void initGUI(Properties properties) {
    try {//from  w  w w.  ja  v  a2 s . co  m
        this.setTitle(APP_TITLE);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                for (MainViewComponent mainViewComponent : mainViews) {
                    if (mainViewComponent instanceof ParrotStateListener) {
                        ((ParrotStateListener) mainViewComponent).parrotExiting();
                    }
                }
            }
        });
        setSize(920, 690);

        getContentPane().setLayout(new BorderLayout());

        UserInterfaceManager uiManager = new UserInterfaceManager(properties);
        navigators = new ArrayList<NavigatorComponent>(4);

        // main view
        listView = uiManager.createMainViewComponent(Style.TABLE);
        graphView = uiManager.createMainViewComponent(Style.GRAPH);
        mainViews.add(listView);
        mainViews.add(graphView);

        final JTabbedPane mainPanel = new JTabbedPane();
        mainPanel.add(graphView.getTitle(), graphView.asJComponent());
        mainPanel.add(listView.getTitle(), listView.asJComponent());

        mainPanel.setSelectedIndex(0);
        activeMainView = graphView;
        mainPanel.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                if (e.getSource() != mainPanel) {
                    return;
                }
                int selectedIndex = mainPanel.getSelectedIndex();
                if (selectedIndex == 0) {
                    activeMainView = graphView;
                } else if (selectedIndex == 1) {
                    activeMainView = listView;
                } else {
                    Logger logger = Logger.getLogger(CombinedParrotApp.class);
                    logger.warn("unknown tab index selected: " + selectedIndex);
                }
            }
        });

        add(mainPanel, BorderLayout.CENTER);

        // navigators
        JToolBar navigatorsBar = new JToolBar(JToolBar.HORIZONTAL);
        navigatorsBar.setMargin(new Insets(0, 11, 0, 0));
        navigatorsBar.setFloatable(false);
        getContentPane().add(navigatorsBar, BorderLayout.PAGE_START);

        // timeline
        NavigatorComponent timelineNavigator = uiManager.createTimelineNavigationComponent();
        navigators.add(timelineNavigator);

        JFrame timelineFrame = new JFrame(timelineNavigator.getNavigatorName() + "  " + APP_TITLE);

        timelineFrame.getContentPane().add(timelineNavigator.asJComponent());
        timelineFrame.pack();
        Point preferredLocation = new Point(0, 0);
        preferredFrameLocations.put(timelineFrame, preferredLocation);

        if (timelineNavigator.hasShowHideListener()) {
            timelineFrame.addComponentListener(timelineNavigator.getShowHideListener());
        }
        timelineFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

        JToggleButton timelineButton = setupNavigatorButton(timelineNavigator.getNavigatorName(),
                timelineNavigator.getAcceleratorKey(), timelineNavigator);
        navigatorsBar.add(timelineButton);

        // map      
        NavigatorComponent mapNavigator = uiManager.createMapNavigationComponent();
        navigators.add(mapNavigator);

        JFrame mapFrame = new JFrame(mapNavigator.getNavigatorName() + "  " + APP_TITLE);

        mapFrame.getContentPane().add(mapNavigator.asJComponent());
        mapFrame.pack();
        preferredLocation = new Point(0,
                Toolkit.getDefaultToolkit().getScreenSize().height - mapFrame.getHeight());
        preferredFrameLocations.put(mapFrame, preferredLocation);

        if (mapNavigator.hasShowHideListener()) {
            mapFrame.addComponentListener(mapNavigator.getShowHideListener());
        }
        mapFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

        JToggleButton mapButton = setupNavigatorButton(mapNavigator.getNavigatorName(),
                mapNavigator.getAcceleratorKey(), mapNavigator);
        navigatorsBar.add(mapButton);

        // search      
        NavigatorComponent searchNavigator = uiManager.createSearchComponent();
        navigators.add(searchNavigator);

        JFrame searchFrame = new JFrame(searchNavigator.getNavigatorName() + "  " + APP_TITLE);

        searchFrame.getContentPane().add(searchNavigator.asJComponent());
        searchFrame.pack();
        preferredLocation = new Point(
                Toolkit.getDefaultToolkit().getScreenSize().width - searchFrame.getWidth(), 0);
        preferredFrameLocations.put(searchFrame, preferredLocation);

        if (searchNavigator.hasShowHideListener()) {
            searchFrame.addComponentListener(searchNavigator.getShowHideListener());
        }
        searchFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

        JToggleButton searchButton = setupNavigatorButton(searchNavigator.getNavigatorName(),
                searchNavigator.getAcceleratorKey(), searchNavigator);
        navigatorsBar.add(searchButton);

        // connections
        NavigatorComponent chainNavigator = uiManager.createChainNavigationComponent();
        navigators.add(chainNavigator);

        if (chainNavigator instanceof PickListener) {
            for (MainViewComponent mainViewComponent : mainViews) {
                mainViewComponent.addPickListener((PickListener) chainNavigator);
            }
        }

        if (chainNavigator.hasShowHideListener()) {
            chainNavigator.asJComponent().addComponentListener(chainNavigator.getShowHideListener());
        }

        JToggleButton connectionsButton = setupNavigatorButton(chainNavigator.getNavigatorName(),
                chainNavigator.getAcceleratorKey(), chainNavigator);
        navigatorsBar.add(connectionsButton);

        add(chainNavigator.asJComponent(), BorderLayout.PAGE_END);
        chainNavigator.asJComponent().setVisible(false);
    } catch (RuntimeException e) {
        e.printStackTrace(System.err);
        System.exit(1);
    } catch (UnknownStyleException e) {
        e.printStackTrace(System.err);
        System.exit(1);
    }
}

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

private JToolBar createToolBarDocument() {
    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);

    toolbar.add(theActionManager.get("last"));
    toolbar.add(theActionManager.get("close"));
    toolbar.add(theActionManager.get("next"));

    toolbar.addSeparator();//w ww .  ja va 2 s  . c  om

    toolbar.add(accunit_button = new JButton(theActionManager.get("accunit=ppm")));
    accunit_button.setText(null);
    toolbar.add(theActionManager.get("new"));

    toolbar.addSeparator();

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

    //toolbar.addSeparator();

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

    return toolbar;
}

From source file:com.mgmtp.jfunk.core.ui.JFunkFrame.java

private void buildToolBar() {
    // Toolbar for the first line
    JToolBar toolBarFirstLine = new JToolBar("Toolbar");
    toolBarFirstLine.setRequestFocusEnabled(false);
    toolBarFirstLine.setFloatable(false);

    toolBarFirstLine.add(fileOpenScriptsAction);
    toolBarFirstLine.add(toolsRunAction);
    toolBarFirstLine.addSeparator();/*from   ww w  . j  ava  2 s.co m*/

    // Build component jFunk property files
    jFunkPropertyFilesModel = new PropertiesComboBoxModel("config", "jfunk", PROPS_SUFFIX, null, true);
    jFunkPropertyFilesComboBox = new JComboBox(jFunkPropertyFilesModel);
    jFunkPropertyFilesComboBox.setBorder(BorderFactory.createTitledBorder("jFunk configuration"));
    // Multi-line tooltip
    jFunkPropertyFilesComboBox
            .setToolTipText("<html>List of jFunk property files containing listener and modules"
                    + "<br>Location: all files in directory 'config'</br></html>");
    toolBarFirstLine.add(jFunkPropertyFilesComboBox);

    // Build component testsystems
    testSystemsModel = new PropertiesComboBoxModel("config/system", null, PROPS_SUFFIX, "baseurl", false);
    testSystemsComboBox = new JComboBox(testSystemsModel);
    testSystemsComboBox.setBorder(BorderFactory.createTitledBorder("Test system"));
    // Multi-line tooltip
    testSystemsComboBox.setToolTipText(
            "<html>List of test systems" + "<br>Defined by all files in directory 'config/system'</br></html>");
    testSystemsComboBox.setSelectedItem(0);
    toolBarFirstLine.add(testSystemsComboBox);

    // Toolbar for the second line
    JToolBar toolBarSecondLine = new JToolBar();
    toolBarSecondLine.setRequestFocusEnabled(false);
    toolBarSecondLine.setFloatable(false);

    // Build component mail configuration
    mailConfigurationsModel = new PropertiesComboBoxModel(PATH_TO_MAIL_CONFIG_FILES, null, PROPS_SUFFIX, null,
            false);
    mailConfigurationsComboBox = new JComboBox(mailConfigurationsModel);
    mailConfigurationsComboBox.setBorder(BorderFactory.createTitledBorder("Mail configuration"));
    // Multi-line tooltip
    mailConfigurationsComboBox.setToolTipText("<html>List of mail configurations"
            + "<br>Defined by all files in directory 'config/email_accounts'</br></html>");
    toolBarSecondLine.add(mailConfigurationsComboBox);

    // Build component thread count
    threadCountComboBox = new JComboBox(createNumberArray(30));
    threadCountComboBox.setBorder(BorderFactory.createTitledBorder("Threads"));
    threadCountComboBox.setToolTipText(
            "Number of threads which will be used for the execution of the selected script files");
    toolBarSecondLine.add(threadCountComboBox);

    // Build component parallel
    parallelComboBox = new JComboBox(new String[] { "yes", "no" });
    parallelComboBox.setSelectedIndex(1);
    parallelComboBox.setBorder(BorderFactory.createTitledBorder("Parallel?"));
    parallelComboBox.setToolTipText("If set to 'yes', a single script will be executed "
            + "multiple times using the specified number of threads");
    toolBarSecondLine.add(parallelComboBox);

    jPanelUtilities = new JPanel();
    jPanelUtilities.setLayout(new BorderLayout());
    jPanelUtilities.add(toolBarFirstLine, BorderLayout.NORTH);
    jPanelUtilities.add(toolBarSecondLine, BorderLayout.CENTER);
}

From source file:aurelienribon.gdxsetupui.ui.panels.LibrarySelectionPanel.java

private void buildLibraryPanel(final String libraryName) {
    ActionListener nameChkAL = new ActionListener() {
        @Override/*from  w  w  w  .  ja v a  2s.  c  om*/
        public void actionPerformed(ActionEvent e) {
            if (((CompactCheckBox) e.getSource()).isSelected()) {
                if (!Ctx.cfgSetup.libraries.contains(libraryName))
                    Ctx.cfgSetup.libraries.add(libraryName);
                if (!Ctx.cfgUpdate.libraries.contains(libraryName))
                    Ctx.cfgUpdate.libraries.add(libraryName);
            } else {
                Ctx.cfgSetup.libraries.remove(libraryName);
                Ctx.cfgUpdate.libraries.remove(libraryName);
            }

            Ctx.fireCfgSetupChanged();
            Ctx.fireCfgUpdateChanged();
        }
    };

    Action infoAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            showInfo(libraryName);
        }
    };
    Action browseAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            browse(libraryName);
        }
    };
    Action getStableAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            getStable(libraryName);
        }
    };
    Action getLatestAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            getLatest(libraryName);
        }
    };

    LibraryDef def = Ctx.libs.getDef(libraryName);

    CompactCheckBox nameChk = new CompactCheckBox(def.name + " ");
    JLabel html5Label = new JLabel(Res.getImage("gfx/ic_html5.png"));
    JButton infoBtn = new JButton(infoAction);
    JButton browseBtn = new JButton(browseAction);
    JButton getStableBtn = new JButton(getStableAction);
    JButton getLatestBtn = new JButton(getLatestAction);

    nameChk.addActionListener(nameChkAL);
    nameChk.setForeground(LIB_NOTFOUND_COLOR);
    html5Label.setToolTipText("Compatible with HTML backend");
    infoBtn.setIcon(Res.getImage("gfx/ic_info.png"));
    browseBtn.setIcon(Res.getImage("gfx/ic_browse.png"));
    getStableBtn.setIcon(Res.getImage("gfx/ic_download_stable.png"));
    getLatestBtn.setIcon(Res.getImage("gfx/ic_download_nightlies.png"));
    infoBtn.setFocusable(false);
    browseBtn.setFocusable(false);
    getStableBtn.setFocusable(false);
    getLatestBtn.setFocusable(false);

    JToolBar toolBar = new JToolBar();
    toolBar.setOpaque(false);
    toolBar.setFloatable(false);
    toolBar.add(Box.createHorizontalGlue());
    toolBar.add(infoBtn);
    toolBar.add(browseBtn);
    if (def.stableUrl != null)
        toolBar.add(getStableBtn);
    else
        toolBar.add(Box.createHorizontalStrut(libgdxGetStableBtn.getPreferredSize().width));
    if (def.latestUrl != null)
        toolBar.add(getLatestBtn);
    else
        toolBar.add(Box.createHorizontalStrut(libgdxGetNightliesBtn.getPreferredSize().width));

    JPanel leftPanel = new JPanel(new BorderLayout());
    leftPanel.setOpaque(false);
    leftPanel.add(nameChk, BorderLayout.CENTER);
    if (def.gwtModuleName != null)
        leftPanel.add(html5Label, BorderLayout.EAST);

    JPanel panel = new JPanel(new BorderLayout());
    panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25));
    panel.setOpaque(false);
    panel.add(leftPanel, BorderLayout.WEST);
    panel.add(toolBar, BorderLayout.CENTER);

    librariesPanel.add(panel);

    Style.apply(librariesPanel, style);
    libsNamesCmps.put(libraryName, nameChk);
}

From source file:ec.util.chart.swing.JTimeSeriesRendererSupportDemo.java

private Component createToolBar() {
    JToolBar result = new JToolBar();
    result.setFloatable(false);

    result.add(RANDOM_DATA.toAction(chart)).setIcon(FontAwesome.FA_RANDOM.getIcon(getForeground(), 16f));

    JComboBox<RendererType> types = new JComboBox<>(
            support.getSupportedRendererTypes().toArray(new RendererType[0]));
    types.setMaximumSize(new Dimension(150, 100));
    types.addItemListener(new ItemListener() {
        @Override/*from  w w  w  .ja v  a 2 s. c  o m*/
        public void itemStateChanged(ItemEvent e) {
            RendererType type = (RendererType) e.getItem();
            chart.getXYPlot().setRenderer(support.createRenderer(type));
            chart.getXYPlot().setBackgroundPaint(support.getPlotColor());
            chart.setBackgroundPaint(colorSchemeSupport.getBackColor());
        }
    });
    types.setSelectedIndex(1);
    result.add(types);

    return result;
}