Link to home
Start Free TrialLog in
Avatar of TLTEO
TLTEO

asked on

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??


Avatar of heyhey_
heyhey_

1. listen for ComponentEvents (add ComponentListener to Frame)
2. save new size in some sort of .ini file.
Avatar of TLTEO

ASKER

do you have any example to do it??
no,

what part do you need help with ?
Avatar of TLTEO

ASKER

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?



// 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);
 
Avatar of TLTEO

ASKER

so actually I will also save the lastsize in .ini,  and before the application starts , I will look into the .ini for the lastsize??
> 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.


ASKER CERTIFIED SOLUTION
Avatar of heyhey_
heyhey_

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial