Eclipse

Chapter: Eclipse

The June 2011 release of Eclipse (Indigo) for Java includes WindowBuilder, a toolbox that lets you build GUI Java programs visually. WindowBuilder is also available for earlier versions of Eclipse as a Plug-in. You will know that you have the Indigo version of Eclipse if it starts up and displays this logo:

If your Eclipse starts up with a different logo, I recommend that you reinstall Eclipse for Java (avoid the "EE" Enterprise Edition).

You will be asked to specify a workspace. Choose a reasonable name for a folder in which you are going to keep your Eclipse projects. Perhaps "CSCI1112" would be a good name for your workspace.

Once you have the large Eclipse opening screen, start up the workbench by clicking on its icon:

This will bring up the workbench

Now we'll create a new project by choosing

File > New > Java Project

Name it something like "labs".

Then make a new package

File > New > Package

and name it something like "lab3".

Now let's use a wizard to get us started building a JFrame. From the menu select

File > New > Other > SwingDesigner > JFrame

You can also access the wizards from the drop down wizard menu in the Eclipse toolbar. Note that we have chosen to use the JFrame wizard. It's a fairly simple one to use. You can read the documentation at Google if you are interested in what the other wizards can do for you.

You'll need a name for the JFrame, something like "Ex1". When you let the wizard do its thing, you will end up with something like


Exercise 1

See if you can figure out how to:
  1. run this simple JFrame. Hint: Look for a green arrowhead.
  2. Make the central pane of the Eclipse workbench larger so it fills its frame as shown below
  3. Add one line of code so the JFrame will have "I did it!" in its title bar like this: Hint: check the Java API documentation to see if there is a method in the JFrame class to set a title.




rhyspj@gwu.edu