下面列出了javax.swing.JComponent#invalidate ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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);
}
@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);
}
}
}
void repaintComponents()
{
synchronized (components) {
for (final JComponent comp : components) {
comp.invalidate();
comp.repaint();
}
}
}
void repaintComponents()
{
synchronized (components) {
for (final JComponent comp : components) {
comp.invalidate();
comp.repaint();
}
}
}
void repaintComponents()
{
for (final JComponent comp : components) {
comp.invalidate();
comp.repaint();
}
}
final void resizeContainer() {
JComponent c = ( JComponent ) container.getParent();
c.invalidate();
c.revalidate();
c.doLayout();
}