Login    New User    Forgot Password    Help      

Flow Layout

Java Tutorials

Example

// flow layout

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

/*
<applet code="control9" width=250 height=300>

</applet>
*/
public class control9 extends Applet implements ItemListener
{

String msg="";
Checkbox oracle,access,foxpro,dbase;
public void init()
{
setLayout (new FlowLayout (FlowLayout.LEFT));

oracle=new Checkbox("Oracle",null,true);
access=new Checkbox("Access");
foxpro=new Checkbox("Foxpro");
dbase=new Checkbox("Dbase");

add(oracle);
add(access);
add(foxpro);
add(dbase);

oracle.addItemListener(this);
access.addItemListener(this);
foxpro.addItemListener(this);
dbase.addItemListener(this);
}

public void itemStateChanged(ItemEvent ie)
{
repaint();
}
public void paint(Graphics g)
{
msg="Oracle" + oracle.getState();
g.drawString(msg,6,100);

msg="Access "+ access.getState();
g.drawString(msg,6,120);

msg="Foxpro "+ foxpro.getState();
g.drawString(msg,6,140);

msg="D Base "+ dbase.getState();
g.drawString(msg,6,160);

}
}

Output

Output in applet

Java Tutorials