Awt GUI Components

Advertisements

Prev Tutorial Next Tutorial

non-container classes

These are the predefined classes used to design the input field so that end user can provide input value to communicate with java program, these are also treated as GUI component.

Label

It can be any user defined name used to identify input field like textbox, textarea etc.

Example

Label l1=new Label("uname");
Label l2=new Label("password");

TextField

This class can be used to design textbox.

Example

TextField tf=new TextField();

Example

TextField tf=new TextField(40);

Button

This class can be used to create a push button.

Example

Button b1=new Button("submit");
Button b2=new Button("cancel");

TextArea

This class can be used to design a textarea, which will accept number of characters in rows and columns formate.

Example

TextArea ta=new TextArea(5, 10);
// here 5 is no. of rows and 10 is no. of column

Note: In above example at a time we can give the contains in textarea is in 5 rows and 9 column (n-1 columns).

Checkbox

This class can be used to design multi selection checkbox.

Example

Checkbox cb1=new Checkbox(".net");
Checkbox cb2=new Checkbox("Java");
Checkbox cb3=new Checkbox("html");
Checkbox cb4=new Checkbox("php");

CheckboxGroup

This class can be used to design radio button. Radio button is used for single selection.

Example

CheckboxGroup cbg=new CheckboxGroup();
Checkbox cb=new Checkbox("male", cbg, "true");
Checkbox cb=new Checkbox("female", cbg, "false");

Note: Under one group many number of radio button can exist but only one can be selected at a time.

Choice

This class can be used to design a drop down box with more options and supports single selection.

Example

Choice c=new Choice();
c.add(20);
c.add(21);
c.add(22);
c.add(23);

List

This class can be used to design a list box with multiple options and support multi selection.

Example

List l=new List(3);
l.add("goa");
l.add("delhi");
l.add("pune");

Note: By holding clt button multiple options can be selected.

Scrollbar

This class can be used to display a scroolbar on the window.

Example

Scrollbar sb=new Scrollbar(type of scrollbar, initialposition, thamb width, minmum value, maximum value);
  • Initial position represent very starting point or position of thumb.
  • Thumb width represent the size of thumb which is scroll on scrollbar
  • Minimum and maxium value represent boundries of scrollbar

Type of scrollbar

There are two types of scrollbar are available;

  • scrollbar.vertical
  • scrollbar.horizental

Example

Scrollbar sb=new Scrollbar(Scrollbar.HORIZENTAL, 10, 5, 0, 100);

Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements