Repaint () in Java

I played around a bit with the Java graphics class, and I was just wondering when to call a method repaint()? I tried to comment on this and didn't seem to affect my graphical output interface. I saw that he used a lot in the Java GUI code that I read. Would anyone mind explaining when to use it and when not to use it?

+5
source share
4 answers

This is never required in most swing applications because they process it automatically (for common operations, such as changing text values ​​on buttons and adding data to a list).

, - , swing - , ( ).

+1

repaint() (), , - , . , , repaint(),

+1

"" .

repaint(), , - .

, ( ), validate() repaint() ( ) .

0

, :

    new Thread() {
    @Override
    public void run() {
    while (ClassName.this.isVisible()) {
        ClassName.this.updateStatusLabel();
        ClassName.this.validate();
        ClassName.this.repaint(50L);
        try {
        Thread.sleep(1000);
        } catch (final InterruptedException e) {
        Log.log(e);
        }
    }
    }
}.start();

, JDialog. updateStatusLabel , , , JLabel . , , , . , , - , , , , , / (, , ).

0

All Articles