Source of AdderDialog1.java


  1: import javax.swing.*;
  2: import java.awt.*;

  4: /**
  5:  * AdderDialog1 is a mock-up for a number-adding GUI.
  6:  *
  7:  * @author Mark Young (A00000000)
  8:  */

 10: public class AdderDialog1 extends JFrame {

 12:     /**
 13:      * Create an AdderDialog window.
 14:      */
 15:     public AdderDialog1() {
 16:         super("Adding Numbers #1");
 17:         setSize(450, 250);
 18:         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 19:         makeTheBody();
 20:         // FontFixer.resizeFont(this, 24);
 21:     }

 23:     /**
 24:      * This method actually puts the body of the window together.
 25:      */
 26:     private void makeTheBody() {
 27:         // set the layout
 28:         super.setLayout( new GridLayout(5, 2, 10, 5) );

 30:         // add the components
 31:         super.add(new JLabel("Enter two numbers to add together:"));
 32:         super.add(new JLabel(""));   // empty cell!
 33:         super.add(new JLabel("First number"));
 34:         super.add(new JTextField());
 35:         super.add(new JLabel("Second number:"));
 36:         super.add(new JTextField());
 37:         super.add(new JLabel("Result:"));
 38:         super.add(new JTextField());
 39:         super.add(new JButton("Calculate"));
 40:         super.add(new JButton("Done"));
 41:     }

 43:     /**
 44:      * Create and show the window.
 45:      *
 46:      * @param args command line arguments cheerfully ignored!
 47:      */
 48:     public static void main(String[] args) {
 49:         AdderDialog1 ad1 = new AdderDialog1();
 50:         ad1.setVisible(true);

 52:         System.out.println("\n\n"
 53:                 + "This window intentionally left blank\n\n\n:-)\n");
 54:     }
 55: }