Category Archives: JAVA AWT & Enents

How to close AWT Window in Java

How to close AWT Window in Java We can close the AWT Window or Frame by calling dispose() or System.exit() inside windowClosing() method. The windowClosing() method is found in WindowListener interface and WindowAdapter class. The WindowAdapter class implements WindowListener interfaces. It provides the default implementation of all the 7 methods of WindowListener interface. To override the windowClosing() method, you can either use WindowAdapter […]

java for beginners
java for beginners
java for beginners
CodSir //course // books
...

WikiSir

How to close AWT Window in Java We can close the AWT Window or Frame by calling dispose() or System.exit() inside windowClosing() method. The windowClosing() method is found in WindowListener interface and WindowAdapter class. The WindowAdapter class implements WindowListener interfaces. It provides the default implementation of all the 7 methods of WindowListener interface. To override the windowClosing() method, you can either use WindowAdapter […]

Tags:

....
...

Java Adapter Classes

Java Adapter Classes Java adapter classes provide the default implementation of listener interfaces. If you inherit the adapter class, you will not be forced to provide the implementation of all the methods of listener interfaces. So it saves code. The adapter classes are found in java.awt.event, java.awt.dnd and javax.swing.event packages. The Adapter classes with their corresponding listener interfaces are given below. java.awt.event […]

java for beginners
java for beginners
java for beginners
CodSir //course // books
...

WikiSir

Java Adapter Classes Java adapter classes provide the default implementation of listener interfaces. If you inherit the adapter class, you will not be forced to provide the implementation of all the methods of listener interfaces. So it saves code. The adapter classes are found in java.awt.event, java.awt.dnd and javax.swing.event packages. The Adapter classes with their corresponding listener interfaces are given below. java.awt.event […]

Tags:

....
...

Java WindowListener Interface

Java WindowListener Interface The Java WindowListener is notified whenever you change the state of window. It is notified against WindowEvent. The WindowListener interface is found in java.awt.event package. It has three methods. Methods of WindowListener interface The signature of 7 methods found in WindowListener interface are given below: public abstract void windowActivated(WindowEvent e); public abstract void windowClosed(WindowEvent e); public abstract void windowClosing(WindowEvent e); public abstract void windowDeactivated(WindowEvent e); public abstract void windowDeiconified(WindowEvent e); public abstract void windowIconified(WindowEvent e); public abstract void windowOpened(WindowEvent e); […]

java for beginners
java for beginners
java for beginners
CodSir //course // books
...

WikiSir

Java WindowListener Interface The Java WindowListener is notified whenever you change the state of window. It is notified against WindowEvent. The WindowListener interface is found in java.awt.event package. It has three methods. Methods of WindowListener interface The signature of 7 methods found in WindowListener interface are given below: public abstract void windowActivated(WindowEvent e); public abstract void windowClosed(WindowEvent e); public abstract void windowClosing(WindowEvent e); public abstract void windowDeactivated(WindowEvent e); public abstract void windowDeiconified(WindowEvent e); public abstract void windowIconified(WindowEvent e); public abstract void windowOpened(WindowEvent e); […]

Tags:

....
...

Java KeyListener Interface

Java KeyListener Interface The Java KeyListener is notified whenever you change the state of key. It is notified against KeyEvent. The KeyListener interface is found in java.awt.event package. It has three methods. Methods of KeyListener interface The signature of 3 methods found in KeyListener interface are given below: public abstract void keyPressed(KeyEvent e); public abstract void keyReleased(KeyEvent e); public abstract void keyTyped(KeyEvent e); Java KeyListener Example import java.awt.*; […]

java for beginners
java for beginners
java for beginners
CodSir //course // books
...

WikiSir

Java KeyListener Interface The Java KeyListener is notified whenever you change the state of key. It is notified against KeyEvent. The KeyListener interface is found in java.awt.event package. It has three methods. Methods of KeyListener interface The signature of 3 methods found in KeyListener interface are given below: public abstract void keyPressed(KeyEvent e); public abstract void keyReleased(KeyEvent e); public abstract void keyTyped(KeyEvent e); Java KeyListener Example import java.awt.*; […]

Tags:

....
...

Java ItemListener Interface

Java ItemListener Interface The Java ItemListener is notified whenever you click on the checkbox. It is notified against ItemEvent. The ItemListener interface is found in java.awt.event package. It has only one method: itemStateChanged(). itemStateChanged() method The itemStateChanged() method is invoked automatically whenever you click or unclick on the registered checkbox component. public abstract void itemStateChanged(ItemEvent e); Java ItemListener Example […]

java for beginners
java for beginners
java for beginners
CodSir //course // books
...

WikiSir

Java ItemListener Interface The Java ItemListener is notified whenever you click on the checkbox. It is notified against ItemEvent. The ItemListener interface is found in java.awt.event package. It has only one method: itemStateChanged(). itemStateChanged() method The itemStateChanged() method is invoked automatically whenever you click or unclick on the registered checkbox component. public abstract void itemStateChanged(ItemEvent e); Java ItemListener Example […]

Tags:

....
...

Java MouseMotionListener Interface

Java MouseMotionListener Interface The Java MouseMotionListener is notified whenever you move or drag mouse. It is notified against MouseEvent. The MouseMotionListener interface is found in java.awt.event package. It has two methods. Methods of MouseMotionListener interface The signature of 2 methods found in MouseMotionListener interface are given below: public abstract void mouseDragged(MouseEvent e); public abstract void mouseMoved(MouseEvent e); Java MouseMotionListener Example import java.awt.*; import java.awt.event.*; public class MouseMotionListenerExample extends Frame implements MouseMotionListener{ […]

java for beginners
java for beginners
java for beginners
CodSir //course // books
...

WikiSir

Java MouseMotionListener Interface The Java MouseMotionListener is notified whenever you move or drag mouse. It is notified against MouseEvent. The MouseMotionListener interface is found in java.awt.event package. It has two methods. Methods of MouseMotionListener interface The signature of 2 methods found in MouseMotionListener interface are given below: public abstract void mouseDragged(MouseEvent e); public abstract void mouseMoved(MouseEvent e); Java MouseMotionListener Example import java.awt.*; import java.awt.event.*; public class MouseMotionListenerExample extends Frame implements MouseMotionListener{ […]

Tags:

....
...

Java MouseListener Interface

Java MouseListener Interface The Java MouseListener is notified whenever you change the state of mouse. It is notified against MouseEvent. The MouseListener interface is found in java.awt.event package. It has five methods. Methods of MouseListener interface The signature of 5 methods found in MouseListener interface are given below: public abstract void mouseClicked(MouseEvent e); public abstract void mouseEntered(MouseEvent e); public abstract void mouseExited(MouseEvent e); public abstract void mousePressed(MouseEvent e); public abstract void mouseReleased(MouseEvent e); Java MouseListener […]

java for beginners
java for beginners
java for beginners
CodSir //course // books
...

WikiSir

Java MouseListener Interface The Java MouseListener is notified whenever you change the state of mouse. It is notified against MouseEvent. The MouseListener interface is found in java.awt.event package. It has five methods. Methods of MouseListener interface The signature of 5 methods found in MouseListener interface are given below: public abstract void mouseClicked(MouseEvent e); public abstract void mouseEntered(MouseEvent e); public abstract void mouseExited(MouseEvent e); public abstract void mousePressed(MouseEvent e); public abstract void mouseReleased(MouseEvent e); Java MouseListener […]

Tags:

....
...

Java ActionListener Interface

Java ActionListener Interface The Java ActionListener is notified whenever you click on the button or menu item. It is notified against ActionEvent. The ActionListener interface is found in java.awt.event package. It has only one method: actionPerformed(). actionPerformed() method The actionPerformed() method is invoked automatically whenever you click on the registered component. public abstract void actionPerformed(ActionEvent e); Java ActionListener Example: […]

java for beginners
java for beginners
java for beginners
CodSir //course // books
...

WikiSir

Java ActionListener Interface The Java ActionListener is notified whenever you click on the button or menu item. It is notified against ActionEvent. The ActionListener interface is found in java.awt.event package. It has only one method: actionPerformed(). actionPerformed() method The actionPerformed() method is invoked automatically whenever you click on the registered component. public abstract void actionPerformed(ActionEvent e); Java ActionListener Example: […]

Tags:

....
...

Java AWT Toolkit

Java AWT Toolkit Toolkit class is the abstract superclass of every implementation in the Abstract Window Toolkit. Subclasses of Toolkit are used to bind various components. It inherits Object class. AWT Toolkit class declaration public abstract class Toolkit extends Object Java AWT Toolkit Example import java.awt.*; public class ToolkitExample {   public static void main(String[] args) {       Toolkit t = Toolkit.getDefaultToolkit();       System.out.println(“Screen resolution = “ + t.getScreenResolution());       Dimension d = t.getScreenSize();       System.out.println(“Screen width = “ + d.width);       System.out.println(“Screen height = “ + d.height);   } } Output: Screen resolution = 96 Screen […]

java for beginners
java for beginners
java for beginners
CodSir //course // books
...

WikiSir

Java AWT Toolkit Toolkit class is the abstract superclass of every implementation in the Abstract Window Toolkit. Subclasses of Toolkit are used to bind various components. It inherits Object class. AWT Toolkit class declaration public abstract class Toolkit extends Object Java AWT Toolkit Example import java.awt.*; public class ToolkitExample {   public static void main(String[] args) {       Toolkit t = Toolkit.getDefaultToolkit();       System.out.println(“Screen resolution = “ + t.getScreenResolution());       Dimension d = t.getScreenSize();       System.out.println(“Screen width = “ + d.width);       System.out.println(“Screen height = “ + d.height);   } } Output: Screen resolution = 96 Screen […]

Tags:

....
...

Java AWT Dialog

Java AWT Dialog The Dialog control represents a top level window with a border and a title used to take some form of input from the user. It inherits the Window class. Unlike Frame, it doesn’t have maximize and minimize buttons. Frame vs Dialog Frame and Dialog both inherits Window class. Frame has maximize and […]

java for beginners
java for beginners
java for beginners
CodSir //course // books
...

WikiSir

Java AWT Dialog The Dialog control represents a top level window with a border and a title used to take some form of input from the user. It inherits the Window class. Unlike Frame, it doesn’t have maximize and minimize buttons. Frame vs Dialog Frame and Dialog both inherits Window class. Frame has maximize and […]

Tags:

....
...