Sie sind auf Seite 1von 3

import java.io.

*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

/*<applet code=bang2.class width=300 height=400></applet>*/

class frame1 extends frame


{
frame1(string title)
{
super(title);
mywindowadapter ad=new mywindowadapter(this);
addwindowlistener(ad);
}
public void paint(graphics g)
{
g.drawstring("this is a frame window",10,40);
}
}

class mywindowadapter extends windowadapter


{
frame1 f1;
public mywindowadapter(frame1 f1)
{
this.f1=f1;
}
public void windowclosing(windowevent we)
{
f1.setvisible(false);
}

public class bang2 extends applet implements


actionlistener,itemlistener
{

label customer,deposit,accno,widthdraw;
textfield cust,dept,number,draw;
textarea t;
choice type;
checkbox yes,nu;
checkboxgroup te;

frame f;

button b;

public void init()


{

f=new frame1("a frame window");


f.setsize(250,250);
f.setvisible(true);
setbackground(color.yellow);
setforeground(color.red);

customer=new label("customer");
deposit=new label("deposit");
accno=new label("account number");
widthdraw=new label("widthdraw");

cust=new textfield(20);
dept=new textfield(20);
number=new textfield(20);
draw=new textfield(20);

type=new choice();
type.add("fixed");
type.add("rd");
// type.add("second class");

te=new checkboxgroup();
yes=new checkbox(te,"yes",false);
nu=new checkbox(te,"no",false);

t=new textarea(40,45);

b=new button("submit");

add(customer);
add(cust);

add(accno);
add(number);

add(deposit);
add(dept);

add(widthdraw);
add(draw);

add(type);
add(b);

add(yes);
add(nu);

add(t);

b.addactionlistener(this);
type.additemlistener(this);
}

public void actionperformed(actionevent ae)


{
if(ae.getactioncommand().equals("submit"))
{
t.settext("name: "+cust.gettext()+"
"+"account number : "+
number.gettext()+"

"+"deposit
amount
: "+dept.gettext()+"

"+
"type of account : "+type.getselecteditem());
}
}

public void itemstatechanged(itemevent ie)


{

}
}

Das könnte Ihnen auch gefallen