Tuesday, 25 February 2014

WORKING WITH FRAME WINDOWS

HOW TO MAKE FRAMES(MAIN WINDOW)


How to Creating a frame window in an applet

   Creating a new frame window from within an applet is actually quite easy. First, create a subclass of Frame. Next, override any of the standard applet methods, such as init( ), start( ), and stop( ), to show or hide the frame as needed. Finally, implement the windowClosing( ) method of the WindowListener interface, calling setVisible(false) when the window is closed.After the applet, the type of window you will most often create is derived from Frame.

Frame’s constructors are as follows:

Frame( )
Frame(String title)

    The first form creates a standard window that does not contain a title.The second form creates a window with the title specified by title. We cannot specify the dimensions of the window. We must set the size of the window after it has been created. Some of the methods used when working with windows are as follows:

SETTING THE WINDOW'S DIMENSIONS:

The setSize( ) method is used to set the dimensions of the window.

Its signature is shown here:

                       void setSize(int newWidth, int newHeight)
                       void setSize(Dimension newSize)


The new size of the window is specified by newWidth and newHeight, or by the width and height fields of the Dimension object passed in newSize. The dimensions are specified in terms of pixels.


The getSize( ) method is used to obtain the current size of a window.

Its signature is shown here:

               Dimension getSize( )

This method returns the current size of the window contained within the width and height fields of a Dimension object.

HIDING AND SHOWING A WINDOW:


After a frame window has been created, it will not be visible until you call setVisible( ). 

Its signature is shown here:

                     void setVisible(boolean visibleFlag)
The component is visible if the argument to this method is true. Otherwise, it is hidden.

SETTING A WINDOW'S TITLE:


You can change the title in a frame window using setTitle( ).
Its signature is shown here:

void setTitle(String newTitle)

Here, newTitle is the new title for the window.

CLOSING A FRAME WINDOW:

        When using a frame window, your program must remove that window from the screen when it is closed, by calling setVisible(false). To intercept a window-close event, you must implement the windowClosing( ) method of the WindowListener interface. Inside windowClosing( ), you must remove the window from the screen.


1 comment :

  1. This process is definitely confidently seriously the best choice. Every one with incredibly small streaks will be expected via a variety of tradition capabilities. I like to recommend software program such a large amount. fensterversand

    ReplyDelete