Frame class in java.awt package: Types of constructors, Methods

Frame class in java.awt package is used to create a window having borders, title bar, re-size corners, and a menu bar. It is a sub class of Window class.

Types of constructors defined by Frame class:

Type-1: To create a window without title.

Frame( )

Type-2: To create a window with title.

Frame(String title)

Methods defined by Frame class:

setSize( ) method: It is used to set dimensions of window.


void setSize(int width, int height)

By using size:

void setSize(Dimension size)

getSize( ) method: It is used to get the current window size.


Dimension getSize( )

setVisible( ) method: It is used to show a window.

void setVisible(boolean vflag)

setTitle( ) method: It is used to set a new title for a window.


void setTitle(String title)

Leave a Reply