Howdy. Today I work on my desktop:

C:\Users\dgerman\Desktop>dir
 Volume in drive C is OSDisk
 Volume Serial Number is 6014-65BE

 Directory of C:\Users\dgerman\Desktop

07/22/2015  11:39 AM    <DIR>          .
07/22/2015  11:39 AM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  54,795,481,088 bytes free

C:\Users\dgerman\Desktop>

I need to set the path:

C:\Users\dgerman\Desktop>PATH=%PATH%;"C:\Program Files\Java\jdk1.8.0_05\bin"

C:\Users\dgerman\Desktop>

Now I am good. 

C:\Users\dgerman\Desktop>dir
 Volume in drive C is OSDisk
 Volume Serial Number is 6014-65BE

 Directory of C:\Users\dgerman\Desktop

07/22/2015  11:49 AM    <DIR>          .
07/22/2015  11:49 AM    <DIR>          ..
07/22/2015  11:49 AM               300 One.java
               1 File(s)            300 bytes
               2 Dir(s)  54,782,537,728 bytes free

C:\Users\dgerman\Desktop>type One.java
import javax.swing.*;

class One {
  public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setSize(300, 400);
    frame.setTitle("An empty frame");
    // frame.setDefaultCloseOperation(3); // better: JFrame.EXIT_ON_CLOSE
    frame.setVisible(true);
  }
}
C:\Users\dgerman\Desktop>

Let's compile and run this program:


C:\Users\dgerman\Desktop>javac One.java

C:\Users\dgerman\Desktop>dir One*
 Volume in drive C is OSDisk
 Volume Serial Number is 6014-65BE

 Directory of C:\Users\dgerman\Desktop

07/22/2015  11:50 AM               448 One.class
07/22/2015  11:49 AM               300 One.java
               2 File(s)            748 bytes
               0 Dir(s)  54,780,116,992 bytes free

C:\Users\dgerman\Desktop>java One
^C
C:\Users\dgerman\Desktop>

So we need to leave that defaultCloseOperation call in there. 

We are following

http://www.cs.indiana.edu/classes/c212-dgerman/spr2015/lecture21.html

We next look at

import javax.swing.*; 

class Two {
  public static void main(String[] args) {
    JFrame frame = new JFrame(); 

    JButton button = new JButton("Click me!"); 
    JLabel label = new JLabel("Hello, World!"); 
 
    JPanel panel = new JPanel();  
    panel.add(button); 
    panel.add(label); 

    frame.add(panel); 

    frame.setSize(300, 100); 
    frame.setTitle("An empty frame"); 
    frame.setDefaultCloseOperation(3); // better: JFrame.EXIT_ON_CLOSE
    frame.setVisible(true); 
  }
}

Layout manager here was flow layout. 

My next step would be to analyze this:

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

public class Example extends JFrame implements ActionListener 
{  private JLabel nameJLabel, ageJLabel; 
   private JTextField nameJTextField, ageJTextField, totalResultJTextField;
   private JButton calculateJButton;
   public Example() 
   {  Container contentPane = getContentPane(); 
      contentPane.setLayout( null );            
      nameJLabel = new JLabel();             
      nameJLabel.setText( "Please enter your name: " );
      nameJLabel.setBounds( 16, 16, 160, 21 );
      contentPane.add( nameJLabel );
      nameJTextField = new JTextField(); 
      nameJTextField.setBounds( 170, 16, 70, 21 );
      nameJTextField.setHorizontalAlignment( JTextField.RIGHT );
      nameJTextField.setText("Laura"); 
      contentPane.add( nameJTextField );
      ageJLabel = new JLabel(); 
      ageJLabel.setText( "How old are you (in years)?" );
      ageJLabel.setBounds( 16, 48, 164, 21 );
      contentPane.add( ageJLabel );
      ageJTextField = new JTextField(); 
      ageJTextField.setText( "8" );
      ageJTextField.setBounds( 200, 48, 40, 21 );
      ageJTextField.setHorizontalAlignment( JTextField.RIGHT );
      contentPane.add( ageJTextField );
      totalResultJTextField = new JTextField(); 
      totalResultJTextField.setBounds( 244, 16, 186, 21 );
      totalResultJTextField.setHorizontalAlignment( JTextField.RIGHT );
      totalResultJTextField.setEditable( false ); 
      contentPane.add( totalResultJTextField );
      calculateJButton = new JButton(); 
      calculateJButton.setText( "Calculate Total" );
      calculateJButton.setBounds( 304, 48, 126, 24 );
      contentPane.add( calculateJButton ); 
      calculateJButton.addActionListener( this ); 
      setTitle( "Inventory" );
      setSize( 454, 132 );    
      setVisible( true );     
   } 
   public void actionPerformed(ActionEvent e) 
   {  String name = this.nameJTextField.getText(), age = this.ageJTextField.getText(); 
      this.totalResultJTextField.setText( name + " you will be " + (Integer.parseInt(age) + 1) + " next year."); 

   }
   public static void main( String[] args ) 
   {  Example application = new Example();
      application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
   }



At this stage I want to corroborate with the assignment

http://www.cs.indiana.edu/classes/c212-dgerman/spr2015/labTwelve.html

So I read and then I try to run the three .jar files

C:\Users\dgerman\Desktop>dir
 Volume in drive C is OSDisk
 Volume Serial Number is 6014-65BE

 Directory of C:\Users\dgerman\Desktop

07/22/2015  12:07 PM    <DIR>          .
07/22/2015  12:07 PM    <DIR>          ..
07/22/2015  12:01 PM             2,280 Example.class
07/22/2015  12:00 PM             2,326 Example.java
07/22/2015  12:07 PM            10,230 labTwelve.jar
07/22/2015  12:07 PM             2,297 labTwo01.jar
07/22/2015  12:07 PM             3,398 labTwo02.jar
07/22/2015  11:52 AM               501 One.class
07/22/2015  11:52 AM               297 One.java
07/22/2015  11:58 AM               806 Two.class
07/22/2015  11:58 AM               553 Two.java
               9 File(s)         22,688 bytes
               2 Dir(s)  54,735,417,344 bytes free

C:\Users\dgerman\Desktop>

So I downloaded the three .jar files then I run the first two. 

(You run the third one.)

C:\Users\dgerman\Desktop>java -classpath labTwo01.jar Inventory

C:\Users\dgerman\Desktop>java -classpath labTwo02.jar Inventory

C:\Users\dgerman\Desktop>

Now I take attendance, then I run the third one. 

Mark Logan Daniel Jared Nate Qin Trevor Austin James
Brennan Jaquelyn Gabriela Adam Judy Hallie Aleksa Walter 
Nick Yiming Jingzhe Paul Morgan Alex Ong William Jon
Grant M. Alexander Mohan Jack 

java -classpath labTwelve.jar TypingApplication

So now we know what we need to do. 

What do we do? 

Let's keep reading and we look at this:

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

class Four extends JFrame {
  JButton button = new JButton("Click me!"); 
  JLabel label = new JLabel("Hello, World!"); 

  Four(String title, int width, int height) {
    JPanel panel = new JPanel();  
    panel.add(button); 
    panel.add(label); 
    this.add(panel); 

    button.addActionListener( new Listener() ); 

    this.setSize(width, height); 
    this.setTitle(title); 
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    this.setVisible(true); 
  }
  public static void main(String[] args) {
    Four f = new Four("Simple Frame", 300, 100); 
  }
}

class Listener implements ActionListener {
  public void actionPerformed(ActionEvent e) {
    System.out.println("Ouch!"); 
  } 
}

This is how it looks: 

C:\Users\dgerman\Desktop>dir
 Volume in drive C is OSDisk
 Volume Serial Number is 6014-65BE

 Directory of C:\Users\dgerman\Desktop

07/22/2015  12:22 PM    <DIR>          .
07/22/2015  12:22 PM    <DIR>          ..
07/22/2015  12:01 PM             2,280 Example.class
07/22/2015  12:00 PM             2,326 Example.java
07/22/2015  12:22 PM               782 Four.java
07/22/2015  12:07 PM            10,230 labTwelve.jar
07/22/2015  12:07 PM             2,297 labTwo01.jar
07/22/2015  12:07 PM             3,398 labTwo02.jar
07/22/2015  11:52 AM               501 One.class
07/22/2015  11:52 AM               297 One.java
07/22/2015  11:58 AM               806 Two.class
07/22/2015  11:58 AM               553 Two.java
              10 File(s)         23,470 bytes
               2 Dir(s)  54,149,873,664 bytes free

C:\Users\dgerman\Desktop>javac Four.java

C:\Users\dgerman\Desktop>java Four
Ouch!
Ouch!
Ouch!
Ouch!
Ouch!
Ouch!

C:\Users\dgerman\Desktop>

Let's move on. 

So next we look at

http://www.cs.indiana.edu/classes/c212-dgerman/spr2012/classNotes/ch10/Five.javahttp://www.cs.indiana.edu/classes/c212-dgerman/spr2012/classNotes/ch10/Five.java

Finally we looked at the 8+ stages in this document:

http://silo.cs.indiana.edu:8346/04142012/001.html

--