List of usage examples for javax.swing JToolBar add
public JButton add(Action a)
JButton
which dispatches the action. From source file:de.tbuchloh.kiskis.gui.MainFramePanel.java
protected static void addActions(final JToolBar fileMenu, final Action[] actions) { for (int i = 0; i < actions.length; ++i) { if (actions[i] == null) { fileMenu.addSeparator();/* w w w. j a v a 2 s . c o m*/ } else { fileMenu.add(actions[i]); } } }
From source file:net.sf.jabref.gui.search.SearchBar.java
/** * Initializes the search bar.//from w w w . j a v a 2 s . com * * @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:com.emental.mindraider.ui.outline.OutlineArchiveJPanel.java
public OutlineArchiveJPanel() { setLayout(new BorderLayout()); // table with archived concepts (title) // let table model to load discarded concepts itself tableModel = new ArchiveTableModel(this); table = new JTable(tableModel); table.setAutoCreateRowSorter(true);/*from w ww. j a v a2s .co m*/ JScrollPane scroll = new JScrollPane(table); table.setFillsViewportHeight(true); table.setShowHorizontalLines(false); table.setShowVerticalLines(false); table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); JToolBar toolbar = new JToolBar(); undoButton = new JButton("", IconsRegistry.getImageIcon("trashUndo.png")); undoButton.setEnabled(false); undoButton.setToolTipText("Restore Note"); undoButton.addActionListener(new UndiscardConceptActionListener(tableModel, table)); toolbar.add(undoButton); deleteButton = new JButton("", IconsRegistry.getImageIcon("explorerDeleteSmall.png")); deleteButton.setEnabled(true); deleteButton.setToolTipText("Delete Note"); deleteButton.addActionListener(new DeleteConceptActionListener(tableModel, table)); toolbar.add(deleteButton); purgeButton = new JButton("", IconsRegistry.getImageIcon("trashFull.png")); purgeButton.setEnabled(true); purgeButton.setToolTipText("Empty Notes Archive"); purgeButton.addActionListener(new EmptyArchiveActionListener()); toolbar.add(purgeButton); add(toolbar, BorderLayout.NORTH); add(scroll, BorderLayout.CENTER); }
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);/*from w ww . ja v a 2 s . co m*/ // Add actions (and thus buttons) toolBar.add(this.closeAction); toolBar.addSeparator(); toolBar.add(this.copyPreviewAction); toolBar.addSeparator(); toolBar.add(this.printAction); Component[] comps = toolBar.getComponents(); for (Component comp : comps) { ((JComponent) comp).setOpaque(false); } return toolBar; }
From source file:fi.smaa.jsmaa.gui.SMAATRIGUIFactory.java
@Override protected JToolBar buildTopToolBar() { JToolBar bar = super.buildTopToolBar(); JButton addCatButton = new JButton(ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_ADD)); addCatButton.setToolTipText("Add category"); addCatButton.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent e) { addCategory();/* w w w .j a v a2s . c o m*/ } }); bar.add(addCatButton); return bar; }
From source file:livecanvas.mesheditor.MeshEditor.java
private JToolBar createToolBar() { JToolBar toolbar = new JToolBar(); JButton button;//from w w w . j av a 2s . co m toolbar.add(Utils.createToolBarButton("New mesh", new ImageIcon(clazz.getResource("res/new.png")), ButtonType.ICON_ONLY, NEW, "New", this)); toolbar.add(Utils.createToolBarButton("Open", new ImageIcon(clazz.getResource("res/open.png")), ButtonType.ICON_ONLY, OPEN, "Open a saved mesh", this)); toolbar.add(Utils.createToolBarButton("Save", new ImageIcon(clazz.getResource("res/save.png")), ButtonType.ICON_ONLY, SAVE, "Save mesh", this)); toolbar.addSeparator(); toolbar.add(Utils.createToolBarButton("Cut", new ImageIcon(clazz.getResource("res/cut.png")), ButtonType.ICON_ONLY, CUT, "Cut selection to clipboard", this)); toolbar.add(Utils.createToolBarButton("Copy", new ImageIcon(clazz.getResource("res/copy.png")), ButtonType.ICON_ONLY, COPY, "Copy selection to clipboard", this)); toolbar.add(Utils.createToolBarButton("Paste", new ImageIcon(clazz.getResource("res/paste.png")), ButtonType.ICON_ONLY, PASTE, "Paste content from clipboard", this)); toolbar.addSeparator(); toolbar.add(Utils.createToolBarButton("Undo", new ImageIcon(clazz.getResource("res/undo.png")), ButtonType.ICON_ONLY, UNDO, "Undo last action", this)); toolbar.add(Utils.createToolBarButton("Redo", new ImageIcon(clazz.getResource("res/redo.png")), ButtonType.ICON_ONLY, REDO, "Redo last undone action", this)); toolbar.addSeparator(); JPanel rendererSelectContainer = new JPanel(); rendererSelectContainer.setOpaque(false); rendererSelectContainer.setMaximumSize(new Dimension(150, 40)); rendererSelectContainer.add(rendererSelect = new JComboBox(Style.Styles)); rendererSelect.setSelectedIndex(Style.Styles.length - 1); toolbar.add(rendererSelectContainer); toolbar.add(Utils.createToolBarButton("Render Settings", new ImageIcon(clazz.getResource("res/render_settings.png")), ButtonType.ICON_ONLY, RENDER_SETTINGS, "Render Settings", this)); toolbar.add(Utils.createToolBarButton("Render", new ImageIcon(clazz.getResource("res/render.png")), ButtonType.ICON_ONLY, RENDER, "Render mesh using current style", this)); return toolbar; }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.PeakAnnotationCalibrationPanel.java
private JToolBar createToolBarDocument() { JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false);// w w w . j ava2 s .c om toolbar.add(theActionManager.get("last")); toolbar.add(theActionManager.get("close")); toolbar.add(theActionManager.get("next")); toolbar.addSeparator(); 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:aurelienribon.gdxsetupui.ui.panels.LibrarySelectionPanel.java
private void buildLibraryPanel(final String libraryName) { ActionListener nameChkAL = new ActionListener() { @Override/*from ww w . j ava2 s . 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: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();//w ww . j a v a2 s. c om // 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:org.eurocarbdb.application.glycoworkbench.plugin.PeakAnnotationCalibrationPanel.java
private JToolBar createToolBarEdit() { JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false);//w w w. ja va 2s . co m toolbar.addSeparator(); 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; }