First In-Class Windows Java Session

Introduction

The first Java in-class session will show you how to do the following:

  1. How to set the Paths .
  2. How to create a simple project
  3. How To Work in the Java Environment

Java Program

Creating a Window Program

Select the Frame from the project list pane
Click on the Design Tab to see your main window.
Select label from the component
Drop it on the main window (see above). Select Label1 from the project tree.
In the object inspector (far right of the design window), change the label name to MyLabel and the text to blank.
Select MenuBar1 in the project tree and with the right button menu start the menu designer.
Select the highlighted location just passed the last menu and select insert from the right-button menu.
Double click on the shaded area and after it turns white enter the menu title. Also name your menu in the Object Inspector at the right.
Click on the first spot below your menu head and enter the text for your first menu selection.
To add a handler for your menu, just select the action performed item from the events tab of the object inspector in your menu item. The click on the text box following this item and press return.
You will find the code for your handler by looking under the MyFrame in the project tree.
You will have the label you placed in the main window display the text "Hello it's me!". You need to find a function that will set the Label text. Look under JLabel in the help. There you will find setText in the method summary. You can also just type "MyLabel." and a list of functions appears. Since you want to set something type set and the set methods will appear.
Finally, use this to set the text that appears on the screen.
void  DrawText_actionPerformed(ActionEvent e) {
     MyLabel.setText("Hello it's me!" );
  }
Select the run button. When you select Draw Text from the Draw menu, your text will appear in the window.