how to use the current frame size.

I set a frame to initial value (500,700);

But I allow the user to resize it by draging the edges.

How can I continue to use this new size for all the other frames that wud come along??

and also as and when they start up again??


TLTEOAsked:
Who is Participating?
 
heyhey_Connect With a Mentor Commented:
you can use Properties object to quickly load and save configuration data.
0
 
heyhey_Commented:
1. listen for ComponentEvents (add ComponentListener to Frame)
2. save new size in some sort of .ini file.
0
 
TLTEOAuthor Commented:
do you have any example to do it??
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
heyhey_Commented:
no,

what part do you need help with ?
0
 
TLTEOAuthor Commented:
for example, this frame will be use most of the time.
The old frame is diposed by mainFrame.dispose() method

public Myapp {
.
.
.

mainFrame = new JFrame("This 1st frame");
mainFrame.setSize(700,580);
content=mainFrame.getContentPane();
content.setLayout(new BorderLayout());

if I resize to (800,700) ..   how can I get the resized 'size' and pass it to the next frame (which is actually previous.dispose(); Or rather how to use this new resized value thruout??

what is the syntax to get the new size?



0
 
heyhey_Commented:
// member
 Dimension lastSize = new Dimension (700, 800);
 
 // before disposing old frame save the size
 lastSize = frame.getSize();
 
 
 // after creating Frame - save the size
 frame.setSize(lastSize.width, lastSize.height);
 
0
 
TLTEOAuthor Commented:
so actually I will also save the lastsize in .ini,  and before the application starts , I will look into the .ini for the lastsize??
0
 
heyhey_Commented:
> so actually I will also save the lastsize in .ini,  and before the application starts , I will look into the .ini for the lastsize.


yes - that's exactly what I suggested.


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.

All Courses

From novice to tech pro — start learning today.