By Viktor Sehr


2010-10-31 22:22:19 8 Comments

I have a JPanel which contains a lot of child components. While updating\adding new components to the parent JPanel I'd like to prevent it from repainting, how can this achieved?

3 comments

@guai 2012-01-27 05:03:44

setVisible(false)  

update

setVisible(true)

@Denis Tulskiy 2010-11-01 03:14:55

Try RepaintManager.currentManager(component).markCompletelyClean(component). It will prevent the component from repainting. You might need to do this after each time you add new components.

@Jack 2010-10-31 22:34:31

you could try by using setIgnoreRepaint(boolean value) but it's a typical swing feature that can or cannot work (mainly because it depends from AWT so you never know).

Otherwise you could override the paint method by using a flag that simply makes the methor return without calling super.paint(). (actually overriding paintComponent should be the right choice)

@Frederic Leitenberger 2014-05-21 14:17:32

setIgnoreRepaint(boolean value) is for something completely different. The Java Doc says: Sets whether or not paint messages received from the operating system should be ignored. This does not affect paint events generated in software by the AWT, unless they are an immediate response to an OS-level paint message. This is useful, for example, if running under full-screen mode and better performance is desired, or if page-flipping is used as the buffer strategy.

Related Questions

Sponsored Content

34 Answered Questions

[SOLVED] Removing whitespace from strings in Java

  • 2011-03-28 07:22:01
  • zyamat
  • 1141835 View
  • 655 Score
  • 34 Answer
  • Tags:   java whitespace

32 Answered Questions

[SOLVED] How do I create a Java string from the contents of a file?

31 Answered Questions

[SOLVED] How to round a number to n decimal places in Java

30 Answered Questions

[SOLVED] How to create a generic array in Java?

21 Answered Questions

[SOLVED] How do I call one constructor from another in Java?

  • 2008-11-12 20:10:19
  • ashokgelal
  • 814759 View
  • 2154 Score
  • 21 Answer
  • Tags:   java constructor

26 Answered Questions

[SOLVED] How to get an enum value from a string value in Java?

  • 2009-03-02 22:56:34
  • Malachi
  • 1068488 View
  • 1898 Score
  • 26 Answer
  • Tags:   java enums

14 Answered Questions

[SOLVED] How to add an image to a JPanel?

1 Answered Questions

[SOLVED] How to repaint JPanel

  • 2015-08-08 14:36:45
  • user4863117
  • 47 View
  • 1 Score
  • 1 Answer
  • Tags:   java swing jpanel

1 Answered Questions

[SOLVED] Repaint JPanel from inside loop

  • 2014-01-08 10:26:29
  • user3086984
  • 1490 View
  • 1 Score
  • 1 Answer
  • Tags:   java swing repaint

Sponsored Content