List of usage examples for javax.swing JToolBar setFloatable
@BeanProperty(preferred = true, description = "Can the tool bar be made to float by the user?") public void setFloatable(boolean b)
floatable
property, which must be true
for the user to move the tool bar. From source file:org.geopublishing.atlasStyler.swing.AtlasStylerGUI.java
/** * This method initializes jToolBar//from ww w . j a v a 2 s .co m * * @return javax.swing.JToolBar */ private JToolBar getJToolBar() { JToolBar jToolBar = new JToolBar(); jToolBar.setFloatable(false); AbstractAction importWiazrdAction = new AbstractAction( AtlasStylerVector.R("MenuBar.FileMenu.ImportWizard")) { @Override public void actionPerformed(ActionEvent e) { ImportWizard.showWizard(AtlasStylerGUI.this, AtlasStylerGUI.this); } }; importWiazrdAction.putValue(Action.LONG_DESCRIPTION, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.CTRL_MASK, true)); jToolBar.add(importWiazrdAction); jToolBar.add(getJTButtonShowXML()); jToolBar.add(getJTButtonExportAsSLD()); return jToolBar; }
From source file:org.jab.docsearch.DocSearch.java
private JToolBar createToolBar() { // tool bar// ww w . j a v a 2s . co m JToolBar toolBar = new JToolBar(); // file open JButton buttonOpen = new JButton(new ImageIcon(getClass().getResource("/icons/fileopen.png"))); buttonOpen.setToolTipText(I18n.getString("tooltip.open")); buttonOpen.setActionCommand("ac_open"); buttonOpen.addActionListener(this); buttonOpen.setMnemonic(KeyEvent.VK_O); buttonOpen.setEnabled(!env.isWebStart()); // disable in WebStart toolBar.add(buttonOpen); // file save JButton buttonSave = new JButton(new ImageIcon(getClass().getResource("/icons/filesave.png"))); buttonSave.setToolTipText(I18n.getString("tooltip.save")); buttonSave.setActionCommand("ac_save"); buttonSave.addActionListener(this); buttonSave.setMnemonic(KeyEvent.VK_S); buttonSave.setEnabled(!env.isWebStart()); // disable in WebStart toolBar.add(buttonSave); toolBar.addSeparator(); // open browser JButton buttonBrowser = new JButton(new ImageIcon(getClass().getResource("/icons/html.png"))); buttonBrowser.setToolTipText(I18n.getString("tooltip.open_in_browser")); buttonBrowser.setActionCommand("ac_openinbrowser"); buttonBrowser.addActionListener(this); buttonBrowser.setMnemonic(KeyEvent.VK_E); buttonBrowser.setEnabled(!env.isWebStart()); // disable in WebStart toolBar.add(buttonBrowser); toolBar.addSeparator(); // home JButton buttonHome = new JButton(new ImageIcon(getClass().getResource("/icons/home.png"))); buttonHome.setToolTipText(I18n.getString("tooltip.home")); buttonHome.setActionCommand("ac_home"); buttonHome.addActionListener(this); buttonHome.setMnemonic(KeyEvent.VK_H); toolBar.add(buttonHome); // refresh JButton buttonRefresh = new JButton(new ImageIcon(getClass().getResource("/icons/refresh.png"))); buttonRefresh.setToolTipText(I18n.getString("tooltip.refresh")); buttonRefresh.setActionCommand("ac_refresh"); buttonRefresh.addActionListener(this); buttonRefresh.setMnemonic(KeyEvent.VK_L); toolBar.add(buttonRefresh); toolBar.addSeparator(); // result JButton buttonResult = new JButton(new ImageIcon(getClass().getResource("/icons/search_results.png"))); buttonResult.setToolTipText(I18n.getString("tooltip.results")); buttonResult.setActionCommand("ac_result"); buttonResult.addActionListener(this); buttonResult.setMnemonic(KeyEvent.VK_R); toolBar.add(buttonResult); toolBar.addSeparator(); // bookmark JButton buttonBookMark = new JButton(new ImageIcon(getClass().getResource("/icons/bookmark.png"))); buttonBookMark.setToolTipText(I18n.getString("tooltip.add_bookmark")); buttonBookMark.setActionCommand("ac_addbookmark"); buttonBookMark.addActionListener(this); buttonBookMark.setMnemonic(KeyEvent.VK_M); toolBar.add(buttonBookMark); toolBar.addSeparator(); // print JButton buttonPrint = new JButton(new ImageIcon(getClass().getResource("/icons/fileprint.png"))); buttonPrint.setToolTipText(I18n.getString("tooltip.print")); buttonPrint.setActionCommand("ac_print"); buttonPrint.addActionListener(this); buttonPrint.setMnemonic(KeyEvent.VK_P); toolBar.add(buttonPrint); toolBar.addSeparator(); // setting JButton buttonSetting = new JButton(new ImageIcon(getClass().getResource("/icons/configure.png"))); buttonSetting.setToolTipText(I18n.getString("tooltip.settings")); buttonSetting.setActionCommand("ac_settings"); buttonSetting.addActionListener(this); buttonSetting.setMnemonic(KeyEvent.VK_HOME); toolBar.add(buttonSetting); toolBar.addSeparator(); // stop buttonStop = new JButton(new ImageIcon(getClass().getResource("/icons/stop.png"))); buttonStop.setToolTipText(I18n.getString("tooltip.stop")); buttonStop.setActionCommand("ac_stop"); buttonStop.addActionListener(this); buttonStop.setMnemonic(KeyEvent.VK_X); toolBar.add(buttonStop); toolBar.addSeparator(); // toolBar.setFloatable(false); // finished return toolBar; }
From source file:org.jcurl.demo.tactics.JCurlShotPlanner.java
private JComponent createToolBar() { final String[] toolbarActionNames = { "cut", "copy", "paste" }; final JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); for (final String actionName : toolbarActionNames) { final JButton button = new JButton(); button.setAction(gui.findAction(actionName)); button.setFocusable(false);//www. j a v a2 s . com toolBar.add(button); } return toolBar; }
From source file:org.kuali.test.creator.TestCreator.java
private JPanel createToolBar() { JPanel retval = new JPanel(new BorderLayout(2, 2)); JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false); toolbar.setMargin(new Insets(1, 5, 2, 0)); ToolbarButton b;/* w w w . j a v a 2 s . c o m*/ toolbar.add(b = new ToolbarButton(Constants.PLATFORM_TOOLBAR_ICON, "add platform")); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleAddPlatform(e); } }); toolbar.add(b = new ToolbarButton(Constants.DATABASE_TOOLBAR_ICON, "add database connection")); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleAddDatabaseConnection(e); } }); toolbar.add(b = new ToolbarButton(Constants.JMX_CONNECTION_TOOLBAR_ICON, "add JMX connection")); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleAddJmxConnection(e); } }); toolbar.add(b = new ToolbarButton(Constants.WEB_SERVICE_TOOLBAR_ICON, "add web service")); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleAddWebService(e); } }); toolbar.add(b = new ToolbarButton(Constants.SCHEDULE_TEST_TOOLBAR_ICON, "schedule test")); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleScheduleTests(e); } }); toolbar.addSeparator(); toolbar.add(saveConfigurationButton = new ToolbarButton(Constants.SAVE_CONFIGURATION_ICON, "save repository configuration") { @Override public void setEnabled(boolean enabled) { if (enabled) { getConfiguration().setModified(true); } super.setEnabled(enabled); } }); saveConfigurationButton.setEnabled(false); saveConfigurationButton.setMargin(new Insets(1, 1, 1, 1)); saveConfigurationButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { handleSaveConfiguration(); } }); toolbar.add(createTestButton = new ToolbarButton(Constants.TEST_ICON, "create new test")); createTestButton.setMargin(new Insets(1, 1, 1, 1)); createTestButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { handleCreateTest(null); } }); toolbar.addSeparator(); toolbar.add( exitApplication = new ToolbarButton(Constants.EXIT_APPLICATION_TOOLBAR_ICON, "exit application")); exitApplication.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(TestCreator.this, "Exit Test Application?", "Exit", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { startSpinner("Shutting down application..."); handleExit(0); } } }); toolbar.addSeparator(); toolbar.add(spinner = new Spinner()); toolbar.add(spinner2 = new Spinner(true)); retval.add(new JSeparator(), BorderLayout.NORTH); retval.add(toolbar, BorderLayout.CENTER); this.enableCreateTestActions(havePlatforms()); return retval; }
From source file:org.languagetool.gui.Main.java
private void createGUI() { loadRecentFiles();//ww w. j av a 2s. co m frame = new JFrame("LanguageTool " + JLanguageTool.VERSION); setLookAndFeel(); openAction = new OpenAction(); saveAction = new SaveAction(); saveAsAction = new SaveAsAction(); checkAction = new CheckAction(); autoCheckAction = new AutoCheckAction(true); showResultAction = new ShowResultAction(true); frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new CloseListener()); URL iconUrl = JLanguageTool.getDataBroker().getFromResourceDirAsUrl(TRAY_ICON); frame.setIconImage(new ImageIcon(iconUrl).getImage()); textArea = new JTextArea(); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.addKeyListener(new ControlReturnTextCheckingListener()); textLineNumber = new TextLineNumber(textArea, 2); numberedTextAreaPane = new JScrollPane(textArea); numberedTextAreaPane.setRowHeaderView(textLineNumber); resultArea = new JTextPane(); undoRedo = new UndoRedoSupport(this.textArea, messages); frame.setJMenuBar(createMenuBar()); GridBagConstraints buttonCons = new GridBagConstraints(); JPanel insidePanel = new JPanel(); insidePanel.setOpaque(false); insidePanel.setLayout(new GridBagLayout()); buttonCons.gridx = 0; buttonCons.gridy = 0; buttonCons.anchor = GridBagConstraints.LINE_START; insidePanel.add(new JLabel(messages.getString("textLanguage") + " "), buttonCons); //create a ComboBox with flags, do not include hidden languages languageBox = LanguageComboBox.create(messages, EXTERNAL_LANGUAGE_SUFFIX, true, false); buttonCons.gridx = 1; buttonCons.gridy = 0; buttonCons.anchor = GridBagConstraints.LINE_START; insidePanel.add(languageBox, buttonCons); JCheckBox autoDetectBox = new JCheckBox(messages.getString("atd")); buttonCons.gridx = 2; buttonCons.gridy = 0; buttonCons.gridwidth = GridBagConstraints.REMAINDER; buttonCons.anchor = GridBagConstraints.LINE_START; insidePanel.add(autoDetectBox, buttonCons); buttonCons.gridx = 0; buttonCons.gridy = 1; buttonCons.gridwidth = GridBagConstraints.REMAINDER; buttonCons.fill = GridBagConstraints.HORIZONTAL; buttonCons.anchor = GridBagConstraints.LINE_END; buttonCons.weightx = 1.0; insidePanel.add(statusLabel, buttonCons); Container contentPane = frame.getContentPane(); GridBagLayout gridLayout = new GridBagLayout(); contentPane.setLayout(gridLayout); GridBagConstraints cons = new GridBagConstraints(); cons.gridx = 0; cons.gridy = 1; cons.fill = GridBagConstraints.HORIZONTAL; cons.anchor = GridBagConstraints.FIRST_LINE_START; JToolBar toolbar = new JToolBar("Toolbar", JToolBar.HORIZONTAL); toolbar.setFloatable(false); contentPane.add(toolbar, cons); JButton openButton = new JButton(openAction); openButton.setHideActionText(true); openButton.setFocusable(false); toolbar.add(openButton); JButton saveButton = new JButton(saveAction); saveButton.setHideActionText(true); saveButton.setFocusable(false); toolbar.add(saveButton); JButton saveAsButton = new JButton(saveAsAction); saveAsButton.setHideActionText(true); saveAsButton.setFocusable(false); toolbar.add(saveAsButton); JButton spellButton = new JButton(this.checkAction); spellButton.setHideActionText(true); spellButton.setFocusable(false); toolbar.add(spellButton); JToggleButton autoSpellButton = new JToggleButton(autoCheckAction); autoSpellButton.setHideActionText(true); autoSpellButton.setFocusable(false); toolbar.add(autoSpellButton); JButton clearTextButton = new JButton(new ClearTextAction()); clearTextButton.setHideActionText(true); clearTextButton.setFocusable(false); toolbar.add(clearTextButton); cons.insets = new Insets(5, 5, 5, 5); cons.fill = GridBagConstraints.BOTH; cons.weightx = 10.0f; cons.weighty = 10.0f; cons.gridx = 0; cons.gridy = 2; cons.weighty = 5.0f; splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, numberedTextAreaPane, new JScrollPane(resultArea)); mainPanel.setLayout(new GridLayout(0, 1)); contentPane.add(mainPanel, cons); mainPanel.add(splitPane); cons.fill = GridBagConstraints.HORIZONTAL; cons.gridx = 0; cons.gridy = 3; cons.weightx = 1.0f; cons.weighty = 0.0f; cons.insets = new Insets(4, 12, 4, 12); contentPane.add(insidePanel, cons); ltSupport = new LanguageToolSupport(this.frame, this.textArea, this.undoRedo); ResultAreaHelper.install(messages, ltSupport, resultArea); languageBox.selectLanguage(ltSupport.getLanguage()); languageBox.setEnabled(!ltSupport.getConfig().getAutoDetect()); autoDetectBox.setSelected(ltSupport.getConfig().getAutoDetect()); taggerShowsDisambigLog = ltSupport.getConfig().getTaggerShowsDisambigLog(); languageBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { // we cannot re-use the existing LT object anymore frame.applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault())); Language lang = languageBox.getSelectedLanguage(); ComponentOrientation componentOrientation = ComponentOrientation .getOrientation(lang.getLocale()); textArea.applyComponentOrientation(componentOrientation); resultArea.applyComponentOrientation(componentOrientation); ltSupport.setLanguage(lang); } } }); autoDetectBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { boolean selected = e.getStateChange() == ItemEvent.SELECTED; languageBox.setEnabled(!selected); ltSupport.getConfig().setAutoDetect(selected); if (selected) { Language detected = ltSupport.autoDetectLanguage(textArea.getText()); languageBox.selectLanguage(detected); } } }); ltSupport.addLanguageToolListener(new LanguageToolListener() { @Override public void languageToolEventOccurred(LanguageToolEvent event) { if (event.getType() == LanguageToolEvent.Type.CHECKING_STARTED) { String msg = org.languagetool.tools.Tools.i18n(messages, "checkStart"); statusLabel.setText(msg); if (event.getCaller() == getFrame()) { setWaitCursor(); checkAction.setEnabled(false); } } else if (event.getType() == LanguageToolEvent.Type.CHECKING_FINISHED) { if (event.getCaller() == getFrame()) { checkAction.setEnabled(true); unsetWaitCursor(); } String msg = org.languagetool.tools.Tools.i18n(messages, "checkDone", event.getSource().getMatches().size(), event.getElapsedTime()); statusLabel.setText(msg); } else if (event.getType() == LanguageToolEvent.Type.LANGUAGE_CHANGED) { languageBox.selectLanguage(ltSupport.getLanguage()); } else if (event.getType() == LanguageToolEvent.Type.RULE_ENABLED) { //this will trigger a check and the result will be updated by //the CHECKING_FINISHED event } else if (event.getType() == LanguageToolEvent.Type.RULE_DISABLED) { String msg = org.languagetool.tools.Tools.i18n(messages, "checkDoneNoTime", event.getSource().getMatches().size()); statusLabel.setText(msg); } } }); frame.applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault())); Language lang = ltSupport.getLanguage(); ComponentOrientation componentOrientation = ComponentOrientation.getOrientation(lang.getLocale()); textArea.applyComponentOrientation(componentOrientation); resultArea.applyComponentOrientation(componentOrientation); ResourceBundle textLanguageMessageBundle = JLanguageTool.getMessageBundle(ltSupport.getLanguage()); textArea.setText(textLanguageMessageBundle.getString("guiDemoText")); Configuration config = ltSupport.getConfig(); if (config.getFontName() != null || config.getFontStyle() != Configuration.FONT_STYLE_INVALID || config.getFontSize() != Configuration.FONT_SIZE_INVALID) { String fontName = config.getFontName(); if (fontName == null) { fontName = textArea.getFont().getFamily(); } int fontSize = config.getFontSize(); if (fontSize == Configuration.FONT_SIZE_INVALID) { fontSize = textArea.getFont().getSize(); } Font font = new Font(fontName, config.getFontStyle(), fontSize); textArea.setFont(font); } frame.pack(); frame.setSize(WINDOW_WIDTH, WINDOW_HEIGHT); frame.setLocationByPlatform(true); splitPane.setDividerLocation(200); MainWindowStateBean state = localStorage.loadProperty("gui.state", MainWindowStateBean.class); if (state != null) { if (state.getBounds() != null) { frame.setBounds(state.getBounds()); ResizeComponentListener.setBoundsProperty(frame, state.getBounds()); } if (state.getDividerLocation() != null) { splitPane.setDividerLocation(state.getDividerLocation()); } if (state.getState() != null) { frame.setExtendedState(state.getState()); } } ResizeComponentListener.attachToWindow(frame); maybeStartServer(); }
From source file:org.nuclos.client.customcomp.resplan.ResPlanPanel.java
public ResPlanPanel(ResPlanController cntrl, CollectableResPlanModel model, DateTimeModel timeModel) { final SpringLocaleDelegate localeDelegate = SpringLocaleDelegate.getInstance(); this.controller = cntrl; this.timeModel = timeModel; this.resPlanModel = model; setLayout(new BorderLayout()); JToolBar tb = UIUtils.createNonFloatableToolBar(); tb.setFloatable(false); tb.add(new AbstractAction(localeDelegate.getText("nuclos.resplan.action.refresh"), Icons.getInstance().getIconRefresh16()) { @Override//from w w w . j a va2s . c o m public void actionPerformed(ActionEvent e) { controller.refresh(); } }); tb.add(exportAction); tb.addSeparator(); this.timeHorizon = new Interval<Date>(model.getDefaultViewFrom(), model.getDefaultViewUntil()); final LabeledComponentSupport support = new LabeledComponentSupport(); startDateChooser = new DateChooser(support, timeHorizon.getStart()); startDateChooser.setMinimumSize(startDateChooser.getPreferredSize()); startDateChooser.setMaximumSize(startDateChooser.getPreferredSize()); endDateChooser = new DateChooser(support, timeHorizon.getEnd()); endDateChooser.setMinimumSize(endDateChooser.getPreferredSize()); endDateChooser.setMaximumSize(endDateChooser.getPreferredSize()); tb.add(new JLabel(localeDelegate.getText("nuclos.resplan.toolbar.from"))); tb.add(startDateChooser); tb.add(Box.createHorizontalStrut(5)); tb.add(new JLabel(localeDelegate.getText("nuclos.resplan.toolbar.until"))); tb.add(endDateChooser); timeGranularityModel = new ListComboBoxModel<ResPlanController.TimeGranularity>( controller.getTimeGranularityOptions()); tb.addSeparator(); tb.add(new JLabel(localeDelegate.getText("nuclos.resplan.toolbar.granularity"))); timeGranularityComboBox = new JComboBox(timeGranularityModel); tb.add(timeGranularityComboBox); timeGranularityComboBox .setMaximumSize(Orientation.VERTICAL.updateExtent(timeGranularityComboBox.getPreferredSize(), 20)); tb.addSeparator(); tb.add(new JLabel(localeDelegate.getText("nuclos.resplan.toolbar.resourceFilter"))); searchFilterComboBox = new JComboBox(); searchFilterComboBox.setRenderer(new SearchFilterListCellRenderer()); refreshSearchFilter(); tb.add(searchFilterComboBox); searchFilterComboBox .setMaximumSize(Orientation.VERTICAL.updateExtent(searchFilterComboBox.getPreferredSize(), 20)); tb.add(Box.createGlue()); infoButton = new JButton(infoAction); infoButton.setVisible(false); tb.add(infoButton); tb.add(Box.createHorizontalStrut(3)); initJResPlan(); ActionListener dateChooserListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { timeHorzionChanged(); } }; startDateChooser.addActionListener(dateChooserListener); endDateChooser.addActionListener(dateChooserListener); timeGranularityComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { Runnable runnable = createScrollToCurrentAreaRunnable(); ResPlanController.TimeGranularity granularity = timeGranularityModel.getSelectedItem(); resPlan.setTimeModel(granularity.getTimeModel()); resPlan.getTimelineHeader().setCategoryModel(granularity.getHeaderCategories()); SwingUtilities.invokeLater(runnable); } } }); searchFilterComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { EntitySearchFilter filter = (EntitySearchFilter) searchFilterComboBox.getSelectedItem(); if (filter instanceof NewCustomSearchFilter) { runCustomSearch(); return; } setSearchCondition(filter.getSearchCondition()); } } }); scrollPane = new JScrollPane(resPlan); JButton corner = new JButton(switchOrientationAction); corner.setBorderPainted(false); scrollPane.setCorner(JScrollPane.LOWER_RIGHT_CORNER, corner); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); add(tb, BorderLayout.NORTH); add(scrollPane, BorderLayout.CENTER); resPlan.setTimeHorizon(this.timeHorizon); resPlan.invalidate(); setFocusable(true); setFocusCycleRoot(true); getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("DELETE"), "delete"); //getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("control F"), "find"); getActionMap().put("delete", removeAction); //getActionMap().put("find", findAction); KeyBindingProvider.bindActionToComponent(KeyBindingProvider.ACTIVATE_SEARCH_PANEL_2, findAction, this); }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.AnnotationDataUI.java
/** * Creates a tool bar and adds the passed buttons to it. * /* w ww . jav a 2 s.c o m*/ * @param addButton The button to add. * @param removeButton The button to add. * @return See above. */ private JToolBar createBar(JButton addButton, JButton removeButton) { JToolBar bar = new JToolBar(); bar.setFloatable(false); bar.setBorder(null); bar.setBackground(UIUtilities.BACKGROUND_COLOR); if (addButton != null) bar.add(addButton); if (removeButton != null) bar.add(removeButton); return bar; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.DocComponent.java
/** Builds and lays out the UI. */ private void buildGUI() { setBackground(UIUtilities.BACKGROUND_COLOR); setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); add(label);// w ww . j a v a 2 s . c o m JToolBar bar = new JToolBar(); bar.setBackground(UIUtilities.BACKGROUND_COLOR); bar.setFloatable(false); bar.setRollover(true); bar.setBorder(null); bar.setOpaque(true); boolean b = setControlsEnabled(data != null); int count = 0; if (editButton != null) count++; if (unlinkButton != null) count++; if (downloadButton != null) count++; if (infoButton != null) count++; if (openButton != null) count++; if (count > 0 && data != null) { menuButton.setEnabled(true); if (model.isAcrossGroups()) menuButton.setEnabled(false); bar.add(menuButton); if (!b) bar.add(Box.createHorizontalStrut(8)); add(bar); } }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.OriginalMetadataComponent.java
/** * Builds the tool bar.//from w ww . j a v a2 s . co m * * @return See above. */ private JComponent buildToolBar() { JToolBar bar = new JToolBar(); bar.setFloatable(false); bar.setRollover(true); bar.setBorder(null); bar.add(downloadButton); return bar; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java
/** * Lays out the components using a <code>FlowLayout</code>. * /*from w w w . ja va2s. c om*/ * @param button The component to lay out. * @param component The component to lay out. * @param sizeRow The size of the row. * @return See above. */ private JPanel layoutEditablefield(Component button, JComponent component, int sizeRow) { JPanel p = new JPanel(); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(0, 2, 2, 0); c.gridy = 0; c.gridx = 0; if (button != null) { JToolBar bar = new JToolBar(); bar.setBorder(null); bar.setFloatable(false); bar.setBackground(UIUtilities.BACKGROUND_COLOR); bar.add(button); p.add(bar, c); c.gridx++; } if (sizeRow > 0) { c.ipady = sizeRow; c.gridheight = 2; } p.add(component, c); JPanel content = UIUtilities.buildComponentPanel(p, 0, 0); content.setBackground(UIUtilities.BACKGROUND_COLOR); return content; }