Re: How to add elements to a JList without preventing refresh
- From: Thomas Hawtin <usenet@xxxxxxxxxxxxxxxxx>
- Date: Fri, 30 Dec 2005 15:40:53 +0000
Anonymous user wrote:
Thomas Hawtin a écrit :
Anonymous user wrote:
i have a simple problem. Let's say that in some app, i have a loop wich add a lot of elements to a JList. I CANNOT change the loop, but i can change how each element is added.
Are you not going to tell us why?
Because i'm working on JTable and sometimes, the same error happens for all the cells in a column for example. If the error happens in the renderering (TableCellRenderer) then you have some kind of loop that you can't control.
So the body of the loop sometime throws an exception, in which case no more entries should be added? That doesn't stop you doing the loop differently. Perhaps in sections. Perhaps in a different thread (but not directly accessing Swing components).
For this problem and all the ones conerning the build of the frame, blame Eclipse Visual Editor.
I blame using a GUI builder.
good idea, i fill up a regular List, and in paintComponent(), i do:
Not necessarily paintComponent. The effect will be much the same, although it might flash if you do do it from the paint.
An anonymous inner class would have worked better here.
i don't know how add a parameter to the constructor in anonymous inner class
Make a local variable final in the enclosing method. You can the access it from within the anonymous inner class.
You need the standard boilerplate here:
EventQueue.invokeLater(new Runnable() { public void run() {
i've never managed to understand why it is needed, so i never write it...
Take it on trust...
The main thread is different from the AWT Event Dispatch Thread (EDT). If you don't transfer across to the EDT then you have a multithreaded Swing program! You'll be okay most of the time. Most of the time.
Tom Hawtin -- Unemployed English Java programmer http://jroller.com/page/tackline/ .
- References:
- How to add elements to a JList without preventing refresh
- From: Anonymous user
- Re: How to add elements to a JList without preventing refresh
- From: Thomas Hawtin
- Re: How to add elements to a JList without preventing refresh
- From: Anonymous user
- How to add elements to a JList without preventing refresh
- Prev by Date: Re: How to add elements to a JList without preventing refresh
- Next by Date: Re: How to add elements to a JList without preventing refresh
- Previous by thread: Re: How to add elements to a JList without preventing refresh
- Next by thread: EzHomeTech will develop a US$99 box for java application.
- Index(es):
Relevant Pages
|