954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Closing window

hi i am a beginner in java language...the below program has should close the window created but it is just minimising,and maximasing the window i am using Edit+ v3.12

import java.awt.*;
import java.awt.Label;
import java.awt.AWTEvent;
import java.awt.event.WindowEvent;

public class HowdyByeWindow extends Frame  
{
	public static void main(String args[])
	{
	 new HowdyByeWindow();
    }
HowdyByeWindow() 
	{
	Label label;
	label=new Label("Howdy!");
	add(label);
	pack();
	show();
	}
public void processWindowEvent(WindowEvent event)
	{
	if(event.getID()== WindowEvent.WINDOW_CLOSING)
	   System.exit(0);
	}

}
garnier4i
Newbie Poster
1 post since May 2010
Reputation Points: 8
Solved Threads: 0
 

Your processWindowEvents won't be called because you have not enabled window events nor registered a listener. See:

http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Window.html#processWindowEvent%28java.awt.event.WindowEvent%29

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You