Hands Up

Amit: " My uncle knew just two words of English when he came to Bombay, and he is a millionaire today."

Manav: "How exiting, by the way what were the words?"

Amit: "Hands up!"


Why is it easier to become a clergyman than a physician?

Because it is easier to preach than practice.


A guy gets lost while on vacation and walks into the local pub to ask for the quickest way back to the town. "Are you walking or driving," asks the barman. "Driving," said the man. "Well, that's the quickest I know."


Manish: "Somebody actually complicated me on my driving today."

Harish: "What did he say?"

Manish: "I found a note on my windshield that read 'Parking Fine'."


Sweet sonA man upon his engagement went to his father and said, "I've found a woman just like mother" His father replies, "So what do you want from me, Sympathy?"

Chapter 1 Executable Java Archives

Listing 1.1 MyFrame.java (Complete code)


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

//Class used to show a Frame
public class MyFrame 
	extends JFrame {
		
   //Constructor
   public MyFrame(){
		
	super("MyFrame");
		
	//Construct a new TextArea
	JTextArea ta = new JTextArea(6,16);
		
	//Set the text of this 
	//TextComponent to the specified text
	ta.setText("\n\n Creating Executable files");
			
	//Set the current font
	ta.setFont(new Font("Serif",Font.BOLD+Font.ITALIC,30));
			
	//Set the specified boolean to indicate 
	//whether or not this TextComponent 
	//should be editable
	ta.setEditable(false);
			
	//Get the content pane object.
	getContentPane().add(ta);
			
	//Add the specified window listener 
	//to receive window events from this window
	this.addWindowListener(new WindowHandler());
		
	//Pack the window
	pack();
			
	//Set the window visible
	show();
   }
	//Main method
	 public static void main(String args[]){
		new MyFrame();
	 }
		 
	 //Class used to handle window events
	 private class WindowHandler 
		extends WindowAdapter{
		 			
		public void windowClosing(WindowEvent we){
			System.exit(0);
		}
	  }		
}

The design of the class is very simple. Comments are included in the source code to help you.


Compiling Class File

The next step is to compile the file just created. I am assuming that the file is stored in a directory named "myframe". Compile the source file using the command line:

c:\myframe>javac MyFrame.java


Contents         Top                              Move to the preceding page Move to the next page
© 2001 www.universalteacher.com. All rights reserved