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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 ?
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
couple of eclipse 5 53
hibernate insert example 13 40
add projects t working set in maven 2 44
Pass multiple values or string arrays in java as a parameter 3 49
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to implement Singleton Design Pattern in Java.

730 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