An Introduction to Software Engineering Principals Using Java’s Swing Libraries.

Slides:



Advertisements
Similar presentations
Things to mention public static void main(String [] args) –The starting point for a free-standing Java application (i.e. one not run from the DrJava interactions.
Advertisements

Introduction to JFC Swing Written by Adam Carmi. Agenda About JFC and Swing Pluggable Look and Feel Swing Components Borders Layout Management Events.
Things to mention public static void main(String [] args) imports comments –block comments /* … */ –single-line comments // –javadoc comments and tags.
Unit 091 Introduction to GUI Programming Introduction to User Interfaces Introduction to GUI Programming GUI Design Issues GUI Programming Issues Java.
© L.Lúcio, An example GUI in Java n Two graphic libraries in Java u AWT u Swing n Swing is more recent than AWT: u Built on top of AWT classes;
2D Graphics in Java COMP53 Nov 14, Applets and Applications Java applications are stand-alone programs – start execution with main() – runs in JVM.
Chapter 12Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Announcements/Reminders l Happy Tax Day! l Project 8 due on Thursday.
Unit 101 Java GUI Components and Events  GUI Components and Containers  Adding Components to Containers  GUI Events  GUI Events Classes  Learning.
Writing GUI Applications An introduction with Java.
Object-Oriented Software Engineering Java with added Swing.
Creating a GUI with Swing. Introduction Very useful link: Swing – is a part of JFC (Java Foundation.
Unit 111 Java GUI Components and Events  Learning Outcomes oDistinguish between GUI components and containers. oIdentify and distinguish top-level containers.
Graphical User Interfaces
Chapter 131 Applets and HTML Chapter Reminders Project 8 due Dec 10:30 pm Project 6 regrades due by midnight tonight –Submit all files (including.
Java Review Structure of a graphics program. Computer Graphics and User Interfaces Java is Object-Oriented A program uses objects to model the solution.
Contructing GUI’s in Java Implemented in the Swing API Imported into your programs by: import javax.swing.*; Most Swing programs also need the AWT packages.
GUI Programming in Java Tim McKenna GUI Programming Concepts l conventional programming: sequence of operations is determined by the program.
Java Swing Chris North cs3724: HCI. AWT to Swing AWT: Abstract Windowing Toolkit import java.awt.* Swing: new with Java2 import javax.swing.* Extends.
Java Swing Joon Ho Cho. What is Java Swing? Part of the Java Foundation Classes (JFC) Provides a rich set of GUI components Used to create a Java program.
Lesson 35: Review of the Java GUI. The JFrame, Container and JButton.
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Graphical User Interface (GUI) Design using Swing Course Lecture Slides.
GUI Programming in Java
Introduction to Java GUI Creating Graphical User Interfaces © copyright Bobby Hoggard / material may not be redistributed without permission.
Software Construction Lecture 10 Frameworks
Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial.
Intro to GUIs (Graphical User Interfaces) Section 2.5Intro. to GUIs: a GUI Greeter Section 3.7Graphical/Internet Java: Einstein's Equation.
Lesson 27: Introduction to the Java GUI. // helloworldbutton.java import java.awt.*; import javax.swing.*; class HelloButton{ public static void main.
Applets and Frames CS 21a: Introduction to Computing I First Semester,
MIT AITI 2003 Lecture 17. Swing - Part II. The Java Event Model Up until now, we have focused on GUI's to present information (with one exception) Up.
Java GUI CSCE 190 – Java Instructor: Joel Gompert Mon, July 26, 2004.
GUI programming Graphical user interface-based programming.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
The Drawing program – Java Applets
FEN IntroJava2006 AAU1 GUI: Graphical User Interface AWT/SWING: Components Drag and Drop in NetBeans Events Listeners.
1 Graphical User Interfaces AWT and Swing packages Frames and Panels Components Nested Panels Images Reading for this Lecture: L&L, 3.9 – 3.11.
MSc Workshop - © S. Kamin, U. ReddyLect 3 - GUI -1 Lecture 3 - Graphical User Interfaces r GUI toolkits in Java API r JFrame r GUI components.
1 Java Swing - Lecture 2 Components and Containment Boriana Koleva
Applets and Frames. Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L14: GUI Slide 2 Applets Usually.
Java Applet. Introductions Applet is java program that can be embedded into HTML pages Java applets runs on the java enables web browsers such as mozila.
 GUI – Graphic User Interface  Up to now in the programs we have written all output has been sent to the standard output device i.e.: the DOS console.
Java GUI. Graphical User Interface (GUI) a list a button a text field a label combo box checkbox.
Week 6: Basic GUI Programming Concepts in Java Example: JFrameDemo.java container : a screen window/applet window/panel that groups and arranges components.
CS 4244: Internet Programming User Interface Programming in Java 1.0.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
Ch13 Creating windows and applets. Short overview AWT (Abstract Windowing Toolkit) Early Java development used graphic classesEarly Java development used.
1 GUI programming Graphical user interface-based programming Chapter G1 (pages )
Swing. Introduction to Swing What is Swing? “ Swing is a diverse collection of lightweight components that can be used to build sophisticated user interfaces.”
Review_6 AWT, Swing, ActionListener, and Graphics.
Chapter 131 Applets and HTML Chapter Objectives learn how to write applets learn to write a simple HTML document learn how to embed an applet in.
Outline Creating Objects The String Class The Random and Math Classes Formatting Output Enumerated Types Wrapper Classes Components and Containers Images.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 15 : Swing III King Fahd University of Petroleum & Minerals College of Computer.
Lecture # 6 Graphical User Interface(GUI). Introduction A graphical user interface (GUI) presents a user- friendly mechanism for interacting with an application.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
Swing GUI Components So far, we have written GUI applications which can ‘ draw ’. These applications are simple, yet typical of all Java GUI applications.
Lesson 28: More on the GUI button, frame and actions.
Graphical User Interface (GUI)
Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface.
1 A Quick Java Swing Tutorial. 2 Introduction Swing – A set of GUI classes –Part of the Java's standard library –Much better than the previous library:
CPCS 391 Computer Graphics Lab One. Computer Graphics Using Java What is Computer Graphics: Computer graphics are graphics created using computers and,
Import javax.swing.*; class Check { public static void main(String[] args) { JFrame frame = new JFrame("Check"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//DO_NOTHING_ON_CLOSE.
CREATING A SIMPLE GUI Mr. Crone. First GUI Today we will use Swing to create the following application:
GUI 1: JFC and Swing Basics OOP tirgul No
Using NetBeans IDE for Desktop Development Geertjan Wielenga
A Quick Java Swing Tutorial
Multiple buttons and action calls
A Quick Java Swing Tutorial
Ellen Walker Hiram College
30 Java Applets.
Graphical user interface-based programming
A Quick Java Swing Tutorial
Presentation transcript:

An Introduction to Software Engineering Principals Using Java’s Swing Libraries

How to Approach a Programming Project Divide and Conquer Large problems must be broken into small parts. Then the small parts can be solved one at a time. Top-down design is one divide and conquer technique for developing an algorithm. Top-down design is similar to outlining. An algorithm is a collection of instructions (possibly not from any programming language) that perform some task. divide and conquer plan (design) before implementing program with style The Object of Java, David D. Riley © Addison Wesley pub.

Top Level Algorithm for making a cheese pizza The Object of Java, David D. Riley © Addison Wesley pub. Subtask 1.Using a premixed ball of crust dough, flatten the dough to the desired thickness. 2.Pour two cups of pizza sauce onto the crust 3.Spread the sauce evenly across the crust 4.Set pizza oven to 400 degrees Fahrenheit and cook pizza for 15 minutes.

First Define our objects – –Dough (crust) –Sauce –Cheese –Oven Next look for classes already developed: Java.sun.org (good resource)

Dough _____ > +Dough() > +void flattenToDesiredThickness() +void spreadTopping() +void placeInOven(PizzaOven) +void removeAfter15Minutes()

PizzaOven ________ > +PizzaOven() > +void turnOnAtZeroDegrees() +void turnOff() +void increaseTemp100Degrees()

Sauce _____ > +Sauce() > +void pourInto(MeasuringCup)

Cheese ______ > +void Cheese() > +void pourInto(MeasuringCup)

MeasuringCup ____________ > +MeasuringCup() > +void pourOnto(Dough)

Second Level Algorithm Use of parameters stems from the need to involve multiple objects in a single method. Exp: act of pouring pizza sauce -> measuring cup involves 1. The sauce 2. The cup. This permits one object to be passed to a method performed upon the second object. Another Exp: crust.placeInOven( oven );

Now refine each of the subtasks: –1 Using a premixed ball of crust dough, flatten the dough to the desired thickness. crust = new Dough( ); crust.flattenToDesiredThickness( ); –2 Pour two cups of pizza sauce onto the crust sauceCup = new MeasuringCup( ); mySauce = new Sauce( ); mySauce.pourInto( sauceCup ); sauceCup.pourOnto( crust ); mySauce.pourInto( sauceCup ); sauceCup.pourOnto( crust );

3.Spread the sauce evenly across the crust. crust.spreadTopping( ); 4.Spread three cups of mozz cheese on top cheeseCup = new MeasuringCup( ); //4.2Use cheeseCup to spread 3 cups on the pizza 5.Set pizza oven to 400 degrees and cook 15 min. oven = new PizzaOven(); oven.turnOnAtZeroDegrees( ); //5.3 set the temp to 400 degrees crust.placeInOven( oven ); crust.removeAfter15minutes( ); oven.turnOff( );

Second level names new objects: –crust –sauceCup –mySauce –cheeseCup –oven Next level is needed to add steps 4.2 and 5.3 one more refinement step finishes your project. Final code on page 60 Fig 3.9 of your book

Swing import java.swing.*; Use code warrior Sometimes will import java.awt.*; And java.awt.event.*; Swing components use the awt infrastructure. Event model governs how a component reacts to events, such as button clicks etc..

Every program must contain at least one top-level Swing container. JFrame, JDialog, and for applets JApplets JFrame – implements a single main window JDialog – implements a second window JApplet – implements an applet’s display area in a browser window

import javax.swing.*; public class HelloWorldSwing { public static void main(String[] args) { JFrame frame = new JFrame("HelloWorldSwing"); final JLabel label = new JLabel("Hello World"); frame.getContentPane().add(label); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E); frame.pack(); frame.setVisible(true); }

Now – take a look at ndex.html Read this tutorial and answer questions at the end – hand in a text file to the G drive. Due date: End of Class – Monday 3/3/2003