Swing Rocks - A Tribute to Filthy Rich Clients

Size: px
Start display at page:

Download "Swing Rocks - A Tribute to Filthy Rich Clients"

Transcription

1 Swing Rocks - A Tribute to Filthy Rich Clients Pär Sikö, Martin Gunnarsson Epsilon Information Technology

2 One way that Pollak has found to speed up JavaTM programs is to rewrite their user interfaces in Microsoft's Visual Basic. 2

3 Sure it looks like shit, but at least it does so consistently on all operating systems. 3

4 and that's why Java on the desktop is as dead as an Egyptian mummy.

5 How bad can it possibly be? 5

6

7

8

9 What s the problem? 9

10 10

11 11

12 The Swing Rocks Formula Subtle effects Smooth animations Custom components Good performance 12

13 Demo: Feedjii 13

14 Under the hood 14

15 15

16 16

17 17

18 paint(graphics g) paintcomponent(graphics g) paintborder(graphics g) paintchildren(graphics g) 18

19 19

20 Feed component 20

21 public class FeedComponent extends JComponent { private String headline, text; public FeedComponent(String title, String text) { this.headline = title; this.text = text; protected void paintcomponent(graphics g) { // Paint code goes here } } 21

22 Graphics2D g2 = (Graphics2D) g; // Enable antialiasing g2.setrenderinghint(renderinghints.key_antialiasing, RenderingHints.VALUE_ANTIALIAS_ON); 22

23 // Create gradient paint Point top = new Point(0, 0); Point bottom = new Point(0, getheight()); Color topcolor = new Color(192, 192, 192); Color bottomcolor = new Color(95, 95, 95); Paint paint = new GradientPaint(top, topcolor, bottom, bottomcolor); // Set paint g2.setpaint(paint); 23

24 // Draw background int radius = 10; g2.fillroundrect(0, 0, getwidth(), getheight(), radius, radius); 24

25 // Draw headline g2.setpaint(color.black); g2.drawstring(this.headline, 15, 15); // Draw body g2.drawstring(this.text, 15, 40); JavaOne The conference where all the cool people hang out 25

26 What about animations? 26

27 Timing Framework public class AnimationExample implements TimingTarget { public void createanimation() { Animator animator = new Animator(2000, this); animator.setresolution(10); animator.setacceleration(0.3f); animator.setdeceleration(0.3f); animator.start(); public void timingevent(float progress) { // Update and redraw } } 27

28 Step 4: Timing event (Called multiple times) Move the list Step 3: Mouse button released Calculate total distance to scroll Step 2: Mouse dragged (Called multiple times) Update component position Step 1: Mouse button pressed Save start time Save vertical position 28

29 Kinetic Scrolling public class KineticScrolling extends JComponent implements MouseListener, MouseMotionListener, TimingTarget { private private private private private private private JComponent componenttoscroll; Animator animator; long starttime; int startposition; int distancetoscroll; MouseEvent previousmouseevent; final int animationduration = 1300; 29

30 Kinetic Scrolling public KineticScrolling(JComponent component) { setlayout(null); addmouselistener(this); addmousemotionlistener(this); componenttoscroll = component; add(componenttoscroll); } 30

31 Kinetic public void mousepressed(mouseevent e) { starttime = System.currentTimeMillis(); startposition = componenttoscroll.gety(); previousmouseevent = e; } 31

32 Kinetic public void mousedragged(mouseevent e) { int diff = e.getyonscreen() previousmouseevent.getyonscreen(); int newyposition = componenttoscroll.gety() + diff; componenttoscroll.setlocation(0, newyposition); previousmouseevent = e; repaint(); } 32

33 Kinetic public void mousereleased(mouseevent e) { int ydiff = componenttoscroll.gety() - startposition; double elapsedtime = System.currentTimeMillis() starttime; double speed = ydiff / elapsedtime; distancetoscroll = (int) (speed * animationduration); startposition = componenttoscroll.gety(); animator = new Animator(animationDuration, this); animator.setresolution(0); animator.setdeceleration(1); animator.start(); } 33

34 Kinetic public void timingevent(float progress) { int newy = (int)(startposition + distancetoscroll * progress); componenttoscroll.setlocation(0, newy); repaint(); } 34

35 Demo: Kinetic scrolling 35

36 Performance: Five steps to success 36

37 1. Hardware Acceleration Flags > > -Dsun.java2d.opengl=true -Dsun.java2d.d3d=true java -Dsun.java2d.opengl=true Feedjii 37

38 2. Timing issues public class CustomTimer extends TimingSource { private long resolution; private boolean stop = false; public void start() {... } public void stop() { stop = true; } public void setresolution(int resolution) { this.resolution = resolution; } } 38

39 2. Timing issues continued public void start() { new Thread() { public void run() { while (!stop) { try { sleep(resolution); } catch (Exception e) { } timingevent(); } } }.start(); } 39

40 3. Cache is king protected void paintcomponent(graphics g) { if(cachedimage == null) { cachedimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = (Graphics2D) cachedimage.getgraphics(); // Paint your component on the cachedimage graphics.drawline(10, 10, 100, 100); } g.drawimage(cachedimage, 0, 0, null); } 40

41 4. Compatible Images // Regular buffered image cachedimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); // Compatible image GraphicsConfiguration conf = getgraphicsconfiguration(); cachedimage = conf.createcompatibleimage(width, height); 41

42 5. Avoid unnecessary transparency cachedimage = conf.createcompatibleimage(width, height, Transparency.TRANSLUCENT); cachedimage = conf.createcompatibleimage(width, height, Transparency.OPAQUE); 42

43 Performance summary S tandard D 3D OpenG L C ache C ached compatible 43

44 Summary 44

45 What s next? 45

46 Books 46

47 Questions 47

48 Pär Sikö, Martin Gunnarsson 48

Computer Science 210: Data Structures. Intro to Java Graphics

Computer Science 210: Data Structures. Intro to Java Graphics Computer Science 210: Data Structures Intro to Java Graphics Summary Today GUIs in Java using Swing in-class: a Scribbler program READING: browse Java online Docs, Swing tutorials GUIs in Java Java comes

More information

Filthy Rich Clients: Filthier. Richer. Clientier. Romain Guy, Google Chet Haase, Adobe Systems

Filthy Rich Clients: Filthier. Richer. Clientier. Romain Guy, Google Chet Haase, Adobe Systems Filthy Rich Clients: Filthier Richer Clientier Romain Guy, Google Chet Haase, Adobe Systems Learn techniques for making cooler, better, and just darned funner applications. Get filthy. 2008 JavaOne SM

More information

Swing and you are winning

Swing and you are winning Swing and you are winning Pimp your user interface with the power of the swing framework. Tuning a standard user interface with gradients, custom components and validating text fields using the JGlassPane.

More information

PESIT Bangalore South Campus

PESIT Bangalore South Campus INTERNAL ASSESSMENT TEST II Date : 20-09-2016 Max Marks: 50 Subject & Code: JAVA & J2EE (10IS752) Section : A & B Name of faculty: Sreenath M V Time : 8.30-10.00 AM Note: Answer all five questions 1) a)

More information

GUI DYNAMICS Lecture July 26 CS2110 Summer 2011

GUI DYNAMICS Lecture July 26 CS2110 Summer 2011 GUI DYNAMICS Lecture July 26 CS2110 Summer 2011 GUI Statics and GUI Dynamics 2 Statics: what s drawn on the screen Components buttons, labels, lists, sliders, menus,... Containers: components that contain

More information

Bringing Life to Swing Desktop Applications

Bringing Life to Swing Desktop Applications Bringing Life to Swing Desktop Applications Alexander Potochkin Sun Microsystems Kirill Grouchnikov Amdocs Inc. TS-3414 2007 JavaOne SM Conference Session TS-3414 Presentation Goal Learn advanced painting

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 35 April 15, 2013 Swing III: OO Design, Mouse InteracGon Announcements HW10: Game Project is out, due Tuesday, April 23 rd at midnight If you want

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 35 April 21, 2014 Swing III: Paint demo, Mouse InteracFon HW 10 has a HARD deadline Announcements You must submit by midnight, April 30 th Demo your

More information

An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a

An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a CBOP3203 An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a page. When you use a Java technology-enabled

More information

Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms.

Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms. Java GUI Windows Events Drawing 1 Java GUI Toolkits Toolkit AWT Description Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms.

More information

G51PRG: Introduction to Programming Second semester Applets and graphics

G51PRG: Introduction to Programming Second semester Applets and graphics G51PRG: Introduction to Programming Second semester Applets and graphics Natasha Alechina School of Computer Science & IT nza@cs.nott.ac.uk Previous two lectures AWT and Swing Creating components and putting

More information

Week 4 Part 2. Introduction to 2D Graphics & Java 2D

Week 4 Part 2. Introduction to 2D Graphics & Java 2D Week 4 Part 2 Introduction to 2D Graphics & Java 2D 2D graphics Vector graphics! Use of geometric primitives: points, lines, curves, etc.! Primitives are created by using mathematical equations! Can be

More information

Java Mouse Actions. C&G criteria: 5.2.1, 5.4.1, 5.4.2,

Java Mouse Actions. C&G criteria: 5.2.1, 5.4.1, 5.4.2, Java Mouse Actions C&G criteria: 5.2.1, 5.4.1, 5.4.2, 5.6.2. The events so far have depended on creating Objects and detecting when they receive the event. The position of the mouse on the screen can also

More information

Object Orientated Programming in Java. Benjamin Kenwright

Object Orientated Programming in Java. Benjamin Kenwright Graphics Object Orientated Programming in Java Benjamin Kenwright Outline Essential Graphical Principals JFrame Window (Popup Windows) Extending JFrame Drawing from paintcomponent Drawing images/text/graphics

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 35 November 30 th 2015 Design PaBerns Model / View / Controller Chapter 31 Game project grading Game Design Proposal Milestone Due: (12 points) Tuesday

More information

Applet which displays a simulated trackball in the upper half of its window.

Applet which displays a simulated trackball in the upper half of its window. Example: Applet which displays a simulated trackball in the upper half of its window. By dragging the trackball using the mouse, you change its state, given by its x-y position relative to the window boundaries,

More information

Windows and Events. created originally by Brian Bailey

Windows and Events. created originally by Brian Bailey Windows and Events created originally by Brian Bailey Announcements Review next time Midterm next Friday UI Architecture Applications UI Builders and Runtimes Frameworks Toolkits Windowing System Operating

More information

UI Software Organization

UI Software Organization UI Software Organization The user interface From previous class: Generally want to think of the UI as only one component of the system Deals with the user Separate from the functional core (AKA, the app

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 36 November 30, 2018 Mushroom of Doom Model / View / Controller Chapter 31 Announcements Game Project Complete Code Due: Monday, December 10th NO LATE

More information

Assignment 2. Application Development

Assignment 2. Application Development Application Development Assignment 2 Content Application Development Day 2 Lecture The lecture covers the key language elements of the Java programming language. You are introduced to numerical data and

More information

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics Topic 9: Swing Outline Swing = Java's GUI library Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 7: Expand moving shapes from Assignment 4 into game. "Programming

More information

Lecture 3: Java Graphics & Events

Lecture 3: Java Graphics & Events Lecture 3: Java Graphics & Events CS 62 Fall 2017 Kim Bruce & Alexandra Papoutsaki Text Input Scanner class Constructor: myscanner = new Scanner(System.in); can use file instead of System.in new Scanner(new

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 34 April 13, 2017 Model / View / Controller Chapter 31 How is the Game Project going so far? 1. not started 2. got an idea 3. submitted design proposal

More information

CSCI 053. Week 5 Java is like Alice not based on Joel Adams you may want to take notes. Rhys Price Jones. Introduction to Software Development

CSCI 053. Week 5 Java is like Alice not based on Joel Adams you may want to take notes. Rhys Price Jones. Introduction to Software Development CSCI 053 Introduction to Software Development Rhys Price Jones Week 5 Java is like Alice not based on Joel Adams you may want to take notes Objectives Learn to use the Eclipse IDE Integrated Development

More information

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction CSC 160 LAB 8-1 DIGITAL PICTURE FRAME PROFESSOR GODFREY MUGANDA DEPARTMENT OF COMPUTER SCIENCE 1. Introduction Download and unzip the images folder from the course website. The folder contains 28 images

More information

HW#1: Pencil Me In Status!? How was Homework #1? Reminder: Handouts. Homework #2: Java Draw Demo. 3 Handout for today! Lecture-Homework mapping.

HW#1: Pencil Me In Status!? How was Homework #1? Reminder: Handouts. Homework #2: Java Draw Demo. 3 Handout for today! Lecture-Homework mapping. HW#1: Pencil Me In Status!? CS193J: Programming in Java Summer Quarter 2003 Lecture 6 Inner Classes, Listeners, Repaint Manu Kumar sneaker@stanford.edu How was Homework #1? Comments please? SITN students

More information

Graphical User Interfaces 2

Graphical User Interfaces 2 Graphical User Interfaces 2 CSCI 136: Fundamentals CSCI 136: Fundamentals of Computer of Science Computer II Science Keith II Vertanen Keith Vertanen Copyright 2011 Extending JFrame Dialog boxes Overview

More information

UCLA PIC 20A Java Programming

UCLA PIC 20A Java Programming UCLA PIC 20A Java Programming Instructor: Ivo Dinov, Asst. Prof. In Statistics, Neurology and Program in Computing Teaching Assistant: Yon Seo Kim, PIC University of California, Los Angeles, Summer 2002

More information

class BankFilter implements Filter { public boolean accept(object x) { BankAccount ba = (BankAccount) x; return ba.getbalance() > 1000; } }

class BankFilter implements Filter { public boolean accept(object x) { BankAccount ba = (BankAccount) x; return ba.getbalance() > 1000; } } 9.12) public interface Filter boolean accept(object x); Describes any class whose objects can measure other objects. public interface Measurer double measure(object anobject); This program tests the use

More information

Unit 7: Event driven programming

Unit 7: Event driven programming Faculty of Computer Science Programming Language 2 Object oriented design using JAVA Dr. Ayman Ezzat Email: ayman@fcih.net Web: www.fcih.net/ayman Unit 7: Event driven programming 1 1. Introduction 2.

More information

Lecture 5: Java Graphics

Lecture 5: Java Graphics Lecture 5: Java Graphics CS 62 Spring 2019 William Devanny & Alexandra Papoutsaki 1 New Unit Overview Graphical User Interfaces (GUI) Components, e.g., JButton, JTextField, JSlider, JChooser, Containers,

More information

OOP Assignment V. For example, the scrolling text (moving banner) problem without a thread looks like:

OOP Assignment V. For example, the scrolling text (moving banner) problem without a thread looks like: OOP Assignment V If we don t use multithreading, or a timer, and update the contents of the applet continuously by calling the repaint() method, the processor has to update frames at a blinding rate. Too

More information

Programmierpraktikum

Programmierpraktikum Programmierpraktikum Claudius Gros, SS2012 Institut für theoretische Physik Goethe-University Frankfurt a.m. 1 of 18 17/01/13 11:46 Java Applets 2 of 18 17/01/13 11:46 Java applets embedding Java applications

More information

Java 2D Graphics. Drawing Primitives, Affine Transformations, Scene Graphs, Hit Tests. Drawing Primitives 2/9/2014. Using it is simple.

Java 2D Graphics. Drawing Primitives, Affine Transformations, Scene Graphs, Hit Tests. Drawing Primitives 2/9/2014. Using it is simple. Java 2D Graphics Drawing Primitives, Affine Transformations, Scene Graphs, Hit Tests Drawing Primitives Graphics - Abstract Base Class that supports basic drawing and rendering - Conceptually sim. to WatGUI

More information

CSIS 10A Practice Final Exam Solutions

CSIS 10A Practice Final Exam Solutions CSIS 10A Practice Final Exam Solutions 1) (5 points) What would be the output when the following code block executes? int a=3, b=8, c=2; if (a < b && b < c) b = b + 2; if ( b > 5 a < 3) a = a 1; if ( c!=

More information

Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how to paint graphics on GUI components

Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how to paint graphics on GUI components CS112-Section2 Hakan Guldas Burcin Ozcan Meltem Kaya Muge Celiktas Notes of 6-8 May Graphics Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how

More information

Java Coordinate System

Java Coordinate System Java Graphics Drawing shapes in Java such as lines, rectangles, 3-D rectangles, a bar chart, or a clock utilize the Graphics class Drawing Strings Drawing Lines Drawing Rectangles Drawing Ovals Drawing

More information

User interfaces and Swing

User interfaces and Swing User interfaces and Swing Overview, applets, drawing, action listening, layout managers. APIs: java.awt.*, javax.swing.*, classes names start with a J. Java Lectures 1 2 Applets public class Simple extends

More information

Clipboard and Drag-and-Drop

Clipboard and Drag-and-Drop 1 Data Transfer Methods to enable user-interface level data transfer within an application and between applications - clipboard (copy, cut, paste) - drag-and-drop (drag data from one view/application to

More information

Agenda. Programming Seminar. By: dr. Amal Khalifa. Coordinate systems Colors Fonts Drawing shapes Graphics2D API

Agenda. Programming Seminar. By: dr. Amal Khalifa. Coordinate systems Colors Fonts Drawing shapes Graphics2D API Agenda Coordinate systems Colors Fonts Drawing shapes Graphics2D API By: dr. Amal Khalifa 1 Programming Seminar @12:30 13:30 pm on Wednesday 9/4/2014 Location : 2.505.01 Painting components 2 Every component

More information

IT101. Graphical User Interface

IT101. Graphical User Interface IT101 Graphical User Interface Foundation Swing is a platform-independent set of Java classes used for user Graphical User Interface (GUI) programming. Abstract Window Toolkit (AWT) is an older Java GUI

More information

Graphic User Interfaces. - GUI concepts - Swing - AWT

Graphic User Interfaces. - GUI concepts - Swing - AWT Graphic User Interfaces - GUI concepts - Swing - AWT 1 What is GUI Graphic User Interfaces are used in programs to communicate more efficiently with computer users MacOS MS Windows X Windows etc 2 Considerations

More information

Rendering with Java. Jim Graham Staff Engineer JavaSoft

Rendering with Java. Jim Graham Staff Engineer JavaSoft Rendering with Java Jim Graham Staff Engineer JavaSoft Overview AWT paint/update callback model Graphics rendering Image rendering and manipulation Basic image fetching and drawing Off-screen images for

More information

Outline. More on the Swing API Graphics: double buffering and timers Model - View - Controller paradigm Applets

Outline. More on the Swing API Graphics: double buffering and timers Model - View - Controller paradigm Applets Advanced Swing Outline More on the Swing API Graphics: double buffering and timers Model - View - Controller paradigm Applets Using menus Frame menus add a menu bar to the frame (JMenuBar) add menus to

More information

public void mouseexited (MouseEvent e) setminute(getminute()+increment); 11.2 public void mouseclicked (MouseEvent e) int x = e.getx(), y = e.gety();

public void mouseexited (MouseEvent e) setminute(getminute()+increment); 11.2 public void mouseclicked (MouseEvent e) int x = e.getx(), y = e.gety(); 11 The Jav aawt Part I: Mouse Events 11.1 public void mouseentered (MouseEvent e) setminute(getminute()+increment); 53 public void mouseexited (MouseEvent e) setminute(getminute()+increment); 11.2 public

More information

Question 1. Show the steps that are involved in sorting the string SORTME using the quicksort algorithm given below.

Question 1. Show the steps that are involved in sorting the string SORTME using the quicksort algorithm given below. Name: 1.124 Quiz 2 Thursday November 9, 2000 Time: 1 hour 20 minutes Answer all questions. All questions carry equal marks. Question 1. Show the steps that are involved in sorting the string SORTME using

More information

1.00/1.001 Introduction to Computers and Engineering Problem Solving Spring Quiz 2

1.00/1.001 Introduction to Computers and Engineering Problem Solving Spring Quiz 2 1.00/1.001 Introduction to Computers and Engineering Problem Solving Spring 2010 - Quiz 2 Name: MIT Email: TA: Section: You have 80 minutes to complete this exam. For coding questions, you do not need

More information

Graphic Interface Programming II Events and Threads. Uppsala universitet

Graphic Interface Programming II Events and Threads. Uppsala universitet Graphic Interface Programming II Events and Threads IT Uppsala universitet Animation Animation adds to user experience Done right, it enhances the User Interface Done wrong, it distracts and irritates

More information

Virtualians.ning.pk. 2 - Java program code is compiled into form called 1. Machine code 2. native Code 3. Byte Code (From Lectuer # 2) 4.

Virtualians.ning.pk. 2 - Java program code is compiled into form called 1. Machine code 2. native Code 3. Byte Code (From Lectuer # 2) 4. 1 - What if the main method is declared as private? 1. The program does not compile 2. The program compiles but does not run 3. The program compiles and runs properly ( From Lectuer # 2) 4. The program

More information

Object Design with GoF Patterns, continued. Curt Clifton Rose-Hulman Institute of Technology

Object Design with GoF Patterns, continued. Curt Clifton Rose-Hulman Institute of Technology Object Design with GoF Patterns, continued Curt Clifton Rose-Hulman Institute of Technology Applying Patterns to NextGen POS Iteration 3 Local caching Used Adapter and Factory Failover to local services

More information

Advanced Effects in Java Desktop Applications

Advanced Effects in Java Desktop Applications Advanced Effects in Java Desktop Applications Kirill Grouchnikov, Senior Software Engineer, Amdocs kirillcool@yahoo.com http://www.pushing-pixels.org OSCON 2007 Agenda Swing pipeline Hooking into the pipeline

More information

CS/120 Final Exam. Name

CS/120 Final Exam. Name CS/120 Final Exam Name 16 pts 1. Trace the following segment of code and to the left of each System.out.println instruction show the precise output that results when this code segment executes. java.awt.container

More information

6.092 Introduction to Software Engineering in Java January (IAP) 2009

6.092 Introduction to Software Engineering in Java January (IAP) 2009 MIT OpenCourseWare http://ocw.mit.edu 6.092 Introduction to Software Engineering in Java January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.

More information

Graphics and Painting

Graphics and Painting Graphics and Painting Lecture 17 CGS 3416 Fall 2015 November 30, 2015 paint() methods Lightweight Swing components that extend class JComponent have a method called paintcomponent, with this prototype:

More information

Inheritance. One class inherits from another if it describes a specialized subset of objects Terminology:

Inheritance. One class inherits from another if it describes a specialized subset of objects Terminology: Inheritance 1 Inheritance One class inherits from another if it describes a specialized subset of objects Terminology: the class that inherits is called a child class or subclass the class that is inherited

More information

J.73 J.74 THE I/O PACKAGE. Java I/O is defined in terms of streams. Streams are ordered sequences of data that have a source and a destination.

J.73 J.74 THE I/O PACKAGE. Java I/O is defined in terms of streams. Streams are ordered sequences of data that have a source and a destination. THE I/O PACKAGE Java I/O is defined in terms of streams. J.73 import java.io.*; class Translate { public static void main(string[] args) { InputStream in = System.in; OutputStream out = System.out; J.74

More information

NITI NITI I PRIORITET

NITI NITI I PRIORITET NITI public class ThreadsTest { public static void main(string args[]) { BytePrinter bp1 = new BytePrinter(); BytePrinter bp2 = new BytePrinter(); BytePrinter bp3 = new BytePrinter(); bp1.start(); bp2.start();

More information

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

Graphics. Lecture 18 COP 3252 Summer June 6, 2017 Graphics Lecture 18 COP 3252 Summer 2017 June 6, 2017 Graphics classes In the original version of Java, graphics components were in the AWT library (Abstract Windows Toolkit) Was okay for developing simple

More information

Graphics in Swing. Engineering 5895 Faculty of Engineering & Applied Science Memorial University of Newfoundland

Graphics in Swing. Engineering 5895 Faculty of Engineering & Applied Science Memorial University of Newfoundland Graphics in Swing Engineering 5895 Faculty of Engineering & Applied Science Memorial University of Newfoundland 1 paintcomponent and repaint Each Swing component has the following paint methods: void paintcomponent(

More information

FirstSwingFrame.java Page 1 of 1

FirstSwingFrame.java Page 1 of 1 FirstSwingFrame.java Page 1 of 1 2: * A first example of using Swing. A JFrame is created with 3: * a label and buttons (which don t yet respond to events). 4: * 5: * @author Andrew Vardy 6: */ 7: import

More information

2. (10 pts) Which of the following classes implements the Shape interface? Circle all that apply. a) Ellipse2D b) Area c) Stroke d) AffineTransform e)

2. (10 pts) Which of the following classes implements the Shape interface? Circle all that apply. a) Ellipse2D b) Area c) Stroke d) AffineTransform e) CS 324E Elements of Computer Graphics Fall 2002 Midterm NAME: Please write your answers on THESE SHEETS. If you must turn in extra sheets, put your name on each one of them. You should not need substantial

More information

Advanced Java Programming

Advanced Java Programming Advanced Java Programming Shmulik London Lecture #5 GUI Programming Part I AWT & Basics Advanced Java Programming / Shmulik London 2006 Interdisciplinary Center Herzeliza Israel 1 Agenda AWT & Swing AWT

More information

G51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread

G51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread G51PGP Programming Paradigms Lecture 008 Inner classes, anonymous classes, Swing worker thread 1 Reminder subtype polymorphism public class TestAnimals public static void main(string[] args) Animal[] animals

More information

Java for Interfaces and Networks (DT3010, HT10)

Java for Interfaces and Networks (DT3010, HT10) Java for Interfaces and Networks (DT3010, HT10) Mouse Events, Timers, Serialization Federico Pecora School of Science and Technology Örebro University federico.pecora@oru.se Federico Pecora Java for Interfaces

More information

Lab & Assignment 1. Lecture 3: ArrayList & Standard Java Graphics. Random Number Generator. Read Lab & Assignment Before Lab Wednesday!

Lab & Assignment 1. Lecture 3: ArrayList & Standard Java Graphics. Random Number Generator. Read Lab & Assignment Before Lab Wednesday! Lab & Assignment 1 Lecture 3: ArrayList & Standard Java Graphics CS 62 Fall 2015 Kim Bruce & Michael Bannister Strip with 12 squares & 5 silver dollars placed randomly on the board. Move silver dollars

More information

GUI in Java TalentHome Solutions

GUI in Java TalentHome Solutions GUI in Java TalentHome Solutions AWT Stands for Abstract Window Toolkit API to develop GUI in java Has some predefined components Platform Dependent Heavy weight To use AWT, import java.awt.* Calculator

More information

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. CSIS 10A PRACTICE FINAL EXAM SOLUTIONS Closed Book Closed Computer 3 Sheets of Notes Allowed MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) What

More information

Avoid Common Pitfalls when Programming 2D Graphics in Java: Lessons Learnt from Implementing the Minueto Toolkit

Avoid Common Pitfalls when Programming 2D Graphics in Java: Lessons Learnt from Implementing the Minueto Toolkit Avoid Common Pitfalls when Programming 2D Graphics in Java: Lessons Learnt from Implementing the Minueto Toolkit Minueto is a platform independent game development framework written in Java, specifically

More information

(C) 2010 Pearson Education, Inc. All rights reserved. Omer Boyaci

(C) 2010 Pearson Education, Inc. All rights reserved. Omer Boyaci Omer Boyaci A sprite must monitor the game environment, for example, reacting to collisions with different sprites or stopping when it encounters an obstacle. Collision processing can be split into two

More information

CS61B Lecture #36. DSIJ, Chapter 10, HFJ, pp Today: A Brief Side Trip: Enumeration types.

CS61B Lecture #36. DSIJ, Chapter 10, HFJ, pp Today: A Brief Side Trip: Enumeration types. CS61B Lecture #36 Today: A Brief Side Trip: Enumeration types. DSIJ, Chapter 10, HFJ, pp. 489 516. Threads Communication between threads Synchronization Mailboxes Last modified: Fri Nov 17 01:28:46 2017

More information

Software Construction

Software Construction Lecture 11: Command Design Pattern Software Construction in Java for HSE Moscow Tom Verhoeff Eindhoven University of Technology Department of Mathematics & Computer Science Software Engineering & Technology

More information

ISO-2022-JP (JIS ) 1 2. (Windows95/98 MacOS ) Java UNICODE UNICODE. Java. .java.java.txt native2ascii. .java

ISO-2022-JP (JIS ) 1 2. (Windows95/98 MacOS ) Java UNICODE UNICODE. Java. .java.java.txt native2ascii. .java 2000 8 2000.1.24-27 0 4 1 ( (1 8 ) ASCII 1 8 1 1 8 2 ISO-2022-JP (JIS ) 1 2 EUC ( EUC) 8 Unix SJIS (MS ) EUC 8 ( (Windows95/98 MacOS Java UNICODE UNICODE ( Java.java.java.txt native2ascii.java native2ascii

More information

Interactors. Brahm Capoor.

Interactors. Brahm Capoor. Interactors Brahm Capoor brahm@stanfordedu Learning goals for today To learn how to use interactors in our programs Learning goals for today To learn how to use interactors in our programs To go under

More information

Come & Join Us at VUSTUDENTS.net

Come & Join Us at VUSTUDENTS.net Come & Join Us at VUSTUDENTS.net For Assignment Solution, GDB, Online Quizzes, Helping Study material, Past Solved Papers, Solved MCQs, Current Papers, E-Books & more. Go to http://www.vustudents.net and

More information

P 6.3) import java.util.scanner;

P 6.3) import java.util.scanner; P 6.3) import java.util.scanner; public class CurrencyConverter public static void main (String[] args) Scanner in = new Scanner(System.in); System.out.print("How many euros is one dollar: "); double rate

More information

CS 120 Fall 2008 Practice Final Exam v1.0m. Name: Model Solution. True/False Section, 20 points: 10 true/false, 2 points each

CS 120 Fall 2008 Practice Final Exam v1.0m. Name: Model Solution. True/False Section, 20 points: 10 true/false, 2 points each CS 120 Fall 2008 Practice Final Exam v1.0m Name: Model Solution True/False Section, 20 points: 10 true/false, 2 points each Multiple Choice Section, 32 points: 8 multiple choice, 4 points each Code Tracing

More information

Graphical User Interfaces 2

Graphical User Interfaces 2 Graphical User Interfaces 2 CSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2014 2011 Extending JFrame Dialog boxes Overview Ge

More information

CIS 120 Programming Languages and Techniques. Final Exam, May 3, 2011

CIS 120 Programming Languages and Techniques. Final Exam, May 3, 2011 CIS 120 Programming Languages and Techniques Final Exam, May 3, 2011 Name: Pennkey: My signature below certifies that I have complied with the University of Pennsylvania s Code of Academic Integrity in

More information

UML and OOD. Some terms related to OOD. Dependency. Coupling. Interfaces. Multiple Interfaces

UML and OOD. Some terms related to OOD. Dependency. Coupling. Interfaces. Multiple Interfaces UML and OOD Some terms related to OOD What are good systems like? Most real systems are too big for a single developer to understand everything about the system modules. How do we break a system into modules/components/classes?

More information

Chapter 14: Applets and More

Chapter 14: Applets and More Chapter 14: Applets and More Starting Out with Java: From Control Structures through Objects Fifth Edition by Tony Gaddis Chapter Topics Chapter 14 discusses the following main topics: Introduction to

More information

8/23/2014. Chapter Topics. Introduction to Applets. Introduction to Applets. Introduction to Applets. Applet Limitations. Chapter 14: Applets and More

8/23/2014. Chapter Topics. Introduction to Applets. Introduction to Applets. Introduction to Applets. Applet Limitations. Chapter 14: Applets and More Chapter 14: Applets and More Starting Out with Java: From Control Structures through Objects Fifth Edition by Tony Gaddis Chapter Topics Chapter 14 discusses the following main topics: Introduction to

More information

Dartmouth College Computer Science 10, Winter 2012 Solution to Midterm Exam

Dartmouth College Computer Science 10, Winter 2012 Solution to Midterm Exam Dartmouth College Computer Science 10, Winter 2012 Solution to Midterm Exam Thursday, February 9, 2012 Professor Drysdale Print your name: If you need more space to answer a question than we give you,

More information

UNIT-3 : MULTI THREADED PROGRAMMING, EVENT HANDLING. A Multithreaded program contains two or more parts that can run concurrently.

UNIT-3 : MULTI THREADED PROGRAMMING, EVENT HANDLING. A Multithreaded program contains two or more parts that can run concurrently. UNIT-3 : MULTI THREADED PROGRAMMING, EVENT HANDLING 1. What are Threads? A thread is a single path of execution of code in a program. A Multithreaded program contains two or more parts that can run concurrently.

More information

L4,5: Java Overview II

L4,5: Java Overview II L4,5: Java Overview II 1. METHODS Methods are defined within classes. Every method has an associated class; in other words, methods are defined only within classes, not standalone. Methods are usually

More information

Inheritance Systems. Merchandise. Television Camcorder Shirt Shoe Dress 9.1.1

Inheritance Systems. Merchandise. Television Camcorder Shirt Shoe Dress 9.1.1 Merchandise Inheritance Systems Electronics Clothing Television Camcorder Shirt Shoe Dress Digital Analog 9.1.1 Another AcademicDisciplines Hierarchy Mathematics Engineering Algebra Probability Geometry

More information

Kirill Grouchnikov, Amdocs Desktop Matters Conference San Jose, March

Kirill Grouchnikov, Amdocs Desktop Matters Conference San Jose, March Kirill Grouchnikov, Amdocs Desktop Matters Conference San Jose, March 8-9 2007 Show two sample effects on buttons Show how this can be achieved with UI delegates Discuss alternative implementations Custom

More information

I/O Framework and Case Study. CS151 Chris Pollett Nov. 2, 2005.

I/O Framework and Case Study. CS151 Chris Pollett Nov. 2, 2005. I/O Framework and Case Study CS151 Chris Pollett Nov. 2, 2005. Outline Character Streams Random Access Files Design case study Planning Iterations Character Streams Java internally represents strings as

More information

Aggregation. Chapter 8. Java By Abstraction Chapter 8. Outline. 8.1 What is Aggregation? Copyright 2006 Pearson Education Canada Inc.

Aggregation. Chapter 8. Java By Abstraction Chapter 8. Outline. 8.1 What is Aggregation? Copyright 2006 Pearson Education Canada Inc. Chapter 8 Aggregation Java By Abstraction 8- Outline 8. What is Aggregation? 8.. Definition and Terminology 8..2 The Aggregate s Constructor 8..3 Accessors and Mutators 8..4 The Client s Perspective 8..5

More information

Chapter 14: Applets and More

Chapter 14: Applets and More Chapter 14: Applets and More Starting Out with Java: From Control Structures through Objects Fourth Edition by Tony Gaddis Addison Wesley is an imprint of 2010 Pearson Addison-Wesley. All rights reserved.

More information

OBJECT ORIENTED PROGRAMMING. Course 8 Loredana STANCIU Room B613

OBJECT ORIENTED PROGRAMMING. Course 8 Loredana STANCIU Room B613 OBJECT ORIENTED PROGRAMMING Course 8 Loredana STANCIU loredana.stanciu@upt.ro Room B613 Applets A program written in the Java programming language that can be included in an HTML page A special kind of

More information

: 15. (x, y) (x, y ) (x, y) ( x x = 1 y = y ) (x = x y y = 1) (12.1.1)

: 15. (x, y) (x, y ) (x, y) ( x x = 1 y = y ) (x = x y y = 1) (12.1.1) 73 12 12.1 15 15 ( 12.1.1) 16 15 15 12.1.1: 15 15 (x, y) x y 0 3 0 0 (x, y ) (x, y) ( x x = 1 y = y ) (x = x y y = 1) (12.1.1) 74 12 Program 12.1.1 Piace.java import java.awt.*; public class Piece { private

More information

The Nervous Shapes Example

The Nervous Shapes Example The Nervous Shapes Example This Example is taken from Dr. King s Java book 1 11.6 Abstract Classes Some classes are purely artificial, created solely so that subclasses can take advantage of inheritance.

More information

Chapter 1 GUI Applications

Chapter 1 GUI Applications Chapter 1 GUI Applications 1. GUI Applications So far we've seen GUI programs only in the context of Applets. But we can have GUI applications too. A GUI application will not have any of the security limitations

More information

The AWT Package, Graphics- Introduction to Images

The AWT Package, Graphics- Introduction to Images Richard G Baldwin (512) 223-4758, baldwin@austin.cc.tx.us, http://www2.austin.cc.tx.us/baldwin/ The AWT Package, Graphics- Introduction to Images Java Programming, Lecture Notes # 170, Revised 09/23/98.

More information

Reviewing OO Concepts

Reviewing OO Concepts Reviewing OO Concepts Users want to draw circles onto the display canvas. public class Circle { // more code here SWEN-261 Introduc2on to So3ware Engineering Department of So3ware Engineering Rochester

More information

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class CHAPTER GRAPHICAL USER INTERFACES 10 Slides by Donald W. Smith TechNeTrain.com Final Draft 10/30/11 10.1 Frame Windows Java provides classes to create graphical applications that can run on any major graphical

More information

Module 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Module 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani Module 5 The Applet Class, Swings OOC 4 th Sem, B Div 2017-18 Prof. Mouna M. Naravani The Applet Class Types of Applets (Abstract Window Toolkit) Offers richer and easy to use interface than AWT. An Applet

More information

Graphical User Interfaces 2

Graphical User Interfaces 2 Graphical User Interfaces 2 CSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2011 Extending JFrame Dialog boxes Ge?ng user input Overview Displaying message or error Listening for

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 32 April 9, 2018 Swing I: Drawing and Event Handling Chapter 29 HW8: Spellchecker Available on the web site Due: Tuesday! Announcements Parsing, working

More information