aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Help!!! - Intermitent display of JSlider Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Help!!! - Intermitent display of JSlider" Watch "Help!!! - Intermitent display of JSlider" New topic
Author

Help!!! - Intermitent display of JSlider

Dave Turner
Ranch Hand

Joined: Mar 13, 2001
Posts: 60
hi
I am developing a gui application using swing, and in one of my gui classes i use the JSlider with a subclass of DefaultBoundedRangeModel as its model. Another gui class contains at least two of the above class at any one time.
The problem is that if i run the application one time the JSliders may be visible, but the next time i load it, they most likely wont be visible. There appears to be no pattern to this changing of visibility, and i am at a complete loss to explain it.
Does anyone have any idea what the problem may be, or a suggestion of what i should do to work around it?
Thanks in advance
Dave
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
what layoutmanager are you using? how are you adding the components and to what container are you adding them?
chantal
Dave Turner
Ranch Hand

Joined: Mar 13, 2001
Posts: 60
the JSlider is in the centre of a BorderLayout in a JPanel (A) that is itself located in the centre of another JPanel (B). Another JPanel (C) contains a number of (B) JPanels in a GridLayout. JPanel (C) is the viewport view of a JScrollPane. The ScrollPane is located at the centre of another JPanel (D). This JPanel (D) is part of a JTabbedPane that is at the centre of another JPanel (E). The JPanel (E) is at the centre of the ContentPane of an InternalFrame held in a DesktopPane at the centre of a JFrame.
The only part that seems to display at random is the JSlider.
I have tried changing layout managers, and recompiling entire packages, yet nothing seems to have an effect.
Dave
Dave Turner
Ranch Hand

Joined: Mar 13, 2001
Posts: 60
I am convinced that the issue here is not with the layout of the components, as i can run the application a number of times without any recompilation and observe a random pattern of visibility of the JSliders.
Also, when the sliders are not visible, clicking on the grey space that they should occupy, still fires ChangeEvents.
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
hm, I haven't worked with jslider before. what i can say from some strange experience i had with jtable is: the problem is most likely the model. writing a complex model from scratch can cause problems in the interaction of the view and the model.
have you written a little test app with just the jslider in it, using a very simple model (e.g. an example out of some documentation)? try to experiment with this test app and extend it to the needs of your big app. then use it with your big app.
chantal
Dave Turner
Ranch Hand

Joined: Mar 13, 2001
Posts: 60
hi chantal
ive tried writing a simple test of JSlider as you suggested and it works fine, even with my subclass model.
Also i tried removing my subclass model from the sliders in my application, but this had no effect on the visibility problem.
i think my next step will be to redesign the Components of my app that use the JSliders from scratch, and hope that the problem does not present itself again.
thanks
Dave
Dave Turner
Ranch Hand

Joined: Mar 13, 2001
Posts: 60
I seem to have solved the problem , though i am unsure of the exact explanation.
I had previously been experimenting with creating a jar file of my classes, which was located on my classpath, although i have now deleted it.
I have been able to load ten instances of my application concurrently and each one functioned without fault.
I am certain that the jar file was the cause of my problem but i dont know why...
thanks for your help
Dave
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Help!!! - Intermitent display of JSlider