Solved

JFrame listen to a resize event?

Posted on 2003-10-28
4
776 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best environment for cross platform web development? 5 101
SequenceInputStream example 3 39
restrict decimal places for double datatype 10 50
DTD and JAVA versions 1 59
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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

752 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