how to use the current frame size.

Posted on 2002-05-11
Last Modified: 2010-03-31
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??

Question by:TLTEO
  • 5
  • 3
LVL 16

Expert Comment

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

Author Comment

ID: 7005118
do you have any example to do it??
LVL 16

Expert Comment

ID: 7005427

what part do you need help with ?
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.


Author Comment

ID: 7006840
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");
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?

LVL 16

Expert Comment

ID: 7007807
// 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);

Author Comment

ID: 7009253
so actually I will also save the lastsize in .ini,  and before the application starts , I will look into the .ini for the lastsize??
LVL 16

Expert Comment

ID: 7010365
> 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.

LVL 16

Accepted Solution

heyhey_ earned 100 total points
ID: 7010371
you can use Properties object to quickly load and save configuration data.

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java SE 8u111  Lot of stuff broke 11 68
even odd program using while loop 3 40
table example 4 29
servlet example issue 6 38
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now