20-CS-694 Advanced Programming Techniques Spring 2012

Interfaces, Exceptions, Graphics, Animation, Threads, Reflection, Networking, RMI, JDBC, JNI

       Previous     Next     Applet Source     All lectures

BorderLayout With Gaps & TextArea

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

class BLGAT extends JFrame implements ActionListener {
   JButton doit;
   JTextArea text;

   public BLGAT () {
      setLayout(new BorderLayout(20,20));
      add("North",new JButton("North"));
      add("South",doit = new JButton("South"));
      add("East",new JButton("East"));
      add("West",new JButton("West"));
      add("Center",new JScrollPane(text = new JTextArea()));

   public void actionPerformed (ActionEvent evt) {
      for (int i=0 ; i < 50 ; i++)
	 text.append("Now is the "+i+"th time to come to the party's aid\n");

public class blgat extends Applet {
   BLGAT b;

   public void init () {
      b = new BLGAT();

   public void finalize () {  b.dispose();  }