Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to catch window maximised event ?

Status
Not open for further replies.

sergeiY

Programmer
Feb 13, 2003
132
AU
I know I need to creat class that will implement WindowListener. But what even should I catch ?? And also... I need to restrict this function... so my window can't be maximised... how do i do this ? Any hints ??? Please help.
 
Actually, if you add a ComponentListener to your frame, you can use the ComponentResized method:
Code:
this.addComponentListener(new java.awt.event.ComponentAdapter()
{
  public void componentResized(ComponentEvent e)
  {
     //handle
  }
});
 
if your class implements WindowListener, you'll have to implement these methods:
public void windowClosing(WindowEvent e)
public void windowClosed(WindowEvent e)
public void windowOpening(WindowEvent e)
public void windowOpened(WindowEvent e)
public void windowActivated(WindowEvent e)
public void windowDeactivated(WindowEvent e)
public void windowIconified(WindowEvent e)
public void windowDeiconified(WindowEvent e)

I usually implement all the methods in blank except the windowClosing. I usually use System.exit(0) or this.dispose() if its a multiframe app.

When I don't want the window to be maximized I use setResizable(false).

I don't know if that's what you were asking for but I hope it helps.
 
Thank you all for your help

I found what I was looking for myself:

myframe.setResizable (false);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top