-
13
pages
-
English
-
Documents
Description
Java AWT Tutorial2 Parts•Creating the graphical interface•Defining the behaviorUsed this site http://brandt.kurowski.net/teaching/java/tutorial.htmlthAs well as Deitel & Deitel Small Java How To Program 6 edition AWT - Building a graphical interface•2 w a y s– Write the code yourself– Use a graphical interface builderWe will write the code ourselves, you should know what kind of code the automatic tools build for youAWT - Building a graphical interface• Terminology– AWT – Abstract Windows Toolkit– GUI – Graphical User InterfaceAWT - Building a graphical interface• Creating the window– The first thing you need is the window your GUI application will be in– In Java AWT – top level windows are represented by the Frame classAWT - Building a graphical interface• The Frame class– Most common way is to use the single argument constructor– The argument is a String that becomes the window’s title– The window is initially invisible, you must call the Frame’s show() method which it inherits from the window classÆAWT - Building a graphical interface• Adding a Frame and using the show() methodpackage com.cosc210.awt;import java.awt.*;public class MyApp1 {public static void main (String arg[]){Frame myFrame = new Frame("example Frame for cosc210");myFrame.show(); // necessary for the frame to be visible}}Used the mouse to drag the Window to a larger size AWT - Building a graphical interface• Adding a Frame and using the show() ...
-
Publié par
-
Langue
English