Frame Awt in Java

Using frame awt in java programming.

Frame awt in java

Using Frame awt in java for graphics can be very easy and while java also provides other means like applet to design and embed components like buttons frame awt is used for graphics in java applications.

Here is a simple example that shows the usage of frame awt without any components added to the frame. Frame of size 300 by 300, using FlowLayout and visible property.

import java.awt.*;

import java.io.*;

class FrameDemo

{

            Frame f;

            public FrameDemo()

            {

                        f=new FrameDemo();

            }

            public void configure()

            {

                        f.setVisible(true);

                        f.setSize(300,300);

                        f.setLayout(new FlowLayout());

            }

            public static void main(String args[])

            {

                        new FrameDemo().configure();

            }

}

In the above frame awt example an object of frame is defined at class level and initialized inside the constructer. Methods for frame awt to set its visible property to true and size as well as layout are called in configure method. Constructor and the configure method at the same time is called by main method.

One Response

09.10.04

good

very good

Leave Your Response