Privacy Policy Terms Of Use. Copyright © 2006-2010 Java Tutorials and Examples.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
- /*
- Layout Manager
- ~~~~~~~~~~~~~~
- FlowLayout
- ==========
- FlowLayout()
- FlowLayout(int how)
- FlowLayout(int how, int horz,int vert)
- =========================================
- FlowLayout.LEFT
- FlowLayout.RIGHT
- FlowLayout.CENTER
- ======================================
- */
- import java.awt.*;
- import java.awt.event.*;
- import java.applet.*;
- /*
- <applet CODE = "FLDemo" width = 600 height = 400>
- </applet>
- */
- public class FLDemo extends Applet implements ItemListener
- {
- String msg = "";
- Checkbox Monitor, Processor, Keyboard, Mouse;
- public void init()
- {
- setLayout(new FlowLayout());
- Monitor = new Checkbox("MONITOR");
- Processor = new Checkbox("Processor P4");
- Keyboard= new Checkbox("TVSE GOLD");
- Mouse= new Checkbox("Logitech");
- add(Monitor);
- add(Processor);
- add(Mouse);
- add(Keyboard);
- Monitor.addItemListener(this);
- Processor.addItemListener(this);
- Mouse.addItemListener(this);
- Keyboard.addItemListener(this);
- }
- public void itemStateChanged(ItemEvent ce)
- {
- msg = "";
- if(Processor.getState())
- {
- msg += "Processor";
- }
- if(Monitor.getState())
- {
- msg += "Monitor";
- }
- if(Keyboard.getState())
- {
- msg += "KeyBoard";
- }
- if(Mouse.getState())
- {
- msg += "Mouse";
- }
- repaint();
- }
- public void paint(Graphics g)
- {
- g.drawString("You have Purchased : " + msg, 50,100);
- }
- }

Post new comment