Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java - hello world example public class HelloWorld { public static void main (String args[]) { System.out.println("Hello World"); }

Similar presentations


Presentation on theme: "Java - hello world example public class HelloWorld { public static void main (String args[]) { System.out.println("Hello World"); }"— Presentation transcript:

1 Java - hello world example public class HelloWorld { public static void main (String args[]) { System.out.println("Hello World"); }

2 Java -compile and run test Type in the text of the program and save as a java program. E.g., HelloWorld.java Compile program: –javac HelloWorld.java Run the program: –java HelloWorld compile and run ButtonTest.java –http://my.fit.edu/~ghrezo/ButtonTest.java

3 The Model-View-Controller (MVC) is a commonly used and powerful architecture for GUIs The MVC paradigm is a way of breaking an application into input, processing and output. Input --> Processing --> Output Controller --> Model --> View

4 In the case of word processors, the Controller collects keystrokes from the keyboard and delivers them to the Model which notifies the View that the data has changed so that the updated data can be displayed.

5 Model View Controller Model- the data View - the GUI (output) Controller - user input (mouse click)

6 MVC  Model : The core of the application. This maintains the state and data that the application represents. When significant changes occur in the model, it updates all of its views  Controller : The user interface presented to the user to manipulate the application.  View : The user interface which displays information about the model to the user. Any object that needs information about the model needs to be a registered view with the model.

7 AWT/Swing basics Graphical objects (Component objects) are contained in Container objects. Container (also a component) objects, may be nested. You can construct a GUI with these steps: –Create a GUI component: JButton okButton = new JButton(“OK”); –Add the component to a container: add(okButton);

8 Event Handling Respond to events generated by the component: –you must attach an event listener to the component: okButton.addActionListener(this); –An event listener is an instance of a class that implements the event listener for the appropriate event type. (other types: window event)

9 The listener: public void actionPerformed(ActionEvent event) { if (event.getSource() == okButton) okButton.getToolkit().beep; }

10 homework Write a Java GUI program 1) that accepts input into a text area 2) contains a button labeled “Read Text” 3) outputs the typed text when the button is pressed.

11 Project 1 dates Sept. 16 (break into groups) –Pick an User Interface to design –Begin designing interface on paper Sept. 25 (next Wednesday) –Present design to class –Collect usability attributes. (I’ll pass out a question and answer sheet.) –The group will then re-design the interface based on what the question and answer sheets indicates. Oct. 2 (the following Wednesday) –Present your findings based the collected data from the question and answer sheets –Re-present the new enhanced design.


Download ppt "Java - hello world example public class HelloWorld { public static void main (String args[]) { System.out.println("Hello World"); }"

Similar presentations


Ads by Google