how to track window maximisation ???


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: how to track window maximisation ???

  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

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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center