Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 442
  • Last Modified:

Random components on resizing frame

When I resize my frame (using button between minimize and close) I get few random components added to my frame (like JFileChooser) and JComponents which I added disappear.

Can some one please say something about such a behavior :(
0
hipal
Asked:
hipal
  • 6
  • 6
  • 2
  • +1
3 Solutions
 
objectsCommented:
sounds like you're not changing your ;layout correctly
may sure you call revalidate()/repaint() on any panel after you change its layout
0
 
hipalAuthor Commented:
what do you mean by changing layout ??

I am using null layout ..
0
 
objectsCommented:
i mean adding or removing components
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
hipalAuthor Commented:
The problem is not when I am moving/adding but when I am resizing frame
0
 
objectsCommented:
i realise that. resizing will trigger a relayout of the frame
0
 
ValeriCommented:
and if you resize the frame by increasing onli width or height, do they dissapear in the same way?
0
 
hipalAuthor Commented:
when I say resize I actually mean resizing by clicking the by default 'restore' button between minimize and close tab ..even if I just increase height or width of frame using mouse .. the effect is same ..

Shall i try to resize frame in program on pressing a button ?? I mean is this what you want me to try when you asked  "if you resize the frame by increasing onli width or height, do they dissapear in the same way?"
0
 
objectsCommented:
definitely sounds like your not adding/removing components correctly (causing the panel to be not laid out as directed). When you resize the frame the frame gets laid out so that why you see the problem then.
0
 
CEHJCommented:
As i mentioned in an earlier question. Using a null layout will cause you problems. These are some of them. Be prepared for more
0
 
ValeriCommented:
how the components that disappear are added to your container? by add and setBounds() or not?
0
 
hipalAuthor Commented:
sry fr late reply .. they are added using  add()
0
 
hipalAuthor Commented:
@CEHJ .. thanks a lot for responding.. but CEHJ .. I have been doing so in so many other small programs .. nothing wents wrong ..seems like I am doing something wrong here which I am not able to notice..

will go through code once again  .. else will post  it

thank you all of you experts !!
0
 
objectsCommented:
you'll get the same problem regardless of whether you use a layout manager or not (in fact it gets more complicated using a layout manager because adding a component can cause other to move)

see my earlier comments for likely cause of the problem.
0
 
hipalAuthor Commented:
thanks for response..

can you please elaborate on your previous comment which is

:definitely sounds like your not adding/removing components correctly (causing the panel to be not laid out as directed). When you resize the frame the frame gets laid out so that why you see the problem then.:
0
 
objectsCommented:
the resizing of the frame will trigger the panel being layed out and repainted. displaying any problems that have been caused by the layout being dynamically being changed earlier
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

  • 6
  • 6
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now