Hi, I have a JList inside a JScrollPane.getviewport.setview.... whatever. I have a separate thread that parses an xml file, and adds components to the JLists defaultlistmodel as it goes along with setElement(String). The application seems to have a mind of its own sometimes. I start the app, it starts to list some of the elements in the jList and then the list just goes blank. it does it a second time when I start the app again. then sometimes on the third time it loads all the elements and I can see them. now when I scroll down past the last element that was viewable from the top I cant select it. I select it, but I dont see the hi-light. once i scroll the selected but not hilighted element out of the viewable area and back in, its suddenly selected. So, in all I have 2 problems. one, the elements not displaying when I start the app, and two, the elements not being hi-lighted. Does anyone have any idea what could cause this?
I think the problem is that you are mixing AWT and Swing components... Frame is an AWT frame, and you are adding a Swing JScrollPane to it. To fix this, use only Swing components, like JFrame, JButton, etc.
Some other things you should do : use a layout manager instead of null... this can lead to sizing problems later. There are also better ways to instantiate all the widgets than the way you are doing it. Take a look at the refactored code for your window below.
[ November 14, 2003: Message edited by: Nathan Pruett ]
Joined: Sep 28, 2003
hmm... it still does that flicker in the list. once, twice and then either it stays off or it comes back on to stay. I have to say, your code looks very neat compared to mine, and makes more sense logically. As to layout managers, if there was an emoticon for pain i'd put it here -> ain: . for some reason my apps never look "cool" when i use them.
That really doesn't make sense... all your code does is add things to the model. They are never removed, so there should never be a case where the list is not populated.
It sounds like either you still have a problem somewhere mixing AWT and Swing components, or that there is a problem with the other thread updating the model. If it is a problem with threading, try minimizing and restoring your frame when it shows up with nothing in the list. If it looks normal after you've restored the frame, then you've got a threading problem, and to fix it you can do one of two things. You're going to have to either wait until the list is completely populated before you show the frame, or you're going to have to use something like SwingUtilities.invokeLater() or invokeAndWait() to make sure you update the model in the event thread.
Joined: Sep 28, 2003
ok, I've consistently noticed this message popping up every time it does NOT work, and after i try to resize the window like you said.
2003-11-20 14:11:14.119 java Java couldn't paint in Java_apple_awt_CRenderer_doRect, no focused view.
it's done that with other applications too, but I haven't seen any problems with them. this is the first time something is giving me trouble and this is displayed. it consistenly only appears every time my app fails. any suggestions?  Q/A found this on apples website... Q: Terminal/Console reports "Java couldn't paint in Java_apple_awt_CRenderer_doRect, no focused view."
A: This is a known issue with Swing applications under 1.4.1 Update 1, as well as Java 1.4.1 on Panther. It specifically refers to a failed paint call, but typically has no noticeable effect on applications and can be safely ignored. but it doesn't draw my list items... [ November 20, 2003: Message edited by: A. Wolf ]