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:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JToolBar toolBar = new JToolBar("Still draggable");

    toolBar.setFloatable(false);
    toolBar.setRollover(true);//from   ww w  . j  a  va2 s . com

    toolBar.add(new JButton("New"));
    toolBar.addSeparator();
    toolBar.add(new JButton("Open"));

    frame.add(toolBar, "North");

    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:BorderLayoutExample.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    JMenuBar menubar = new JMenuBar();
    JMenu file = new JMenu("File");

    menubar.add(file);/*from   ww w . j  a  v a2s  . c  o m*/
    f.setJMenuBar(menubar);

    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);

    JButton bexit = new JButton(new ImageIcon("exit.png"));
    bexit.setBorder(new EmptyBorder(0, 0, 0, 0));
    toolbar.add(bexit);

    f.add(toolbar, BorderLayout.NORTH);

    JToolBar vertical = new JToolBar(JToolBar.VERTICAL);
    vertical.setFloatable(false);
    vertical.setMargin(new Insets(10, 5, 5, 5));

    JButton selectb = new JButton(new ImageIcon("a.png"));
    selectb.setBorder(new EmptyBorder(3, 0, 3, 0));

    JButton freehandb = new JButton(new ImageIcon("b.png"));
    freehandb.setBorder(new EmptyBorder(3, 0, 3, 0));
    JButton shapeedb = new JButton(new ImageIcon("c.png"));
    shapeedb.setBorder(new EmptyBorder(3, 0, 3, 0));

    vertical.add(selectb);
    vertical.add(freehandb);
    vertical.add(shapeedb);

    f.add(vertical, BorderLayout.WEST);
    f.add(new JTextArea(), BorderLayout.CENTER);

    JLabel statusbar = new JLabel(" Statusbar");
    statusbar.setPreferredSize(new Dimension(-1, 22));
    statusbar.setBorder(LineBorder.createGrayLineBorder());
    f.add(statusbar, BorderLayout.SOUTH);
    f.setSize(350, 300);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    // Create a horizontal toolbar
    JToolBar toolbar = new JToolBar();

    // Get current floatability
    boolean b = toolbar.isFloatable();

    // Disable floatability
    toolbar.setFloatable(false);
}

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

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

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

    toolbar.addSeparator();/*from w ww.  j av  a2  s .co m*/

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

    return toolbar;
}

From source file:components.ToolBarDemo2.java

public ToolBarDemo2() {
    super(new BorderLayout());

    //Create the toolbar.
    JToolBar toolBar = new JToolBar("Still draggable");
    addButtons(toolBar);//from  ww  w . j a  v a 2 s.c  om
    toolBar.setFloatable(false);
    toolBar.setRollover(true);

    //Create the text area used for output.  Request
    //enough space for 5 rows and 30 columns.
    textArea = new JTextArea(5, 30);
    textArea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(textArea);

    //Lay out the main panel.
    setPreferredSize(new Dimension(450, 130));
    add(toolBar, BorderLayout.PAGE_START);
    add(scrollPane, BorderLayout.CENTER);
}

From source file:net.nosleep.superanalyzer.panels.HomePanel.java

public JPanel createRightButtonBarPanel(final PieRotator rotator) {
    URL url = this.getClass().getResource("/media/" + "ButtonPlay.png");
    final ImageIcon playIcon = new ImageIcon(Toolkit.getDefaultToolkit().getImage(url));
    url = this.getClass().getResource("/media/" + "ButtonPause.png");
    final ImageIcon pauseIcon = new ImageIcon(Toolkit.getDefaultToolkit().getImage(url));
    final JButton button = new JButton(playIcon);
    button.setBorder(null);//from ww w.  j a v a  2 s. c o  m
    button.setBorderPainted(false);
    button.setText(null);
    button.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            if (rotator.isRunning() == false) {
                rotator.start();
                button.setIcon(pauseIcon);
            } else {
                rotator.stop();
                button.setIcon(playIcon);
            }
        }
    });

    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    toolBar.setBackground(Color.white);
    toolBar.add(button);

    JPanel barPanel = new JPanel(new BorderLayout());
    barPanel.setBackground(Color.white);
    barPanel.add(toolBar, BorderLayout.SOUTH);

    return barPanel;
}

From source file:ToolBarDemo2.java

public ToolBarDemo2() {
    super(new BorderLayout());

    //Create the toolbar.
    JToolBar toolBar = new JToolBar("Still draggable");
    addButtons(toolBar);//from w w  w  .  java2 s . com
    toolBar.setFloatable(false);
    toolBar.setRollover(true);

    //Create the text area used for output. Request
    //enough space for 5 rows and 30 columns.
    textArea = new JTextArea(5, 30);
    textArea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(textArea);

    //Lay out the main panel.
    setPreferredSize(new Dimension(450, 130));
    add(toolBar, BorderLayout.PAGE_START);
    add(scrollPane, BorderLayout.CENTER);
}

From source file:com.opendoorlogistics.studio.scripts.list.ScriptsPanel.java

/**
 * Create the panel./*from   ww w.ja  va 2 s  . c o m*/
 */
public ScriptsPanel(ODLApi api, File directory, ScriptUIManager launchScriptEditor) {
    this.scriptUIManager = launchScriptEditor;
    this.api = api;

    // find a sensible directory
    if (directory == null) {
        directory = new File(ScriptConstants.DIRECTORY);
        if (!directory.exists()) {
            directory = new File("");
        }
    }
    this.directory = directory;
    setLayout(new BorderLayout(0, 0));

    // Add directory browser and label at the top in their own panel.
    // Label is wrapped in a panel because alignment is being ignored and this at least makes it properly centred.
    // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4275005
    boolean lockedDir = scriptUIManager.getAppPermissions().isScriptDirectoryLocked();
    if (!lockedDir) {
        JLabel lblLabel = new JLabel("Scripts directory");
        JPanel labelPanel = new JPanel(new BorderLayout());
        labelPanel.add(lblLabel, BorderLayout.CENTER);
        labelPanel.setMaximumSize(lblLabel.getMinimumSize());
        dirChooser = new FileBrowserPanel(directory.getAbsolutePath(), new FilenameChangeListener() {

            @Override
            public void filenameChanged(String newFilename) {
                ScriptsPanel.this.directory = new File(newFilename);
                onDirectoryChanged(ScriptsPanel.this.directory);
            }
        }, true, "Select");
        JPanel topPanel = LayoutUtils.createVerticalBoxLayout(labelPanel, dirChooser);
        add(topPanel, BorderLayout.NORTH);
    } else {
        dirChooser = null;
    }

    // add toolbar at the bottom
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    add(toolBar, BorderLayout.SOUTH);

    // create all actions and add as buttons and menu items
    popup = new JPopupMenu();
    actions = createActions(launchScriptEditor.getAppPermissions());
    for (Action action : actions) {
        toolBar.add(action);
        popup.add(action);
    }

    // add list in the centre
    scriptsTree = new ScriptsTree(scriptUIManager, popup);
    scriptsTree.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            ScriptsPanel.this.updateAppearance();
        }
    });
    add(scriptsTree.getScrollPane(), BorderLayout.CENTER);

    // // create selection changed listener on the list
    // listControl.addListSelectionListener(new ListSelectionListener() {
    //
    // @Override
    // public void valueChanged(ListSelectionEvent e) {
    // updateAppearance();
    // }
    // });

    // finally file the list
    onDirectoryChanged(directory);

}

From source file:net.sf.jabref.gui.search.SearchBar.java

/**
 * Initializes the search bar.//from ww w .  j ava2s.  co m
 *
 * @param basePanel the base panel
 */
public SearchBar(BasePanel basePanel) {
    super();

    this.basePanel = Objects.requireNonNull(basePanel);
    this.searchQueryHighlightObservable = new SearchQueryHighlightObservable();

    currentResults.setFont(currentResults.getFont().deriveFont(Font.BOLD));

    caseSensitive = new JToggleButton(IconTheme.JabRefIcon.CASE_SENSITIVE.getSmallIcon(),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_CASE_SENSITIVE));
    caseSensitive.setToolTipText(Localization.lang("Case sensitive"));
    caseSensitive.addActionListener(e -> {
        performSearch();
        updatePreferences();
    });

    regularExp = new JToggleButton(IconTheme.JabRefIcon.REG_EX.getSmallIcon(),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_REG_EXP));
    regularExp.setToolTipText(Localization.lang("regular expression"));
    regularExp.addActionListener(e -> {
        performSearch();
        updatePreferences();
    });

    openCurrentResultsInDialog = new JButton(IconTheme.JabRefIcon.OPEN_IN_NEW_WINDOW.getSmallIcon());
    openCurrentResultsInDialog.setToolTipText(Localization.lang("Show search results in a window"));
    openCurrentResultsInDialog.addActionListener(ae -> {
        SearchResultsDialog searchDialog = new SearchResultsDialog(basePanel.frame(),
                Localization.lang("Search results in database %0 for %1",
                        basePanel.getBibDatabaseContext().getDatabaseFile().getName(),
                        this.getSearchQuery().localize()));
        List<BibEntry> entries = basePanel.getDatabase().getEntries().stream().filter(BibEntry::isSearchHit)
                .collect(Collectors.toList());
        searchDialog.addEntries(entries, basePanel);
        searchDialog.selectFirstEntry();
        searchDialog.setVisible(true);
    });
    openCurrentResultsInDialog.setEnabled(false);

    // Init controls
    setLayout(new WrapLayout(FlowLayout.LEFT));

    searchIcon = new JLabel(IconTheme.JabRefIcon.SEARCH.getSmallIcon());
    this.add(searchIcon);
    initSearchField();
    if (OS.OS_X) {
        searchField.putClientProperty("JTextField.variant", "search");
    }
    this.add(searchField);

    JButton clearSearchButton = new JButton(IconTheme.JabRefIcon.CLOSE.getSmallIcon());
    clearSearchButton.setToolTipText(Localization.lang("Clear"));
    clearSearchButton.addActionListener(l -> endSearch());

    this.add(clearSearchButton);

    searchModeButton = new JButton();
    updateSearchModeButtonText();
    searchModeButton.addActionListener(l -> toggleSearchModeAndSearch());

    JToolBar toolBar = new OSXCompatibleToolbar();
    toolBar.setFloatable(false);
    toolBar.add(clearSearchButton);
    toolBar.addSeparator();
    toolBar.add(regularExp);
    toolBar.add(caseSensitive);
    toolBar.addSeparator();
    toolBar.add(searchModeButton);
    toolBar.addSeparator();
    toolBar.add(openCurrentResultsInDialog);
    globalSearch = new JButton(Localization.lang("Search globally"));
    globalSearch.setToolTipText(Localization.lang("Search in all open databases"));
    globalSearch.addActionListener(l -> {
        AbstractWorker worker = new GlobalSearchWorker(basePanel.frame(), getSearchQuery());
        worker.run();
        worker.update();
    });
    globalSearch.setEnabled(false);
    toolBar.add(globalSearch);
    toolBar.addSeparator();
    toolBar.add(new HelpAction(HelpFile.SEARCH));

    this.add(toolBar);
    this.add(currentResults);

    paintBackgroundWhite(this);
}

From source file:net.sf.jabref.gui.PreviewPanel.java

private JToolBar createToolBar() {
    JToolBar toolBar = new OSXCompatibleToolbar(SwingConstants.VERTICAL);
    toolBar.setMargin(new Insets(0, 0, 0, 2));
    toolBar.setFloatable(false);

    // Add actions (and thus buttons)
    toolBar.add(this.closeAction);
    toolBar.addSeparator();/*from  w  w w .  jav a  2  s. co  m*/
    toolBar.add(this.copyPreviewAction);
    toolBar.addSeparator();
    toolBar.add(this.printAction);

    Component[] comps = toolBar.getComponents();

    for (Component comp : comps) {
        ((JComponent) comp).setOpaque(false);
    }

    return toolBar;
}