Example usage for java.awt Container remove

List of usage examples for java.awt Container remove

Introduction

In this page you can find the example usage for java.awt Container remove.

Prototype

public void remove(Component comp) 

Source Link

Document

Removes the specified component from this container.

Usage

From source file:com.jvms.i18neditor.editor.Editor.java

public void updateUI() {
    TranslationTreeNode selectedNode = translationTree.getSelectionNode();

    resourcesPanel.removeAll();/*from   w w w  . ja v  a 2 s.  c  o  m*/
    resourceFields = resourceFields.stream().sorted().collect(Collectors.toList());
    resourceFields.forEach(field -> {
        Locale locale = field.getResource().getLocale();
        String label = locale != null ? locale.getDisplayName() : MessageBundle.get("resources.locale.default");
        field.setEnabled(selectedNode != null && selectedNode.isEditable());
        field.setRows(settings.getDefaultInputHeight());
        resourcesPanel.add(Box.createVerticalStrut(5));
        resourcesPanel.add(new JLabel(label));
        resourcesPanel.add(Box.createVerticalStrut(5));
        resourcesPanel.add(field);
        resourcesPanel.add(Box.createVerticalStrut(10));
    });

    Container container = getContentPane();
    if (project != null) {
        container.add(contentPane);
        container.remove(introText);
        List<Resource> resources = project.getResources();
        editorMenu.setEnabled(true);
        editorMenu.setEditable(!resources.isEmpty());
        translationField.setEditable(!resources.isEmpty());
    } else {
        container.add(introText);
        container.remove(contentPane);
        editorMenu.setEnabled(false);
        editorMenu.setEditable(false);
        translationField.setEditable(false);
    }

    translationField.setVisible(settings.isKeyFieldEnabled());
    translationTree.setToggleClickCount(settings.isDoubleClickTreeToggling() ? 2 : 1);

    updateTitle();
    validate();
    repaint();
}

From source file:com.jcraft.weirdx.DDXWindowImp.java

public void delete() throws IOException {
    if (offi != null) {
        offi.flush();//w w w  .  jav  a  2  s  .  co  m
        offi = null;
    }
    if (offg != null) {
        offg.dispose();
        offg = null;
    }
    window = null;
    Container tmp = getParent();
    if (tmp != null) {
        tmp.remove(this);
    }
}

From source file:org.intermine.install.swing.NewDerivedTypeDialog.java

/**
 * Initialise to show the properties needed to complete to create the
 * derived source from the given parent.
 * //from  ww  w. j  a  v a 2 s .  c o m
 * @param project The Project being edited.
 * @param parentType The parent data source type descriptor.
 * @param name The name of the actual data source to add to the project.
 */
public void initialise(Project project, SourceInfo parentType, String name) {
    Container cp = getContentPane();

    this.project = project;
    parentInfo = parentType;

    nameField.setText(name);
    typeField.setText(parentType.getSource().getType());
    derivedTypeField.setText(name);

    for (JComponent c : additionalFields) {
        cp.remove(c);
    }
    cp.remove(spacerPanel);
    cp.remove(buttonPanel);

    additionalFields.clear();
    wrappers.clear();

    GridBagConstraints cons = GridBagHelper.defaultConstraints();

    cons.gridy = 3;

    SourceTypeDerivation derivation = parentInfo.getSource().getDerivation();
    assert derivation != null : "No derivation on source";
    for (PropertyDescriptor descriptor : derivation.getProperty()) {

        JLabel label = new JLabel(descriptor.getName());
        cons.gridx = 0;
        cons.weightx = 0;
        cp.add(label, cons);
        additionalFields.add(label);

        PropertyComponentWrapper wrapper = PropertyComponentCreator.createComponentFor(descriptor.getName(),
                descriptor, "");
        cons.weightx = 1;
        cons.gridx++;
        cp.add(wrapper.getDisplayComponent(), cons);
        additionalFields.add(wrapper.getDisplayComponent());
        wrappers.add(wrapper);

        cons.gridy++;
    }

    cons.gridx = 0;
    cons.weightx = 1;
    cons.weighty = 1;
    cons.gridwidth = GridBagConstraints.REMAINDER;
    cons.fill = GridBagConstraints.BOTH;
    cp.add(spacerPanel, cons);

    cons.gridy++;
    cons.weighty = 0;
    cons.fill = GridBagConstraints.HORIZONTAL;
    cp.add(buttonPanel, cons);

    pack();
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/** 
 * Lays out the components composing main panel. 
 * /*w  w w  .  j  ava  2  s  .  c  o  m*/
 * @param fromPreferences   Pass <code>true</code> to indicate that the 
 *                      method is invoked while setting the user 
 *                      preferences, <code>false</code> otherwise.
 */
private void layoutComponents(boolean fromPreferences) {
    //initSplitPanes();
    Dimension d;
    int diff;
    Container container = getContentPane();
    container.removeHierarchyBoundsListener(boundsAdapter);
    int width = 0, height = 0;
    JComponent rightComponent;
    //int divider = 0;
    int vExtra = 2;
    int addition;
    switch (displayMode) {
    case RENDERER:
        rightComponent = model.getMetadataViewer().getEditorUI();
        rendererSplit.setRightComponent(rightComponent);
        if (restoreSize == null) {
            rendererSplit.setResizeWeight(1.0);
            return;
        }
        d = model.getMetadataViewer().getIdealRendererSize();
        rightComponent.setMinimumSize(d);
        tabs.setMinimumSize(restoreSize);
        height = restoreSize.height;
        diff = d.height - restoreSize.height;
        if (diff > 0)
            height += diff;
        else
            height += vExtra;
        addition = rendererSplit.getDividerSize() + 2 * (refInsets.left + refInsets.right);

        width = restoreSize.width + d.width;
        width += 4 * addition;
        break;
    case HISTORY:
        container.remove(mainComponent);
        historyUI.doGridLayout();
        addComponents(historySplit, tabs, historyUI);
        mainComponent = historySplit;
        container.add(mainComponent, BorderLayout.CENTER);
        container.validate();
        container.repaint();
        height = restoreSize.height;
        width = restoreSize.width;
        d = historyUI.getIdealSize();
        addition = historySplit.getDividerSize() + 2 * (refInsets.top + refInsets.bottom);
        height += d.height;
        historySplit.setResizeWeight(0.49);
        height += addition;
        break;
    case HISTORY_AND_RENDERER:
        historySplit.setResizeWeight(0.49);
        container.remove(mainComponent);
        historyUI.doGridLayout();
        rightComponent = model.getMetadataViewer().getEditorUI();
        addComponents(rendererSplit, tabs, rightComponent);
        addComponents(historySplit, rendererSplit, historyUI);
        mainComponent = historySplit;
        container.add(mainComponent, BorderLayout.CENTER);
        container.validate();
        container.repaint();

        d = model.getMetadataViewer().getIdealRendererSize();
        height = restoreSize.height;
        diff = d.height - restoreSize.height;
        if (diff > 0)
            height += diff;
        else
            height += vExtra;
        addition = rendererSplit.getDividerSize() + 2 * (refInsets.left + refInsets.right);

        width = restoreSize.width + d.width;
        width += 4 * addition;
        d = historyUI.getPreferredSize();
        addition = historySplit.getDividerSize() + 2 * (refInsets.top + refInsets.bottom);
        height += d.height;
        height += addition;
        break;
    case NEUTRAL:
        rightComponent = model.getMetadataViewer().getEditorUI();
        rendererSplit.remove(rightComponent);
        if (restoreSize == null)
            return;
        width = restoreSize.width;
        height = restoreSize.height;
        break;
    default:
    }
    //rendererSplit.setDividerLocation(-1);
    //rendererSplit.setResizeWeight(1.0);
    //historySplit.setDividerLocation(-1);
    d = getIdealSize(width, height);

    /* Need to review that code.
     * Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int w = (int) (screen.width*SCREEN_RATIO);
    int h = (int) (screen.height*SCREEN_RATIO);
    if (d.width > w || d.height > h) {
       setSize(width, height);
    } else setSize(d);
    */
    setSize(d);
    setPreferredSize(d);
    pack();
    container.addHierarchyBoundsListener(boundsAdapter);
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.util.MoveGroupSelectionDialog.java

/**
 * Creates a new container corresponding to {@link #containerType}.
 * /*  w  w  w .ja  v a 2  s.co m*/
 * @param name The name of the container.
 */
private void create(String name) {
    if (containerType == null)
        return;
    if (ProjectData.class.equals(containerType)) {
        toCreate = new ProjectData();
        ((ProjectData) toCreate).setName(name);
    } else if (ScreenData.class.equals(containerType)) {
        toCreate = new ScreenData();
        ((ScreenData) toCreate).setName(name);
    } else if (DatasetData.class.equals(containerType)) {
        toCreate = new DatasetData();
        ((DatasetData) toCreate).setName(name);
    }
    DefaultTreeModel dtm = (DefaultTreeModel) treeDisplay.getModel();
    TreeImageDisplay root = (TreeImageDisplay) dtm.getRoot();
    TreeImageSet node = new TreeImageSet(toCreate);
    node.setDisplayItems(false);
    dtm.insertNodeInto(node, root, root.getChildCount());
    node = (TreeImageSet) root.getChildAt(root.getChildCount() - 1);
    treeDisplay.setSelectionPath(new TreePath(node.getPath()));
    if (noDisplay) {
        noDisplay = false;
        Container c = getContentPane();
        c.remove(body);
        c.remove(1);
        c.add(new JScrollPane(treeDisplay), BorderLayout.CENTER);
        c.add(buildToolBar(), BorderLayout.SOUTH);
        validate();
        repaint();

    }
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.util.MoveGroupSelectionDialog.java

/**
 * Sets the values where to import the data.
 * /*from  w  w w . j a  v  a 2 s. c o  m*/
 * @param targets The values to display.
 */
public void setTargets(Collection<DataObject> targets) {
    Container c = getContentPane();
    c.remove(body);
    c.remove(1);
    treeDisplay = new JTree();
    treeDisplay.setVisible(true);
    treeDisplay.setRootVisible(false);
    ToolTipManager.sharedInstance().registerComponent(treeDisplay);
    treeDisplay.setCellRenderer(new TreeCellRenderer(userID));
    treeDisplay.setShowsRootHandles(true);
    TreeImageSet root = new TreeImageSet("");
    treeDisplay.setModel(new DefaultTreeModel(root));
    treeDisplay.addTreeSelectionListener(this);
    if (CollectionUtils.isEmpty(targets)) {
        buildNoContentPane();
        return;
    }
    Set<TreeImageDisplay> nodes = TreeViewerTranslator.transformHierarchy(new ArrayList<Object>(targets));
    List<TreeImageDisplay> transformedNodes = prepareSortedList(sorter.sort(nodes));
    if (transformedNodes.size() == 0) {
        buildNoContentPane();
        return;
    }
    DefaultTreeModel dtm = (DefaultTreeModel) treeDisplay.getModel();
    buildTreeNode(root, transformedNodes, dtm);
    dtm.reload();
    c.add(new JScrollPane(treeDisplay), BorderLayout.CENTER);
    c.add(buildToolBar(), BorderLayout.SOUTH);
    validate();
    repaint();
}

From source file:org.xulux.swing.widgets.Entry.java

/**
 * @see org.xulux.nyx.Widget#destroy()//  ww  w .  ja v a2  s.  com
 */
public void destroy() {
    processDestroy();
    removeAllRules();
    if (textComponent != null) {
        textComponent.removeAll();
        Container container = textComponent.getParent();
        if (container != null) {
            container.remove(textComponent);
        }
        textComponent = null;
    }
    if (getPart() != null) {
        getPart().removeWidget(this, this);
    }
    initialized = false;
}

From source file:org.xulux.swing.widgets.Table.java

/**
 * @see org.xulux.gui.Widget#destroy()//  w  w  w .j  av  a 2  s .  c  om
 */
public void destroy() {
    if (!initialized) {
        return;
    }
    super.destroy();
    destroyTable();
    if (this.scrollPane == null) {
        return;
    }
    Container container = this.scrollPane.getParent();
    this.scrollPane.setVisible(false);
    this.scrollPane.removeAll();
    if (container != null) {
        container.remove(this.scrollPane);
    }
    this.scrollPane = null;
    this.table = null;
}

From source file:org.xulux.swing.widgets.TabPanel.java

/**
 * @see org.xulux.gui.Widget#destroy()/*from  w  ww.  j  a  v  a  2s . c  o  m*/
 */
public void destroy() {
    super.destroy();
    if (tabPanel == null) {
        return;
    }
    if (repaintComponent != null) {
        tabPanel.removeHierarchyListener(repaintComponent);
        repaintComponent = null;
    }
    Container container = tabPanel.getParent();
    tabPanel.setVisible(false);
    tabPanel.removeAll();
    if (container != null) {
        container.remove(tabPanel);
    }
    tabPanel = null;
}

From source file:org.xulux.swing.widgets.TextArea.java

/**
 * @see org.xulux.gui.Widget#destroy()// w ww.  ja  v a  2 s .  co  m
 */
public void destroy() {
    processDestroy();
    removeAllRules();
    if (textComponent != null) {
        textComponent.removeAll();
        Container container = textComponent.getParent();
        if (container != null) {
            container.remove(textComponent);
        }
        textComponent = null;
        if (scrollPane != null) {
            scrollPane.removeAll();
            container = scrollPane.getParent();
            if (container != null) {
                container.remove(scrollPane);
            }
        }
    }
    getPart().removeWidget(this, this);
}