Component Class Assignment Help

Assignment Help: >> AWT GUI Components - Component Class

Component Class:

All non-menu-related elements which comprise a graphical user interface are derived from the abstract class Component. A Component class specifies a huge assortment of functions for handling events, modifying window bounds, controlling fonts and colors and drawing components and their contents. Component uses the visual properties (font face, background color, foreground color and many more.) of its parent container, unless set explicitly for the component.

The given utility methods are provided through component and its sub class:

Dimension getSize ( )

void setSize (int width, int height)

void setSize (Dimension d)

The getSize( ) function could be used to get the size of a component in pixels. The return object is of type Dimension that has two public data members' width, and height. A setSize( ) methods could be used to set the size of a component in pixels.

point getLocation ( )

void setLocation ( int x, int y)

void setLocation (Point p)

The getLocation ( ) method returns the coordinates of the top-left corner of the component. A return object is of type point, that has two public data members x and y.  SetLocation methods could be used to move the component to the specified locations

Rectangle getBounds( )

void setBounds(int x, int y, int width, int height)

void setBounds (Rectangle r)

A getBounds ( ) function can be used to get the bounds of a component (in size and location both).   A return object is of type Rectangle that has four public data members: x, y, height and width.  A setBounds ( ) methods could be used to set the bounds of a component

void setForeground(Color c)

void setBackground(Color c)

The setForground( ) method could be used to set the foreground color of a component. A setBackground ( ) method could be used to set the background color of a component.  Commonly the background colors are used to fill the area occupied through the component and text is rendered in the component's area by using the foreground color.

The corresponding values from this component's instant container are used if foreground and background colors are not explicitly specified for a component.

Font getFont ( )

void setFont( Font f)

A getFont( ) method returns the font used for rendering the text in a component. The setFont ( ) method could be used to set a particular font.

void setEnabled(boolean b)

the component acts as normal if the argument of this method is true, that is it is enabled and can respond to user input and produce events. The component appears grayed out and does not respond to external stimuli if the arguments are false. All components are initially enabled

void setVisible(boolean b)

A component is either displays on the screen or hidden, depending on the argument to this method being either true or false correspondingly. It influences the visibility of the child components except for Frame, window, and Dialog classes whose object must explicitly be made visible through this method.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd