Solved

JFrame listen to a resize event?

Posted on 2003-10-28
4
771 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
4 Comments
 
LVL 1

Accepted Solution

by:
nex1999 earned 25 total points
Comment Utility
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 25 total points
Comment Utility
If You want to see components resizing during Frame resize:

this.getToolkit().setDynamicLayout(true);

Just a tip. :-)
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

771 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