20-CS-694 Advanced Programming Techniques Spring 2012

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

       Previous     Next     Applet Source     All lectures

Another Applet - GridLayout

Grid layout with 2 rows, 3 columns, all sections populated with JButtons

import java.awt.*;          // For the GridLayout class
import javax.swing.*;       // For the JButton class
import java.applet.*;       // For the Applet class

class Prog2Frame extends JFrame {
   JButton a,b,c,d,e,f;

   public Prog2Frame () {
      setLayout(new GridLayout(2,3));
      add (a = new JButton("One,One"));
      add (b = new JButton("One,Two"));
      add (c = new JButton("One,Three"));
      add (d = new JButton("Two,One"));
      add (e = new JButton("Two,Two"));
      add (f = new JButton("Two,Three"));

public class Prog2 extends Applet {
   public void init () {
      Prog2Frame pf = new Prog2Frame();