Solved

JFrame listen to a resize event?

Posted on 2003-10-28
4
777 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
[X]
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
4 Comments
 
LVL 1

Accepted Solution

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

this.getToolkit().setDynamicLayout(true);

Just a tip. :-)
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

630 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