Java Code Examples for javax.swing.JToolBar#remove()
The following examples show how to use
javax.swing.JToolBar#remove() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PageInspectorImpl.java From netbeans with Apache License 2.0 | 5 votes |
/** * Uninitializes the selection mode (removes the page inspection * component/s from the toolbar). * * @param toolBar toolBar to remove the buttons from. */ void uninitSelectionMode(JToolBar toolBar) { if (toolBar != null) { for (Component component : toolBar.getComponents()) { if (SELECTION_MODE_COMPONENT_NAME.equals(component.getName())) { toolBar.remove(component); break; } } } }
Example 2
Source File: TerminalContainerCommon.java From netbeans with Apache License 2.0 | 5 votes |
private void fixSize(JToolBar actionBar) { Insets ins = actionBar.getMargin(); JButton dummy = new JButton(); dummy.setBorderPainted(false); dummy.setOpaque(false); dummy.setText(null); dummy.setIcon(new Icon() { @Override public int getIconHeight() { return 16; } @Override public int getIconWidth() { return 16; } @SuppressWarnings(value = "empty-statement") @Override public void paintIcon(Component c, Graphics g, int x, int y) { ; } }); actionBar.add(dummy); Dimension buttonPref = dummy.getPreferredSize(); Dimension minDim = new Dimension(buttonPref.width + ins.left + ins.right, buttonPref.height + ins.top + ins.bottom); actionBar.setMinimumSize(minDim); actionBar.setPreferredSize(minDim); actionBar.remove(dummy); }
Example 3
Source File: SeparableToolBar.java From audiveris with GNU Affero General Public License v3.0 | 5 votes |
/** * Remove any potential orphan separator at the end of the tool bar * * @param toolBar the toolBar to purge */ public static void purgeSeparator (JToolBar toolBar) { int count = toolBar.getComponentCount(); if (toolBar.getComponent(count - 1) instanceof JSeparator) { toolBar.remove(count - 1); } }
Example 4
Source File: SnapshotDiffView.java From visualvm with GNU General Public License v2.0 | 5 votes |
public DataViewComponent.MasterView getMasterView() { try { JComponent memoryDiffPanel = (JComponent)sdw.getComponent(0); memoryDiffPanel.setOpaque(false); final JToolBar toolBar = (JToolBar)memoryDiffPanel.getComponent(1); toolBar.setOpaque(false); ((JComponent)toolBar.getComponent(0)).setOpaque(false); ((JComponent)toolBar.getComponent(1)).setOpaque(false); ((JComponent)toolBar.getComponent(3)).setOpaque(false); ((JComponent)toolBar.getComponent(4)).setOpaque(false); ((JComponent)toolBar.getComponent(5)).setOpaque(false); JPanel toolbarSpacer = new JPanel(null) { public Dimension getPreferredSize() { if (UISupport.isGTKLookAndFeel() || UISupport.isNimbusLookAndFeel()) { int currentWidth = toolBar.getSize().width; int minimumWidth = toolBar.getMinimumSize().width; int extraWidth = currentWidth - minimumWidth; return new Dimension(Math.max(extraWidth, 0), 0); } else { return super.getPreferredSize(); } } }; toolbarSpacer.setOpaque(false); Component descriptionLabel = toolBar.getComponent(7); toolBar.remove(descriptionLabel); toolBar.remove(6); toolBar.add(toolbarSpacer); toolBar.add(descriptionLabel); } catch (Exception e) {} sdw.setPreferredSize(new Dimension(1, 1)); SnapshotDiffContainer snapshotDiff = (SnapshotDiffContainer)getDataSource(); String caption = NbBundle.getMessage(SnapshotDiffView.class, "DESCR_Snapshots_Comparison", // NOI18N new Object[] { DataSourceDescriptorFactory.getDescriptor(snapshotDiff.getSnapshot1()).getName(), DataSourceDescriptorFactory.getDescriptor(snapshotDiff.getSnapshot2()).getName()}); return new DataViewComponent.MasterView(caption, null, sdw); // NOI18N }
Example 5
Source File: SeparableToolBar.java From libreveris with GNU Lesser General Public License v3.0 | 5 votes |
/** * Remove any potential orphan separator at the end of the tool bar */ public static void purgeSeparator (JToolBar toolBar) { int count = toolBar.getComponentCount(); if (toolBar.getComponent(count - 1) instanceof JSeparator) { toolBar.remove(count - 1); } }
Example 6
Source File: AKDockLayout.java From WorldPainter with GNU General Public License v3.0 | 2 votes |
private void flipSeparators(Component c, int orientn) { if (c != null && c instanceof JToolBar && UIManager.getLookAndFeel().getName().toLowerCase().indexOf("windows") != -1) { JToolBar jtb = (JToolBar) c; Component comps[] = jtb.getComponents(); if (comps != null && comps.length > 0) { for (int i = 0; i < comps.length; i++) { try { Component component = comps[i]; if (component != null) { if (component instanceof JSeparator) { jtb.remove(component); JSeparator separ = new JSeparator(); if (orientn == SwingConstants.VERTICAL) { separ.setOrientation(SwingConstants.VERTICAL); separ.setMinimumSize(new Dimension(2, 6)); separ.setPreferredSize(new Dimension(2, 6)); separ.setMaximumSize(new Dimension(2, 100)); } else { separ.setOrientation(SwingConstants.HORIZONTAL); separ.setMinimumSize(new Dimension(6, 2)); separ.setPreferredSize(new Dimension(6, 2)); separ.setMaximumSize(new Dimension(100, 2)); } jtb.add(separ, i); } } } catch (Exception e) { e.printStackTrace(); } } } } }