II 12, JFileChooser. , 2. SolidEllipse ( 2), PolyLine.java ( 3). Draw.java
|
|
- Barrie Gregory
- 5 years ago
- Views:
Transcription
1 II 12, , 17 2 : 1 2, JFileChooser, 2,,, Draw 1, SolidEllipse ( 2), PolyLinejava ( 3) 1 Drawjava 2 import javaxswing*; 3 import javaawtevent*; import javautil*; 5 import javaio*; 6 7 public class Draw extends JFrame { 8 public Draw() { 9 factory = factories [0]; 10 figs = new FigureList(); 11 } public static void main(string[] args) { 1 Draw app = new Draw(); 15 appsetmenu(); 16 appsetsize(500, 00); 17 app setvisible(true); 18 app setdefaultcloseoperation( DISPOSE_ON_CLOSE); TheMouseListener listener = appnew TheMouseListener (); 21 app addmouselistener(listener); 22 app addmousemotionlistener(listener); 23 app addwindowlistener(appnew TheWindowListener ()); 2 } void setmenu() { 27 JMenuBar mb = new JMenuBar(); 28 addfilemenu(mb); 29 addeditmenu(mb); 30 setjmenubar(mb); 31 } 32 1
2 33 void addfilemenu( JMenuBar mb) { 3 JMenu mn = new JMenu("File"); addmenuitem(mn, "Save", new SaveFileHandler ()); 37 addmenuitem(mn, "Load", new LoadFileHandler ()); mn addseparator (); 0 addmenuitem(mn, "Exit", new ExitHandler ()); 1 2 mbadd(mn); 3 } 5 void addeditmenu( JMenuBar mb) { 6 JMenu mn = new JMenu("Edit"); 7 8 for (int i = 0; i < factorieslength; ++i) { 9 JRadioButtonMenuItem item = 50 new JRadioButtonMenuItem( factories[i] name(), i == 0); 51 mnadd(item); 52 item addactionlistener(new FigureItemHandler( factories[i])); 53 figurebuttonsadd(item); 5 } mn addseparator (); 57 addmenuitem(mn, "Undo", null); mbadd(mn); 60 } void addmenuitem(jmenu mn, String title, ActionListener listener) { 63 JMenuItem item = new JMenuItem(title); 6 mnadd(item); 65 if (listener!= null) { 66 item addactionlistener(listener); 67 } 68 } public void paint(graphics g) { 71 superpaint(g); 72 figsdraw(g); 73 } 7 75 FigureList figs; 76 Figure prevfig = FigureFactory nullfigure; 77 ButtonGroup figurebuttons = new ButtonGroup (); 78 JFileChooser fc = new JFileChooser(); class FigureItemHandler implements ActionListener { 81 public FigureItemHandler(FigureFactory factory) { 82 thefactory = factory; 83 } 8 85 public void actionperformed( ActionEvent e) { 86 factory = thefactory; 87 repaint(); 88 } FigureFactory thefactory; 91 }; class TheWindowListener extends WindowAdapter { 9 public void windowclosing( WindowEvent e) { 95 Systemexit(0); 96 } 97 }; class ExitHandler implements ActionListener { 100 public void actionperformed( ActionEvent e) { 101 Systemexit(0); 102 } 103 }; class TheMouseListener extends MouseAdapter implements MouseMotionListener { 106 public void mousepressed( MouseEvent e) { 107 if (e getclickcount() == 1) { 2
3 108 factoryaddpoint(egetpoint ()); 109 } else { 110 factory terminate(); 111 } if (factory iscompleted()) { 11 Graphics g = getgraphics (); 115 prevfigdraw(g); 116 Figure newfig = factorygenerate(); 117 if (newfig!= FigureFactory nullfigure) { 118 figs addfigure(newfig); 119 } 120 prevfig = FigureFactory nullfigure; 121 repaint(); 122 } 123 } public void mousedragged( MouseEvent e) { } public void mousemoved( MouseEvent e) { 128 Graphics g = getgraphics(); 129 prevfigdraw(g); 130 factory addtmppoint(egetpoint ()); 131 prevfig = factory tmpgenerate (); 132 prevfigdraw(g); 133 } public void mousereleased( MouseEvent e) { } 136 }; FigureFactory factory; FigureFactory[] factories = { 11 Line getfactory(), 12 Box getfactory(), 13 PolyLine getfactory(), 1 SolidEllipse getfactory(), 15 }; class LoadFileHandler implements ActionListener { 18 public void actionperformed( ActionEvent e) { 19 repaint(); 150 int retval = fc showopendialog(null); 151 if (retval == JFileChooser APPROVE_OPTION) { 152 File f = fc getselectedfile (); 153 try { 15 FileInputStream istream = new FileInputStream(f); 155 ObjectInputStream p = new ObjectInputStream(istream); figs = ( FigureList)p readobject(); 158 istreamclose(); 159 } 160 catch ( FileNotFoundException ex) { 161 Systemoutprintln(" FileNotFoundException"); 162 } 163 catch ( ClassNotFoundException ex) { 16 Systemoutprintln(" ClassNotFoundException"); 165 } 166 catch ( IOException ex) { 167 Systemoutprintln(" IOException"); 168 } 169 finally { 170 repaint(); 171 } 172 } 173 } 17 }; class SaveFileHandler implements ActionListener { 177 public void actionperformed( ActionEvent e) { 178 repaint(); 179 int retval = fc showsavedialog(null); 180 if (retval == JFileChooser APPROVE_OPTION) { 181 File f = fc getselectedfile (); 182 try { 3
4 183 FileOutputStream ostream = new FileOutputStream(f); 18 ObjectOutputStream p = new ObjectOutputStream(ostream); p writeobject(figs); 187 pflush(); 188 ostreamclose(); 189 } 190 catch ( FileNotFoundException ex) { 191 Systemoutprintln(" FileNotFoundException"); 192 } 193 catch ( IOException ex) { 19 Systemoutprintln(" IOException"); 195 } 196 } 197 } 198 }; 199 }; 2 SolidEllipsejava 2 import javalang*; 3 import javalang*; 5 public class SolidEllipse extends Rectangular { 6 public SolidEllipse(Point p, Point q) { 7 super(p, q); 8 } 9 10 public void draw(graphics g) { 11 gfilloval(lt()x, lt()y, width(), height()); 12 } 13 1 public static FigureFactory getfactory() { 15 return factory; 16 } static Factory factory = new Factory(); static class Factory extends RectangularFactory { 21 protected Factory() { } 22 public String name() { return " SolidEllipse"; } protected Figure gen() { 26 if (iscompleted()) { 27 return new SolidEllipse(p(), q()); 28 } else { 29 return nullfigure; 30 } 31 } 32 }; 33 }; 3 PolyLinejava 2 import javalang*; 3 import javautil*; 5 public class PolyLine extends Figure { 6 PolyLine( ArrayList points) { 7 thispoints = new Point[pointssize()]; 8 for (int i = 0; i < pointssize(); ++i) { 9 thispoints[i] = (Point)pointsget(i); 10 } 11 } public void draw(graphics g) { 1 Point p = points[0]; 15 for (int i = 1; i < pointslength; ++i) { 16 Point q = points[i]; 17 gdrawline(px, py, qx, qy); 18 p = q;
5 19 } 20 } public void move(point vec) { 23 for (int i = 0; i < pointslength; ++i) { 2 points[i] = movepoint(points[i], vec); 25 } 26 } public static FigureFactory getfactory() { 29 return factory; 30 } Point[] points; 33 static Factory factory = new Factory(); 3 35 static class Factory extends FigureFactory { 36 protected Factory() { } 37 public String name() { return "PolyLine"; } public void addpoint(point p) { 0 if (npoints == 0) { 1 pointsadd(new Point(p)); 2 npoints = 1; 3 } else { pointsset(npoints -1, new Point(p)); 5 } 6 ++npoints; 7 pointsadd(null); 8 } 9 50 public void addtmppoint(point p) { 51 if (npoints > 0) { 52 pointsset(npoints -1, new Point(p)); 53 } 5 } public boolean iscompleted() { return completed; } protected Figure gen() { 59 if (npoints >= 2) { 60 if (pointsget(npoints -1) == null) { 61 pointsremove(npoints -1); 62 } 63 return new PolyLine(points); 6 } else { 65 return nullfigure; 66 } 67 } public void clear() { 70 pointsclear(); 71 npoints = 0; 72 completed = false; 73 } 7 75 public void terminate() { 76 completed = true; 77 } static ArrayList points = new ArrayList(); 80 static boolean completed = false; 81 static int npoints = 0; 82 }; 83 }; 5
13 (ono@is.nagoya-u.ac.jp) 2008 1 15 1 factory., factory,. 2 2.,, JFileChooser. 1. Java,,, Serializable *1., FigBase ( 1). FigBase.java 3 5. 1 import java. lang.*; 2 import java. awt.*; 3 import java.
More informationMethod Of Key Event Key Listener must implement three methods, keypressed(), keyreleased() & keytyped(). 1) keypressed() : will run whenever a key is
INDEX Event Handling. Key Event. Methods Of Key Event. Example Of Key Event. Mouse Event. Method Of Mouse Event. Mouse Motion Listener. Example of Mouse Event. Event Handling One of the key concept in
More informationOOP 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 informationA Simple Text Editor Application
CASE STUDY 7 A Simple Text Editor Application To demonstrate the JTextArea component, fonts, menus, and file choosers we present a simple text editor application. This application allows you to create
More informationImplementing Graphical User Interfaces
Chapter 6 Implementing Graphical User Interfaces 6.1 Introduction To see aggregation and inheritance in action, we implement a graphical user interface (GUI for short). This chapter is not about GUIs,
More informationChapter 13 Lab Advanced GUI Applications Lab Objectives. Introduction. Task #1 Creating a Menu with Submenus
Chapter 13 Lab Advanced GUI Applications Lab Objectives Be able to add a menu to the menu bar Be able to use nested menus Be able to add scroll bars, giving the user the option of when they will be seen.
More informationChapter 13 Lab Advanced GUI Applications
Gaddis_516907_Java 4/10/07 2:10 PM Page 113 Chapter 13 Lab Advanced GUI Applications Objectives Be able to add a menu to the menu bar Be able to use nested menus Be able to add scroll bars, giving the
More informationVirtualians.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 informationLecture 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 informationLecture 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 informationQueens College, CUNY Department of Computer Science. CS 212 Object-Oriented Programming in Java Practice Exam 2. CS 212 Exam 2 Study Guide
Topics for Exam 2: Queens College, CUNY Department of Computer Science CS 212 Object-Oriented Programming in Java Practice Exam 2 CS 212 Exam 2 Study Guide Linked Lists define a list node define a singly-linked
More informationCN208 Introduction to Computer Programming
CN208 Introduction to Computer Programming Lecture #11 Streams (Continued) Pimarn Apipattanamontre Email: pimarn@pimarn.com 1 The Object Class The Object class is the direct or indirect superclass of every
More informationAdvanced Java Unit 6: Review of Graphics and Events
Advanced Java Unit 6: Review of Graphics and Events This is a review of the basics of writing a java program that has a graphical interface. To keep things simple, all of the graphics programs will follow
More informationBuilding Graphical User Interfaces. GUI Principles
Building Graphical User Interfaces 4.1 GUI Principles Components: GUI building blocks Buttons, menus, sliders, etc. Layout: arranging components to form a usable GUI Using layout managers. Events: reacting
More informationUnit 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 informationChapter 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 informationBased on slides by Prof. Burton Ma
Based on slides by Prof. Burton Ma 1 TV - on : boolean - channel : int - volume : int + power(boolean) : void + channel(int) : void + volume(int) : void Model View Controller RemoteControl + togglepower()
More information11/7/12. Discussion of Roulette Assignment. Objectives. Compiler s Names of Classes. GUI Review. Window Events
Objectives Event Handling Animation Discussion of Roulette Assignment How easy/difficult to refactor for extensibility? Was it easier to add to your refactored code? Ø What would your refactored classes
More informationGraphical 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 informationI/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 informationpublic 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 informationJava Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing
Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing Rui Moreira Some useful links: http://java.sun.com/docs/books/tutorial/uiswing/toc.html http://www.unix.org.ua/orelly/java-ent/jfc/
More informationAP Computer Science Unit 13. Still More Graphics and Animation.
AP Computer Science Unit 13. Still More Graphics and Animation. In this unit you ll learn about the following: Mouse Motion Listener Suggestions for designing better graphical programs Simple game with
More informationCS 335 Graphics and Multimedia. Image Manipulation
CS 335 Graphics and Multimedia Image Manipulation Image Manipulation Independent pixels: image subtraction image averaging grey level mapping thresholding Neighborhoods of pixels: filtering, convolution,
More information) / Java ( )
2002 3 2003.1.29 1 3 ( ) ( ) / Java ( ) 1 ( )? ( ) 2 (3 ) 3 Java Java Java (dynamic dispatch) ( ) import java.awt.*; import java.awt.event.*; public class Sample30 extends Frame { boolean go; double time;
More informationCome & 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 informationProgrammierpraktikum
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 informationJava 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 informationSD Module-1 Advanced JAVA
Assignment No. 4 SD Module-1 Advanced JAVA R C (4) V T Total (10) Dated Sign Title: Transform the above system from command line system to GUI based application Problem Definition: Write a Java program
More informationTheory Test 3A. University of Cape Town ~ Department of Computer Science. Computer Science 1016S ~ For Official Use
Please fill in your Student Number and, optionally, Name. For Official Use Student Number : Mark : Name : Marker : University of Cape Town ~ Department of Computer Science Computer Science 1016S ~ 2007
More informationSD Module-1 Advanced JAVA. Assignment No. 4
SD Module-1 Advanced JAVA Assignment No. 4 Title :- Transform the above system from command line system to GUI based application Problem Definition: Write a Java program with the help of GUI based Application
More information08/23/03 10:49:32 Table of Contents
08/23/03 10:49:32 Table of Contents 0 1 PaintBox.java 1 pages 31 lines 03/08/21 21:29:00 2 Shape.java 4 pages 162 lines 03/08/21 22:02:34 3 Line.java 8 pages 227 lines 03/08/21 22:02:34 4 Poly.java 14
More information1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall (total 7 pages)
1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall 2002 (total 7 pages) Name: TA s Name: Tutorial: For Graders Question 1 Question 2 Question 3 Total Problem 1 (20 points) True or
More informationBuilding Graphical User Interfaces. Overview
Building Graphical User Interfaces 4.1 Overview Constructing GUIs Interface components GUI layout Event handling 2 1 GUI Principles Components: GUI building blocks. Buttons, menus, sliders, etc. Layout:
More informationDr. Hikmat A. M. AbdelJaber
Dr. Hikmat A. M. AbdelJaber GUI are event driven (i.e. when user interacts with a GUI component, the interaction (event) derives the program to perform a task). Event: click button, type in text field,
More informationStream Manipulation. Lecture 11
Stream Manipulation Lecture 11 Streams and I/O basic classes for file IO FileInputStream, for reading from a file FileOutputStream, for writing to a file Example: Open a file "myfile.txt" for reading FileInputStream
More informationOverview. Building Graphical User Interfaces. GUI Principles. AWT and Swing. Constructing GUIs Interface components GUI layout Event handling
Overview Building Graphical User Interfaces Constructing GUIs Interface components GUI layout Event handling 4.1 GUI Principles AWT and Swing Components: GUI building blocks. Buttons, menus, sliders, etc.
More informationCSE 8B Intro to CS: Java
CSE 8B Intro to CS: Java Winter, 2006 February 23 (Day 14) Menus Swing Event Handling Inner classes Instructor: Neil Rhodes JMenuBar container for menus Menus associated with a JFrame via JFrame.setMenuBar
More informationPackages: Putting Classes Together
Packages: Putting Classes Together 1 Introduction 2 The main feature of OOP is its ability to support the reuse of code: Extending the classes (via inheritance) Extending interfaces The features in basic
More informationGraphical Interfaces
Weeks 11&12 Graphical Interfaces All the programs that you have created until now used a simple command line interface, which is not user friendly, so a Graphical User Interface (GUI) should be used. The
More informationSTREAMS. (fluxos) Objetivos
STREAMS (fluxos) Objetivos To be able to read and write files To become familiar with the concepts of text and binary files To be able to read and write objects using serialization To be able to process
More informationPESIT 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 information1.1 GUI. JFrame. import java.awt.*; import javax.swing.*; public class XXX extends JFrame { public XXX() { // XXX. init() main() public static
18 7 17 1 1.1 GUI ( ) GUI ( ) JFrame public class XXX extends JFrame { public XXX() { // XXX // init()... // ( )... init() main() public static public class XXX extends JFrame { public XXX() { // setsize(,
More informationCS 251 Intermediate Programming GUIs: Event Listeners
CS 251 Intermediate Programming GUIs: Event Listeners Brooke Chenoweth University of New Mexico Fall 2017 What is an Event Listener? A small class that implements a particular listener interface. Listener
More informationLecture 28. Exceptions and Inner Classes. Goals. We are going to talk in more detail about two advanced Java features:
Lecture 28 Exceptions and Inner Classes Goals We are going to talk in more detail about two advanced Java features: Exceptions supply Java s error handling mechanism. Inner classes ease the overhead of
More informationName Section. CS 21a Introduction to Computing I 1 st Semester Final Exam
CS a Introduction to Computing I st Semester 00-00 Final Exam Write your name on each sheet. I. Multiple Choice. Encircle the letter of the best answer. ( points each) Answer questions and based on the
More informationHandout 14 Graphical User Interface (GUI) with Swing, Event Handling
Handout 12 CS603 Object-Oriented Programming Fall 15 Page 1 of 12 Handout 14 Graphical User Interface (GUI) with Swing, Event Handling The Swing library (javax.swing.*) Contains classes that implement
More informationMore Swing. CS180 Recitation 12/(04,05)/08
More Swing CS180 Recitation 12/(04,05)/08 Announcements No lecture/labs next week Recitations and evening consulting hours will be held as usual. Debbie's study group on tuesday and office hours on thursday
More informationimport javax.swing.*; import java.awt.*; import java.awt.event.*;
I need to be walked through with why the stocks are being recognized "half way." They will print out in the console but won't be recognized by certain code. Every line of code seems to look right and that's
More informationAP CS Unit 11: Graphics and Events
AP CS Unit 11: Graphics and Events This packet shows how to create programs with a graphical interface in a way that is consistent with the approach used in the Elevens program. Copy the following two
More informationUser 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 informationMIT AITI Swing Event Model Lecture 17
MIT AITI 2004 Swing Event Model Lecture 17 The Java Event Model In the last lecture, we learned how to construct a GUI to present information to the user. But how do GUIs interact with users? How do applications
More informationName:... ID:... class A { public A() { System.out.println( "The default constructor of A is invoked"); } }
KSU/CCIS/CS CSC 113 Final exam - Fall 12-13 Time allowed: 3:00 Name:... ID:... EXECRICE 1 (15 marks) 1.1 Write the output of the following program. Output (6 Marks): class A public A() System.out.println(
More informationExample Programs. COSC 3461 User Interfaces. GUI Program Organization. Outline. DemoHelloWorld.java DemoHelloWorld2.java DemoSwing.
COSC User Interfaces Module 3 Sequential vs. Event-driven Programming Example Programs DemoLargestConsole.java DemoLargestGUI.java Demo programs will be available on the course web page. GUI Program Organization
More informationRAIK 183H Examination 2 Solution. November 10, 2014
RAIK 183H Examination 2 Solution November 10, 2014 Name: NUID: This examination consists of 5 questions and you have 110 minutes to complete the test. Show all steps (including any computations/explanations)
More informationCSIS 10A Assignment 14 SOLUTIONS
CSIS 10A Assignment 14 SOLUTIONS Read: Chapter 14 Choose and complete any 10 points from the problems below, which are all included in the download file on the website. Use BlueJ to complete the assignment,
More informationWhat is Serialization?
Serialization 1 Topics What is Serialization? What is preserved when an object is serialized? Transient keyword Process of serialization Process of deserialization Version control Changing the default
More informationControl Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User
CSE3461 Control Flow Paradigms: Reacting to the User Control Flow: Overview Definition of control flow: The sequence of execution of instructions in a program. Control flow is determined at run time by
More informationGUI Program Organization. Sequential vs. Event-driven Programming. Sequential Programming. Outline
Sequential vs. Event-driven Programming Reacting to the user GUI Program Organization Let s digress briefly to examine the organization of our GUI programs We ll do this in stages, by examining three example
More informationAttempt FOUR questions Marking Scheme Time: 120 mins
Ahmadu Bello University Department of Computer Science Second Semester Examinations August 2017 COSC212: Object Oriented Programming II Marking Scheme Attempt FOUR questions Marking Scheme Time: 120 mins
More informationGraphic 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 informationApplet 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 informationH212 Introduction to Software Systems Honors
Introduction to Software Systems Honors Lecture #19: November 4, 2015 1/14 Third Exam The third, Checkpoint Exam, will be on: Wednesday, November 11, 2:30 to 3:45 pm You will have 3 questions, out of 9,
More informationAP CS Unit 12: Drawing and Mouse Events
AP CS Unit 12: Drawing and Mouse Events A JPanel object can be used as a container for other objects. It can also be used as an object that we can draw on. The first example demonstrates how to do that.
More informationWindow Interfaces Using Swing Objects
Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs
More informationContents Chapter 1 Introduction to Programming and the Java Language
Chapter 1 Introduction to Programming and the Java Language 1.1 Basic Computer Concepts 5 1.1.1 Hardware 5 1.1.2 Operating Systems 8 1.1.3 Application Software 9 1.1.4 Computer Networks and the Internet
More informationWindow Interfaces Using Swing Objects
Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs
More informationPhase 2: Due 11/28/18: Additional code to add, move and remove vertices in response to user mouse clicks on the screen.
Fall 2018 CS313 Project Implementation of a GUI to work with Graphs. Reminder: This is a pass/fail assignment. If you fail the assignment you will lose half a grade from your course grade. If you pass
More informationLecture 7. File Processing
Lecture 7 File Processing 1 Data (i.e., numbers and strings) stored in variables, arrays, and objects are temporary. They are lost when the program terminates. To permanently store the data created in
More informationThe Scanner class reads data entered by the user. Methods: COSC Dr. Ramon Lawrence. Page 3. COSC Dr. Ramon Lawrence A) A = 6, B = 3
COSC 123 Computer Creativity Course Review Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Reading Data from the User The Scanner Class The Scanner class reads data entered
More informationGraphical Interfaces
Weeks 9&11 Graphical Interfaces All the programs that you have created until now used a simple command line interface, which is not user friendly, so a Graphical User Interface (GUI) should be used. The
More informationAN IMPROTANT COLLECTION OF JAVA IO RELATED PROGRAMS
JAVALEARNINGS.COM AN IMPROTANT COLLECTION OF JAVA IO RELATED PROGRAMS Visit for more pdf downloads and interview related questions JAVALEARNINGS.COM /* Write a program to write n number of student records
More informationInteracción con GUIs
Interacción con GUIs Delegation Event Model Fuente EVENTO Oyente suscripción Fuente Oyente suscripción EVENTO Adaptador EVENTO java.lang.object java.util.eventobject java.awt.awtevent java.awt.event. ActionEvent
More informationCSC 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 information1005ICT Object Oriented Programming Lecture Notes
1005ICT Object Oriented Programming Lecture Notes School of Information and Communication Technology Griffith University Semester 2, 2015 1 20 GUI Components and Events This section develops a program
More informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CISC124, WINTER TERM, 2011 FINAL EXAMINATION 7pm to 10pm, 26 APRIL 2011, Ross Gym Instructor: Alan McLeod If the instructor
More informationGraphical 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 informationCSEN401 Computer Programming Lab. Topics: Graphical User Interface Window Interfaces using Swing
CSEN401 Computer Programming Lab Topics: Graphical User Interface Window Interfaces using Swing Prof. Dr. Slim Abdennadher 22.3.2015 c S. Abdennadher 1 Swing c S. Abdennadher 2 AWT versus Swing Two basic
More informationProgram 20: //Design an Applet program to handle Mouse Events. import java.awt.*; import java.applet.*; import java.awt.event.*;
Program 20: //Design an Applet program to handle Mouse Events. import java.awt.*; import java.applet.*; import java.awt.event.*; /* */ public
More informationG51PRG: 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 informationPart 3: Graphical User Interface (GUI) & Java Applets
1,QWURGXFWLRQWR-DYD3URJUDPPLQJ (( Part 3: Graphical User Interface (GUI) & Java Applets EE905-GUI 7RSLFV Creating a Window Panels Event Handling Swing GUI Components ƒ Layout Management ƒ Text Field ƒ
More informationInput from Files. Buffered Reader
Input from Files Buffered Reader Input from files is always text. You can convert it to ints using Integer.parseInt() We use BufferedReaders to minimize the number of reads to the file. The Buffer reads
More informationagentmom User's Manual
July 2000 agentmom User's Manual Scott A. DeLoach GRADUATE SCHOOL OF ENGINEERING AND MANAGEMENT AIR FORCE INSTITUTE OF TECHNOLOGY WRIGHT-PATTERSON AIR FORCE BASE, OHIO Approved for public release; distribution
More informationPhase 2: Due 05/02/18 The Gui now stores and displays a graph in response to user mouse clicks on the screen.
Spring 2018 CS313 Project Implementation of a GUI to work with Graphs. Reminder: This is a pass/fail assignment, you must pass it to pass the course. You do not have to do a perfect job to pass the assignment,
More informationUNIT-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 informationGraphical 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 informationEXCEPTIONS & GUI. Errors are signals that things are beyond help. Review Session for. -Ankur Agarwal
Review Session for EXCEPTIONS & GUI -Ankur Agarwal An Exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions. Errors are signals
More informationA sample print out is: is is -11 key entered was: w
Lab 9 Lesson 9-2: Exercise 1, 2 and 3: Note: when you run this you may need to maximize the window. The modified buttonhandler is: private static class ButtonListener implements ActionListener public void
More informationChapter 18. Advanced graphics programming
Chapter 18 Advanced graphics programming Making choices With graphical applications, there are a number of ways of providing choices to the user: pull-down menus; pop-up menus dialogue windows; radio buttons;
More informationAdvanced Java. Guide 108. Version 1.2
Guide 108 Version 1.2 Advanced Java The tutorial given in ITS Guide 58: Getting started with Java provides basic information on developing programs in the Java programming language. This Guide introduces
More informationFILE I/O IN JAVA. Prof. Chris Jermaine
FILE I/O IN JAVA Prof. Chris Jermaine cmj4@cs.rice.edu 1 Our Simple Java Programs So Far Aside from screen I/O......when they are done, they are gone They have no lasting effect on the world When the program
More informationNORTHWEST NAZARENE UNIVERSITY. Cyclops An Open Source Educational Tool for Modeling Digital Logic
NORTHWEST NAZARENE UNIVERSITY Cyclops An Open Source Educational Tool for Modeling Digital Logic THESIS Submitted to the Department of Mathematics and Computer Science in partial fulfillment of the requirements
More informationG51PGP 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 informationOutline. 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 informationEvent Driven Programming
Event Driven Programming 1. Objectives... 2 2. Definitions... 2 3. Event-Driven Style of Programming... 2 4. Event Polling Model... 3 5. Java's Event Delegation Model... 5 6. How to Implement an Event
More informationBM214E Object Oriented Programming Lecture 13
BM214E Object Oriented Programming Lecture 13 Events To understand how events work in Java, we have to look closely at how we use GUIs. When you interact with a GUI, there are many events taking place
More informationJRadioButton account_type_radio_button2 = new JRadioButton("Current"); ButtonGroup account_type_button_group = new ButtonGroup();
Q)Write a program to design an interface containing fields User ID, Password and Account type, and buttons login, cancel, edit by mixing border layout and flow layout. Add events handling to the button
More informationChapter 11 Handling Exceptions and Events. Chapter Objectives
Chapter 11 Handling Exceptions and Events Chapter Objectives Learn what an exception is See how a try/catch block is used to handle exceptions Become aware of the hierarchy of exception classes Learn about
More informationOutline. 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 informationJ.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