Java Code Examples for javax.swing.JComponent#remove()

The following examples show how to use javax.swing.JComponent#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: FeatureEditor.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent event) {
    String     command = event.getActionCommand();
    JComponent parent  = (JComponent) getParent();
    if (LeveledAmount.ATTRIBUTE_PER_LEVEL.equals(command)) {
        ((Bonus) mFeature).getAmount().setPerLevel(mLeveledAmountCombo.getSelectedIndex() == 1);
    } else if (CHANGE_BASE_TYPE.equals(command)) {
        LAST_FEATURE_TYPE = (FeatureType) mBaseTypeCombo.getSelectedItem();
        if (LAST_FEATURE_TYPE != null && !LAST_FEATURE_TYPE.matches(mFeature)) {
            Commitable.sendCommitToFocusOwner();
            try {
                parent.add(create(mRow, LAST_FEATURE_TYPE.createFeature()), UIUtilities.getIndexOf(parent, this));
            } catch (Exception exception) {
                // Shouldn't have a failure...
                exception.printStackTrace(System.err);
            }
            parent.remove(this);
            parent.revalidate();
            parent.repaint();
        }
    } else {
        super.actionPerformed(event);
    }
}
 
Example 2
Source File: FeatureEditor.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
private void addFeature() {
    JComponent parent = (JComponent) getParent();
    try {
        parent.add(create(mRow, LAST_FEATURE_TYPE.createFeature()));
    } catch (Exception exception) {
        // Shouldn't have a failure...
        exception.printStackTrace(System.err);
    }
    if (mFeature == null) {
        parent.remove(this);
    }
    parent.revalidate();
}
 
Example 3
Source File: FeatureEditor.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
private void removeFeature() {
    JComponent parent = (JComponent) getParent();
    parent.remove(this);
    if (parent.getComponentCount() == 0) {
        parent.add(new NoFeature(mRow));
    }
    parent.revalidate();
    parent.repaint();
}
 
Example 4
Source File: SkillDefaultEditor.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
private void addDefault() {
    SkillDefault skillDefault = new SkillDefault(LAST_ITEM_TYPE, LAST_ITEM_TYPE.isSkillBased() ? "" : null, null, 0); //$NON-NLS-1$
    JComponent   parent       = (JComponent) getParent();
    parent.add(new SkillDefaultEditor(skillDefault));
    if (mDefault == null) {
        parent.remove(this);
    }
    parent.revalidate();
    parent.repaint();
    notifyActionListeners();
}
 
Example 5
Source File: SkillDefaultEditor.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
private void removeDefault() {
    JComponent parent = (JComponent) getParent();
    parent.remove(this);
    if (parent.getComponentCount() == 0) {
        parent.add(new SkillDefaultEditor());
    }
    parent.revalidate();
    parent.repaint();
    notifyActionListeners();
}
 
Example 6
Source File: PrereqEditor.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
private void remove() {
    JComponent parent = (JComponent) getParent();
    int        index  = UIUtilities.getIndexOf(parent, this);
    int        count  = countSelfAndDescendents(mPrereq);
    for (int i = 0; i < count; i++) {
        parent.remove(index);
    }
    mPrereq.removeFromParent();
    parent.revalidate();
    parent.repaint();
}
 
Example 7
Source File: PrereqEditor.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (CHANGE_BASE_TYPE.equals(command)) {
        Class<?> type = BASE_TYPES[mBaseTypeCombo.getSelectedIndex()];
        if (!mPrereq.getClass().equals(type)) {
            JComponent parent    = (JComponent) getParent();
            PrereqList list      = mPrereq.getParent();
            int        listIndex = list.getIndexOf(mPrereq);
            try {
                Prereq prereq;
                if (type == ContainedWeightPrereq.class) {
                    prereq = new ContainedWeightPrereq(list, mRow.getDataFile().defaultWeightUnits());
                } else {
                    prereq = (Prereq) type.getConstructor(PrereqList.class).newInstance(list);
                }
                if (prereq instanceof HasPrereq && mPrereq instanceof HasPrereq) {
                    ((HasPrereq) prereq).has(((HasPrereq) mPrereq).has());
                }
                list.add(listIndex, prereq);
                list.remove(mPrereq);
                parent.add(create(mRow, prereq, mDepth), UIUtilities.getIndexOf(parent, this));
            } catch (Exception exception) {
                // Shouldn't have a failure...
                exception.printStackTrace(System.err);
            }
            parent.remove(this);
            parent.revalidate();
            parent.repaint();
            ListPrereqEditor.setLastItemType(type);
        }
    } else if (CHANGE_HAS.equals(command)) {
        ((HasPrereq) mPrereq).has(((JComboBox<?>) event.getSource()).getSelectedIndex() == 0);
    } else {
        super.actionPerformed(event);
    }
}
 
Example 8
Source File: MultiLineToolTipUI.java    From osp with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void uninstallUI(JComponent c) {
	super.uninstallUI(c);		
  c.remove(rendererPane);
  rendererPane = null;
}