FlowLayout1.java


</COMMENT> No Java 2 support for APPLET!!

import       javax.swing.*;
import          java.awt.*;
import          java.awt.event.*;
import          javax.swing.border.*;
import          com.bruceeckel.swing.*;
import          java.io.*;
import          java.net.*;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.border.TitledBorder;

public class FlowLayout1 extends JApplet {
    Container cp ;
    ActionListener BAction = new ActionListener() {
    public void actionPerformed(ActionEvent e){
      JButton b = (JButton)e.getSource();
      cp.remove(b);
      cp.repaint();

    }
  };

  public void init() {
    cp = getContentPane();
    cp.setLayout(new FlowLayout());
    for(int i = 0; i < 20; i++) {
      JButton b = new JButton ("Button " + i);
      b.addActionListener(BAction);
      cp.add(b);
    }
  }
  public static void main(String[] args) {
    Console.run(new FlowLayout1(), 300, 250);
  }
} ///:~