GK Informatik

Arbeitsblatt JAVA9c

AWT-Layout (3)

JSt. 11/2

NAME:

 

UI-Komponenten

Das folgende Applett stellt Ihnen alle UI-Komponenten vor.

import java.applet.*;

import java.awt.*;

public class LayoutKomponenten extends Applet

{ FlowLayout myFlow = new FlowLayout();

Label MyLabel = new Label("Das ist ein Testlabel");

TextField myTextField = new TextField("voreingestellter Text");

Button myButton = new Button("Drück mich");

CheckboxGroup myCbg = new CheckboxGroup();

List myList = new List(4, false);

Choice myChoice = new Choice();

TextArea myTextArea = new TextArea("Hallo", 5, 40);

Scrollbar myScroller1 = new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, 255);

Scrollbar myScroller2 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 64, 0, 255);

 

public void init()

{

resize(640, 480);

setLayout(myFlow);

add(MyLabel);

add(myTextField);

add(myButton);

add(new Checkbox("Radiobutton Eins", myCbg, true));

add(new Checkbox("Radiobutton Zwei", myCbg, false));

add(new Checkbox("Radiobutton Drei", myCbg, false));

add(new Checkbox("Ankreuzfeld Eins", null, true));

add(new Checkbox("Ankreuzfeld Zwei", null, false));

myList.addItem("Merkur");

myList.addItem("Venus");

myList.addItem("Erde");

myList.addItem("Mars");

myList.addItem("Jupiter");

myList.addItem("Saturn");

myList.addItem("Uranus");

myList.addItem("Neptun");

myList.addItem("Pluto");

add(myList);

myChoice.addItem("Grün");

myChoice.addItem("Rot");

myChoice.addItem("Blau");

add(myChoice);

add(myTextArea);

add(myScroller1);

add(myScroller2);

}

}


© Ralph-Erich Hildebrandt, Neuss / April 1999