DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2005
    Posts
    9

    Question how to track window maximisation ???

    hi...

    i want to perform some operations when my frame is maximized and also when it is restored. how can i do this by using window listeners. i did n't see any method such as windowMaximised in the window listener. pls help

    thanx....

    sanu

  2. #2
    Join Date
    Jan 2005
    Location
    Reisterstowwn, MD
    Posts
    72
    Quote Originally Posted by sanu
    hi...

    i want to perform some operations when my frame is maximized and also when it is restored. how can i do this by using window listeners. i did n't see any method such as windowMaximised in the window listener. pls help

    thanx....

    sanu
    http://java.sun.com/j2se/1.5.0/docs/...ndowEvent.html
    http://java.sun.com/j2se/1.5.0/docs/...eListener.html

    look at the getNewState method. You need to use a WindowStateListener to montior the state of your window. You then use getNewState to check whther it has been maximized or restored. Here is some sample code to show you:

    Code:
    public class WindowFrame extends JFrame implements WindowStateListener{
    	
    	public WindowFrame(){
    		this.addWindowStateListener(this);
    	
    	}
    
    	public void windowStateChanged(WindowEvent arg0) {
    		if(arg0.getNewState()==NORMAL)
    			System.out.println("restored");
    		else if(arg0.getNewState()==MAXIMIZED_BOTH)
    			System.out.println("max");
    	}
    	
    	
    }
    Hope that helps.
    Java has 99 problems but a pointer ain't one

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links