javax.swing.JToolBar#remove ( )源码实例Demo

下面列出了javax.swing.JToolBar#remove ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: PageInspectorImpl.java
/**
 * 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;
            }
        }
    }
}
 
源代码2 项目: netbeans   文件: TerminalContainerCommon.java
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);
}
 
源代码3 项目: audiveris   文件: SeparableToolBar.java
/**
 * 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);
    }
}
 
源代码4 项目: visualvm   文件: SnapshotDiffView.java
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
}
 
源代码5 项目: libreveris   文件: SeparableToolBar.java
/**
 * 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);
    }
}
 
源代码6 项目: WorldPainter   文件: AKDockLayout.java
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();

                    }

                }

            }

        }

    }