Saturday 28 April 2018

java frame component

java frame component

a frame component is an object that can be displayed on the screen and
can interact with the user. Frame  has a visual representation in a screen window .
the frame class provides windows for applets and applications. the following program
show the frame figure.
import java.awt.*;
class frame
{
public static void main(String agrs[])
{
Frame f=new Frame("this is internationaly youth acuity java frame");
f.setBackground(Color.red);
f.setSize(300,400);
f.setVisible(true);
System.out.println("Return to dos prompt and press control+c for quit you international java program");
}
}
In this program we create frame and set the title as this is international youth acuity java frame and
to determine the size of the frame by setSize() method and set the background color by set Background()
method .the size is 300 pixel wide and 400 pixel height. the frame invoke the setVisible() method to display
on the computer screen  .
frame does not close directly.so come to dos prompt and press control+c or you click dos prompt windows for close
java frame programs.

this program written in other forms as follows
import java.awt.*;
class myframe extends Frame
{
   Frame f;   
myframe()
{
  
super("this is my new frame");
f.setBackground(Color.red);
f.setSize(300,400);
setCursor(Frame.HAND_CURSOR);
show();
}
public static void main(String args[])
{
new myframe();
System.out.println("Return to dos promt and press control+c for quit you internationl java program");
}
}
the frame class consist of a method setCuursor(int),this method is used to set the cursor type. The cursor must be in one of the following
type.it is deprecate method.
DEFAULT_CURSOR
TEXT_CURSOR
SW_RESIZE_CURSOR
NW_RESIZE_CURSOR
N_RESIZE_CURSOR
W_RESIZE_CURSOR
HAND_CURSOR
NORMAL
CROSSHAIR_CURSOR
WAIT_CURSOR
SE_RESIZE_CURSOR
NE_RESIZE_CURSOR
S_RESIZE_CURSOR
E_RESIZE_CURSOR
MOVE_CURSOR
ICONIFIED

0 comments:

Post a Comment