• Post Reply Bookmark Topic Watch Topic
  • New Topic

a weird problem with panel  RSS feed

 
Gulsum Ramazanoglu
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi people,
I wanted to check whether I could make the second panel appear/disappear with a mouse click on a field in the first panel.. It works, ok, but there is a weird point : At first click, the second panel doesnt apeear as long as I dont click the lower line of the frame... but I must click right over it.. you know, to drag and widen the frames we come over and the cursor looks as a bidirectional arrow.. if I click at that point (after first click on the first panel), then its ok, the second panel appears.. else it doesnt! Why, I couldnt figure out..
If you understand why, would you tell it to me too? THanks a lot..

The code is ;
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you alter components in a container you must tell the container to do a new layout. You can do this with the Container method validate or the JComponent method revalidate. Since you have extended JFrame and are adding/removing from its contentPane you can use validate:
 
Gulsum Ramazanoglu
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Craig thank you very much you opened a way of thinking and THEN I could see the problem..
First I tried validate() and also read about Container.. I saw that (as you directed me as well) you must somehow "refresh" the stuff... but we refreshed the wrong one, the Container, in my example the Content Pane, and so it didnt work... As I clicked over the borders of the frame, my JFrame object, I saw that its refreshing itself as I clicked and showing the stuff inside properly... THEN I realized that I, myself, had to refresh it in the program.... So I checked the JFrame document and saw that there is something as setContentPane... so I used it in a funny way as ;


which means get the Content Pane which I changed recently, and set it as the new Content Pane of the JFrame object.

Here I tap on my left shoulder with my right hand (vice versa...both works

A biig thank you Craig Have a very beautiful day..
 
Gulsum Ramazanoglu
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Craig thank you very much you opened a way of thinking and THEN I could see the problem..
First I tried validate() and also read about Container.. I saw that (as you directed me as well) you must somehow "refresh" the stuff... but we refreshed the wrong one, the Container, in my example the Content Pane, and so it didnt work... As I clicked over the borders of the frame, my JFrame object, I saw that its refreshing itself as I clicked and showing the stuff inside properly... THEN I realized that I, myself, had to refresh it in the program.... So I checked the JFrame document and saw that there is something as setContentPane... so I used it in a funny way as ;


which means get the Content Pane which I changed recently, and set it as the new Content Pane of the JFrame object.

Here I tap on my left shoulder with my right hand (vice versa...both works

A biig thank you Craig Have a very beautiful day..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!