20-CS-694 Advanced Programming Techniques Spring 2012

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

       Previous     Next     Applet Source     All lectures

TextFields - Use method to set TextField property

Grid layout showing three JButtons in the top row and three JTextFields in the bottom row

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

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

   public Prog3Frame () {
      setLayout(new GridLayout(2,3));
      add (a = new JButton("One,One"));
      add (b = new JButton("One,Two"));
      add (c = new JButton("Two,One"));
      add (d = new JTextField("Nothing Yet"));
      add (e = new JTextField("Nothing Yet"));
      add (f = new JTextField("Nothing Yet"));

public class Prog3 extends Applet {
   public void init () {
      Prog3Frame pf = new Prog3Frame();