by Dinesh Thakur Category: AWT and Applets

addWindowListener method is used to add the windowlistener interface to the window. WindowClosing is a predefined method of WindowListener interface present in java.awt package. exit is a predefined static method present in System class, used to terminate the currently running java. syntax-public static void exit (int status)

Toolkit class is abstract class present in java.awt package. It toolkit is predefined method present in Toolkit class. This method is used to create the object of Toolkit class. Syntax-public static Toolkit getDefaultToolkit ().

getImage is a predefined abstract method present in Toolkit class. Return type of this method is Image class object. Syntax-public abstract Image getImage ( URL)

drawImage and drawString are abstract methods present in Graphics class. These methods are used to draw an image and string respectively. Syntax-public abstract boolean drawImage (Image image, int, int, java. awt. image.ImageObserver) public abstract void drawString (String s, int, int)
setSize is a predefined method present in Frame class , used to set the size of the frame. setVisible is a predefined method present in Frame class, used to make the frame visible. setLocation is a predefined method present in Frame class, used to set the frame at a particular position.

Here is the Java Example for getDefaultToolkitExample:

import java.awt.*;

import java.awt.event.*;
public class getDefaultToolkitExample extends Frame
              Image image;
              String Picture = "DineshThakur.jpg";
              public getDefaultToolkitExample ()
                       addWindowListener(new WindowAdapter()
                                public void windowClosing(WindowEvent we)
                              public void paint(Graphics g)
                                    Toolkit tool = Toolkit.getDefaultToolkit();
                                     image = tool.getImage(Picture);
                              public static void main(String args []) throws Exception
                                          getDefaultToolkitExample image = new getDefaultToolkitExample();
                                          image.setTitle("Toolkit.getDefaultToolkit().getImage Example");

Toolkit.getDefaultToolkit().getImage in Java Example

Popular Article