Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

JFrame listen to a resize event?

Posted on 2003-10-28
4
Medium Priority
?
779 Views
Last Modified: 2013-11-23
Hello,

 Every time I drag and expand my JFrame it does not seem to respond to the events I used. Is there a way I can listen for the resize event of a JFrame and check to see if both the height and width are the same. If they are not force a automatic adjustment to make the JFrame have both the same height and width using the smaller of the two to set the other? A simple example would be great. Thank you.
0
Comment
Question by:entercite
2 Comments
 
LVL 1

Accepted Solution

by:
nex1999 earned 100 total points
ID: 9637243
try adding a Component Listener:

        this.addComponentListener(new ComponentAdapter()
        {
              public void componentResized(ComponentEvent event)
              {
                   if(getWidth() < getHeight() )
            setSize(getWidth(), getWidth() );
          else
                      setSize(getHeight(), getHeight() );
                   repaint();
              }
          });
0
 
LVL 2

Assisted Solution

by:Tols
Tols earned 100 total points
ID: 9640108
If You want to see components resizing during Frame resize:

this.getToolkit().setDynamicLayout(true);

Just a tip. :-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses

824 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