Java Code Examples for javax.swing.JComponent.removeAll()

The following are Jave code examples for showing how to use removeAll() of the javax.swing.JComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Equella   File: FlatterSpinnerUI.java   View Source Code Vote up 5 votes
@Override
public void uninstallUI(JComponent c)
{
	uninstallDefaults();
	uninstallListeners();
	this.spinner = null;
	c.removeAll();
}
 
Example 2
Project: jdk8u-jdk   File: bug4337267.java   View Source Code Vote up 5 votes
void injectComponent(JComponent p, JComponent c, boolean shape) {
    if (shape) {
        setShaping(c);
    }
    p.removeAll();
    p.add(c);
}
 
Example 3
Project: openjdk-jdk10   File: bug4337267.java   View Source Code Vote up 5 votes
void injectComponent(JComponent p, JComponent c, boolean shape) {
    if (shape) {
        setShaping(c);
    }
    p.removeAll();
    p.add(c);
}
 
Example 4
Project: incubator-netbeans   File: MenuEditLayer.java   View Source Code Vote up 4 votes
private void registerForm(final RADVisualContainer metacomp, final JMenu menu) {
    // don't double register
    if(!formModelListeners.containsKey(metacomp)) {
        FormModelListener fml = new FormModelListener() {
            @Override
            public void formChanged(FormModelEvent[] events) {
                if (events != null) {
                    for(FormModelEvent evt : events) {
                        if(evt.getChangeType() == FormModelEvent.FORM_TO_BE_CLOSED) {
                            formModelListeners.remove(metacomp);
                            metacomp.getFormModel().addFormModelListener(this);
                            continue;
                        }
                        
                        if(evt.getChangeType() == FormModelEvent.COMPONENT_PROPERTY_CHANGED) {
                            if("action".equals(evt.getPropertyName())) { // NOI18N
                                configureEditedComponent(evt.getComponent());
                            }
                        }
                        if(evt.getChangeType() == FormModelEvent.COMPONENT_PROPERTY_CHANGED || evt.getChangeType() == FormModelEvent.BINDING_PROPERTY_CHANGED) {
                            if(evt.getContainer() == metacomp || evt.getComponent() == metacomp) {
                                rebuildOnScreenMenu(metacomp);
                            }
                            updateIcon(evt.getComponent());
                        }
                        
                        if(evt.getChangeType() == FormModelEvent.COMPONENT_ADDED) {
                            updateIcon(evt.getComponent());
                            //reinstall the accelerator preview when moving items around
                            if(evt.getComponent() != null) {
                                Component co = (Component) formDesigner.getComponent(evt.getComponent());
                                if(co instanceof JMenuItem) {
                                    installAcceleratorPreview((JMenuItem)co);
                                }
                            }
                        }
                        
                        // if this menu was deleted then make sure it's popup is hidden and removed
                        if(evt.getChangeType() == FormModelEvent.COMPONENT_REMOVED) {
                            if(evt.getComponent() == metacomp) {
                                unconfigureMenu(menu);
                                continue;
                            }
                        }
                        // if something added to the menu we monitor
                        if(evt.getChangeType() == FormModelEvent.COMPONENT_ADDED ||
                                evt.getChangeType() == FormModelEvent.COMPONENTS_REORDERED ||
                                evt.getChangeType() == FormModelEvent.COMPONENT_REMOVED) {
                            if(evt.getContainer() == metacomp) {
                                // then rebuild the menu
                                rebuildOnScreenMenu(metacomp);
                                return;
                            }
                            if(evt.getContainer() == getFormMenuBar()) {
                                JComponent comp = (JComponent) formDesigner.getComponent(getFormMenuBar());
                                if (comp != null) { // MenuBar not shown in the designer, see issue 124873
                                    RADVisualContainer rad = (RADVisualContainer) getFormMenuBar();
                                    comp.removeAll();
                                    for(RADVisualComponent c : rad.getSubComponents()) {
                                        if(c!=null) {
                                            comp.add((JComponent)formDesigner.getComponent(c));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        };
        formModelListeners.put(metacomp,fml);
        metacomp.getFormModel().addFormModelListener(fml);
    }
}
 
Example 5
Project: incubator-netbeans   File: NbEditorUI.java   View Source Code Vote up 4 votes
private static void processSideBars(Map sideBars, JComponent ec, JScrollPane scroller) {
        // Remove all existing sidebars
        ec.removeAll();

        // Add the scroller and the new sidebars
        ec.add(scroller);
        scroller.setRowHeader(null);
        scroller.setColumnHeaderView(null);
//        final MouseDispatcher mouse = new MouseDispatcher((JTextComponent) ec.getClientProperty(JTextComponent.class));
        for (Iterator entries = sideBars.entrySet().iterator(); entries.hasNext(); ) {
            Map.Entry entry = (Map.Entry) entries.next();
            SideBarPosition position = (SideBarPosition) entry.getKey();
            JComponent sideBar = (JComponent) entry.getValue();
            
//            if (position.getPosition() == SideBarPosition.WEST) {
//                JPanel p = new JPanel(new BorderLayout()) {
//
//                    @Override
//                    public void addNotify() {
//                        super.addNotify();
//                        infiltrateContainer(this, mouse, true);
//                    }
//
//                    @Override
//                    public void removeNotify() {
//                        infiltrateContainer(this, mouse, false);
//                        super.removeNotify();
//                    }
//
//                };
//                p.add(sideBar, BorderLayout.CENTER);
//                sideBar = p;
//            }
            
            if (position.isScrollable()) {
                if (position.getPosition() == SideBarPosition.WEST) {
                    scroller.setRowHeaderView(sideBar);
                } else {
                    if (position.getPosition() == SideBarPosition.NORTH) {
                        scroller.setColumnHeaderView(sideBar);
                    } else {
                        throw new IllegalArgumentException("Unsupported side bar position, scrollable = true, position=" + position.getBorderLayoutPosition()); // NOI18N
                    }
                }
            } else {
                ec.add(sideBar, position.getBorderLayoutPosition());
            }
        }
    }