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

The following examples show how to use javax.swing.JComponent#invalidate() . These examples are extracted from open source projects. 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
private static void checkVisibility(JComponent comp) {
    if (comp == null) return;

    comp.invalidate();
    comp.revalidate();
    comp.doLayout();
    comp.repaint();

    for (Component c : comp.getComponents())
        if (c.isVisible()) {
            comp.setVisible(true);

            return;
        }

    comp.setVisible(false);
}
 
Example 2
Source Project: pumpernickel   File: SplayedLayout.java    License: MIT License 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
	synchronized (container.getTreeLock()) {
		long elapsedTime = System.currentTimeMillis() - startTime;
		float f = ((float) elapsedTime) / ANIMATION_DURATION;
		if (f >= 1)
			f = 1;
		boolean containerDirty = false;
		for (Entry<JComponent, Rectangle> entry : endingPositions
				.entrySet()) {
			Rectangle oldBounds = startingPositions.get(entry.getKey());
			Rectangle tweenBounds = tween(oldBounds, entry.getValue(),
					f);
			JComponent jc = entry.getKey();
			if (!jc.getBounds().equals(tweenBounds)) {
				jc.setBounds(tweenBounds);
				if (f == 1) {
					jc.invalidate();
					jc.revalidate();
				}
				containerDirty = true;
			}
		}
		if (containerDirty)
			container.repaint();
		if (f == 1 && e != null) {
			((Timer) e.getSource()).stop();
			container.putClientProperty(PROPERTY_TIMER, null);
			container.putClientProperty(PROPERTY_TIMER_LISTENER, null);
		}
	}
}
 
Example 3
void repaintComponents()
{
  synchronized (components) {
    for (final JComponent comp : components) {
      comp.invalidate();
      comp.repaint();
    }
  }
}
 
Example 4
void repaintComponents()
{
  synchronized (components) {
    for (final JComponent comp : components) {
      comp.invalidate();
      comp.repaint();
    }
  }
}
 
Example 5
void repaintComponents()
{
  for (final JComponent comp : components) {
    comp.invalidate();
    comp.repaint();
  }
}
 
Example 6
Source Project: netbeans   File: TabLayoutManager.java    License: Apache License 2.0 4 votes vote down vote up
final void resizeContainer() {
    JComponent c = ( JComponent ) container.getParent();
    c.invalidate();
    c.revalidate();
    c.doLayout();
}