Begin this practice during the class. Try to clear out all your questions about graphical user interface (GUI) editing. You may finish it after the class.
The Visual Editor (VE) is an Eclipse plugin that allows the building of AWT/Swing applications with a complete WYSIWYG (what you see is what you get) editor. If you don't have the plugin you can download it from the Eclipse site.
First of all, go to the File menu and choose New ->
Other... -> Java -> Visual Class. This will create a
Java class and open the visual editor. Name it
HelloVisualEditor
and choose the
JFrame
as it's superclass.
Now you can see the Design area, the
components Palette, the
JavaBeans viewer and the
Properties panel. In the
Design area, select the content pane of the frame
you've created and change it's layout property to
null
. Using the Swing
Components, create a label that displays the text "Hello
World!" and a button to kill the application. You can do it using drag
and drop.
To assign the button an event you must add an
ActionListener
to it. Do this by clicking with
the right button of the mouse over the component and selecting
Events -> actionPerformed. Go to the source code
and change the action to
System.exit(0)
.
Set the visible property of the frame to
true
and create a new instance of the
class in the main
method. Save and run the
program.
Present in your report the source code and a screenshot of the application.
Copyright © 1998-2009 Dilvan Moreira