1 / 11

Java - hello world example

Java - hello world example. public class HelloWorld { public static void main (String args[]) { System.out.println("Hello World"); } }. Java -compile and run test. Type in the text of the program and save as a java program. E.g., HelloWorld.java Compile program:

ilyssa
Download Presentation

Java - hello world example

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 --> OutputController --> 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.

More Related