Code zum Betreuten Programmieren vom , Blatt 10 Serialisierung und GUI
|
|
- Gary McCarthy
- 6 years ago
- Views:
Transcription
1 SS 2011 Fakultät für Angewandte Informatik Lehrprofessur für Informatik Prof. Dr. Robert Lorenz Code zum Betreuten Programmieren vom , Blatt 10 Serialisierung und GUI 1 Die Klasse Field 1 import java.awt.button; 2 import java.awt.panel; 3 import java.awt.gridlayout; 4 import java.awt.event.actionevent; 5 import java.awt.event.actionlistener; 6 import java.awt.color; 7 import java.io.serializable; 8 import java.util.arraylist; 9 10 public class Field extends Panel implements ActionListener, Serializable 11 { 12 private static final long serialversionuid = L; 13 private int clickedbuttons; 14 private ArrayList<String> clicked; 15 private ArrayList<Button> numbers; public Field() 18 { 19 super(); 20 numbers = new ArrayList<Button>(49); 21 for(int i=1;i<=49;i++) 22 { 23 numbers.add(new Button(""+i)); 24 numbers.get(i-1).addactionlistener(this); 25 numbers.get(i-1).setbackground(color.white); 26 add(numbers.get(i-1)); 27 } 28 clicked = new ArrayList<String>(6); 29 clickedbuttons=0; 30 setlayout(new GridLayout(7,7)); 31 setbackground(color.red); 32 } public void actionperformed(actionevent e) 1
2 35 { 36 Button b = (Button)e.getSource(); 37 if(b.getbackground()==color.white && clickedbuttons<6) 38 { 39 b.setbackground(color.magenta); 40 clicked.add(b.getlabel()); 41 clickedbuttons++; 42 } 43 else if(b.getbackground()==color.magenta) 44 { 45 b.setbackground(color.white); 46 clicked.remove(b.getlabel()); 47 clickedbuttons--; 48 } 49 } public void redo() 52 { 53 for(int i=0;i<numbers.size();i++) 54 { 55 numbers.get(i).setbackground(color.white); 56 clicked.clear(); 57 } 58 clickedbuttons=0; 59 } public ArrayList<String> getclicked() 62 { 63 return clicked; 64 } public boolean isok() 67 { 68 if(clickedbuttons==0 clickedbuttons==6) 69 return true; 70 else 71 return false; 72 } 73 } 2 Die Klasse LotteryTicker 1 import java.awt.borderlayout; 2 import java.awt.button; 3 import java.awt.color; 4 import java.awt.filedialog; 5 import java.awt.frame; 6 import java.awt.gridlayout; 7 import java.awt.label; 8 import java.awt.panel; 9 import java.awt.event.actionevent; 10 import java.awt.event.actionlistener; 11 import java.awt.event.windowadapter; 2
3 12 import java.awt.event.windowevent; 13 import java.io.fileinputstream; 14 import java.io.fileoutputstream; 15 import java.io.objectinputstream; 16 import java.io.objectoutputstream; 17 import java.util.arraylist; 18 import java.util.iterator; public class LotteryTicket extends Frame implements ActionListener 21 { 22 private Label msg; 23 private ArrayList<Field> lottofields; 24 private Panel fields; 25 private static final int SAVE = 0; 26 private static final int LOAD = 1; 27 private int TYPE; 28 private Warning warning=null; public LotteryTicket() 31 { 32 super("lottoschein"); 33 setbackground(color.red); 34 lottofields = new ArrayList<Field>(); 35 fields = new Panel(new GridLayout(2,6,2,2)); 36 fields.setbackground(color.red); 37 for(int i=0;i<12;i++) 38 { 39 lottofields.add(new Field()); 40 fields.add(lottofields.get(i)); 41 } 42 Panel buttons = new Panel(); 43 buttons.setbackground(color.white); Button speichern = new Button("Speichern"); 46 speichern.addactionlistener(this); 47 buttons.add(speichern); Button laden = new Button("Laden"); 50 laden.addactionlistener(this); 51 buttons.add(laden); Button loeschen = new Button("Loeschen"); 54 loeschen.addactionlistener(this); 55 buttons.add(loeschen); Label nachricht = new Label("Nachricht: "); 58 buttons.add(nachricht); msg = new Label(); 61 buttons.add(msg); add(fields,borderlayout.north); 3
4 64 add(buttons,borderlayout.center); pack(); addwindowlistener(new WindowAdapter() 69 { 70 public void windowclosing(windowevent e) 71 { 72 dispose(); 73 System.exit(0); 74 } 75 }); 76 setvisible(true); 77 } public void setwarning(warning warning) 80 { 81 this.warning=warning; 82 } public void actionperformed(actionevent e) 85 { 86 if(e.getactioncommand().equals(("speichern"))) 87 { 88 if(checkticket(lottofields)==false) 89 { 90 TYPE=SAVE; 91 new Warning(this,"Der Lottoschein enthält unvollständige Felder"); 92 } 93 else 94 saveticket(); 95 } 96 else if(e.getactioncommand().equals("loeschen")) 97 redoticket(); 98 else if(e.getactioncommand().equals("laden")) 99 { 100 TYPE=LOAD; 101 loadticket(); 102 } 103 else if(e.getactioncommand().equals("ok")) 104 { 105 warning.dispose(); 106 if(type==save) 107 doit(type); 108 } 109 else if(e.getactioncommand().equals("cancel")) 110 { 111 System.out.println(e.getActionCommand()); 112 warning.setvisible(false); 113 warning.dispose(); 114 if(type==load) 115 TYPE=-1; 4
5 116 } 117 } private void doit(int type) 120 { 121 if(type==save) 122 saveticket(); 123 else if (type==load) 124 loadticket(); 125 } private boolean checkticket(arraylist<field> al) 128 { 129 Iterator<Field> it=al.iterator(); 130 boolean isok=true; 131 while(it.hasnext()) 132 { 133 if(it.next().isok()==false) 134 isok = false; 135 } 136 return isok; 137 } private void redoticket() 140 { 141 Iterator<Field> it = lottofields.iterator(); 142 while(it.hasnext()) 143 { 144 it.next().redo(); 145 } 146 msg.settext("zurückgesetzt!"); 147 this.pack(); 148 } private void saveticket() 151 { 152 Iterator<Field> it = lottofields.iterator(); 153 ObjectOutputStream stream=null; 154 FileOutputStream fo=null; 155 String filename; 156 FileDialog fd = new FileDialog(this,"Speichern",FileDialog.SAVE); 157 fd.setalwaysontop(true); 158 fd.setlocation(50, 50); 159 fd.setvisible(true); 160 filename = fd.getfile(); 161 try 162 { 163 fo = new FileOutputStream(filename); 164 stream = new ObjectOutputStream(fo); while(it.hasnext()) 167 { 5
6 168 Field f=it.next(); 169 if(!f.isok()) 170 { 171 f.redo(); 172 } 173 } stream.writeobject(lottofields); 176 msg.settext("schein gespeichert"); 177 stream.close(); 178 for (Field f: lottofields) 179 f.redo(); 180 } 181 catch (Exception e) 182 { msg.settext((e.getstacktrace())[0].tostring()+" schmeisst: "+e.tostring()); 185 } 186 this.pack(); 187 } private void loadticket() 190 { 191 FileInputStream fi=null; 192 ObjectInputStream stream=null; 193 FileDialog fd = new FileDialog(this,"Speichern",FileDialog.SAVE); 194 fd.setalwaysontop(true); 195 fd.setlocation(50, 50); 196 fd.setvisible(true); 197 String filename = fd.getfile(); 198 try 199 { 200 fi = new FileInputStream(filename); 201 stream = new ObjectInputStream(fi); 202 Object o = stream.readobject(); 203 if(o instanceof ArrayList<?>) 204 { 205 if(checkticket((arraylist<field>)o)==false) 206 { 207 new Warning(this,"Der Lottoschein enthält unvollständige Felder"); 208 } 209 if(type==load) 210 { 211 lottofields.clear(); 212 lottofields=(arraylist<field>)o; 213 msg.settext("feld geladen!"); 214 fields.removeall(); 215 for(int i=0;i<lottofields.size();i++) 216 { 217 fields.add(lottofields.get(i)); 218 } 219 msg.settext("geladen"); 6
7 220 } 221 } 222 stream.close(); 223 } 224 catch(exception e) 225 { 226 msg.settext(e.getmessage()); 227 } 228 this.pack(); 229 } 230 } 3 Die Klasse Warning 1 import java.awt.borderlayout; 2 import java.awt.button; 3 import java.awt.dialog; 4 import java.awt.frame; 5 import java.awt.label; 6 import java.awt.event.actionevent; 7 import java.awt.event.actionlistener; 8 9 public class Warning extends Dialog implements ActionListener 10 { 11 private Button ok; 12 private Button cancel; 13 public static final int OK=1; 14 public static final int CANCEL=2; 15 private int action=0; public Warning(LotteryTicket owner, String msg) 18 { 19 super(owner,true); 20 add(new Label(msg),BorderLayout.NORTH); 21 ok = new Button("OK"); 22 cancel = new Button("Cancel"); 23 ok.addactionlistener(owner); 24 cancel.addactionlistener(owner); 25 add(ok,borderlayout.west); 26 add(cancel,borderlayout.east); 27 pack(); 28 owner.setwarning(this); 29 setvisible(true); 30 } public void actionperformed(actionevent e) 33 { 34 if(e.getactioncommand().equals("ok")) 35 action=ok; 36 else if (e.getactioncommand().equals("cancel")) 37 action=cancel; 38 } 39 7
8 40 public int getresult(int type) 41 { 42 return action; 43 } 44 } 8
12% of course grade. CSCI 201L Final - Written Fall /7
12% of course grade 1. Interfaces and Inheritance Does the following code compile? If so, what is the output? If not, why not? Explain your answer. (1.5%) interface I2 { public void meth1(); interface
More informationAdvanced Programming Methods. Seminar 12
Advanced Programming Methods Seminar 12 1. instanceof operator 2. Java Serialization Overview 3. Discuss how we can serialize our ToyLanguage interpreter. Please discuss the implementation of different
More informationData Structures. 03 Streams & File I/O
David Drohan Data Structures 03 Streams & File I/O JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN 0132162709 2012 Pearson Education, Inc., Upper Saddle River, NJ.
More informationExceptions Binary files Sequential/Random access Serializing objects
Advanced I/O Exceptions Binary files Sequential/Random access Serializing objects Exceptions No matter how good of a programmer you are, you can t control everything. Other users Available memory File
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 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 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 informationCMP-326 Exam 2 Spring 2018 Solutions Question 1. Version 1. Version 2
Question 1 30 30 60 60 90 20 20 40 40 60 Question 2 a. b. public Song(String title, String artist, int length, String composer) { this.title = title; this.artist = artist; this.length = length; this.composer
More information!"# $ %&# %####' #&() % # # # #&* # ## +, # -
By Pep Jorge @joseplluisjorge Steema Software July 213!"# $ %&# %####' #&() % # # # #&* # ## +, # -. / " - $- * 11 1 1$ 2 11 1 3 4 / $ 5 5,+67 +68$ Copyright 213 Steema Software SL. Copyright Information.
More informationLösningsförslag till tentamen
till tentamen 1 (5) Kursnamn Objektorienterade applikationer Tentamensdatum 2018-08-27 Program DAI 2 Läsår 2017/2018, lp 3 Examinator Uno Holmer Uppgift 1 (6 p) Detta diagram är ett exempel på designmönstret
More informationBuilding a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver
Building a GUI in Java with Swing CITS1001 extension notes Rachel Cardell-Oliver Lecture Outline 1. Swing components 2. Building a GUI 3. Animating the GUI 2 Swing A collection of classes of GUI components
More informationAWT DIALOG CLASS. Dialog control represents a top-level window with a title and a border used to take some form of input from the user.
http://www.tutorialspoint.com/awt/awt_dialog.htm AWT DIALOG CLASS Copyright tutorialspoint.com Introduction Dialog control represents a top-level window with a title and a border used to take some form
More information10/8/2018 Programming Data Structures. class diagram for assignment 08 review: polymorphism review: exception new: File I/O
10/8/2018 Programming Data Structures class diagram for assignment 08 review: polymorphism review: exception new: File I/O 1 class diagram (informal) link the parent classes and child classes describe
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 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 informationPrevious to Chapter 7 Files
Previous to Chapter 7 Files Recall Scanner from Part I notes. A scanner object can reference a text file Scanner f = new Scanner(new File("file name goes here")); Scanner methods can be applied to reading
More information1 of :32:42
1 2 package oop4_dat4_u; 3 4 /** 5 * 6 * @author Felix Rohrer 7 */ 8 public class Main { 9 10 /** 11 * @param args the command line arguments 12 */ 13 public static void main(string[]
More informationCS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University
CS5000: Foundations of Programming Mingon Kang, PhD Computer Science, Kennesaw State University Files Two types: Text file and Binary file Text file (ASCII file) The file data contains only ASCII values
More informationCSE1720. General Info Continuation of Chapter 9 Read Chapter 10 for next week. Second level Third level Fourth level Fifth level
CSE1720 Click to edit Master Week text 08, styles Lecture 13 Second level Third level Fourth level Fifth level Winter 2014! Thursday, Feb 27, 2014 1 General Info Continuation of Chapter 9 Read Chapter
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 informationLARA TECHNOLOGIES EXAM_SPECIALSIX SECTION-1
Q: 01. SECTION-1 Q: 02 Given: 12. import java.io.*; 13. public class Forest implements Serializable { 14. private Tree tree = new Tree(); 15. public static void main(string [] args) { 16. Forest f = new
More informationCMPSCI 187: Programming With Data Structures. Lecture #24: Files and a Case Study David Mix Barrington 2 November 2012
CMPSCI 187: Programming With Data Structures Lecture #24: Files and a Case Study David Mix Barrington 2 November 2012 Files and a Case Study Volatile and Non-Volatile Storage Storing and Retrieving Objects
More informationCSE 331. Memento Pattern and Serialization
CSE 331 Memento Pattern and Serialization slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/ 1 Pattern: Memento a
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 UNIVERSIY SCHOOL O COMPUING CMPE212, ALL ERM, 2011 INAL EXAMINAION 15 December 2011, 2pm, Grant Hall Instructor: Alan McLeod HAND IN Answers Are Recorded on Question Paper SOLUION If the instructor
More informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor: Alan
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 informationPage 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
Page 1 of 16 SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2005 FINAL EXAMINATION 9am to 12noon, 19 DECEMBER 2005 Instructor: Alan McLeod
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 informationpackage As7BattleShip;
package As7BattleShip; Program: BattleshipBoard.java Author: Kevin Nider Date: 11/18/12 Description: Assignment 7: Runs the battleship game Input: ship placement board files and computer player type Output:
More informationObject-Oriented Software Engineering (Re-exam for Object-Oriented Analysis, Design and Programming)
Object-Oriented Software Engineering (Re-exam for Object-Oriented Analysis, Design and Programming) Medialogy, 4 th Semester, Aalborg Monday 11 June 2012, 09.00 12.00 Instructions You have 3 hours to complete
More informationกล ม API ท ใช. Programming Graphical User Interface (GUI) Containers and Components 22/05/60
กล ม API ท ใช Programming Graphical User Interface (GUI) AWT (Abstract Windowing Toolkit) และ Swing. AWT ม ต งต งแต JDK 1.0. ส วนมากจะเล กใช และแทนท โดยr Swing components. Swing API ปร บปร งความสามารถเพ
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 informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor:
More informationFirstSwingFrame.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 informationPage 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
Page 1 of 16 HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2005 FINAL EXAMINATION 9am to 12noon, 19 DECEMBER 2005 Instructor: Alan McLeod If
More informationEvents and Exceptions
Events and Exceptions Analysis and Design of Embedded Systems and OO* Object-oriented programming Jan Bendtsen Automation and Control Lecture Outline Exceptions Throwing and catching Exceptions creating
More informationDraft project proposal
Quiz 2 1/30 You can find your grade for Quiz 2 at https://www.cse.yorku.ca/~roumani/epost/server/ ep.cgi?year=2017-18&term=w&course=4315. You received an email with feedback at your EECS account. Draft
More informationChapter 10. File I/O. Copyright 2016 Pearson Inc. All rights reserved.
Chapter 10 File I/O Copyright 2016 Pearson Inc. All rights reserved. Streams A stream is an object that enables the flow of data between a program and some I/O device or file If the data flows into a program,
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 information/* Write a Program implementing GUI based Calculator using Swing */
/* Write a Program implementing GUI based Calculator using Swing */ import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.*; public class Calculator extends JFrame
More information// autor igre Ivan Programerska sekcija package mine;
// autor igre Ivan Bauk @ Programerska sekcija package mine; import java.awt.color; import java.awt.flowlayout; import java.awt.gridlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener;
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 informationAppBisect > PrBisect > class Functie. AppBisect > PrBisect > class Punct. public class Functie { double x(double t) { return t;
1 AppBisect > PrBisect > class Punct public class Punct { double x,y; public Punct(double x, double y) { this.x = x; this.y = y; public void setx(double x) { this.x = x; public double getx() { return x;
More informationSystems Programming. Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid
Systems Programming Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid Leganés, 21st of March, 2014. Duration: 75 min. Full
More informationLösningsförslag till exempeldugga
till exempeldugga 1 (6) Kursnamn Objektorienterade applikationer Program DAI 2 Examinator Uno Holmer Modellering Designmönster a) Decorator. b) public class Singleton { private static Singleton instance
More informationExample 3-1. Password Validation
Java Swing Controls 3-33 Example 3-1 Password Validation Start a new empty project in JCreator. Name the project PasswordProject. Add a blank Java file named Password. The idea of this project is to ask
More informationJAVA NOTES GRAPHICAL USER INTERFACES
1 JAVA NOTES GRAPHICAL USER INTERFACES Terry Marris 24 June 2001 5 TEXT AREAS 5.1 LEARNING OUTCOMES By the end of this lesson the student should be able to understand how to get multi-line input from the
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 informationJava JavaBeans JavaBeans Builder (vitsual) Java JavaBeans JavaBeans http://java.sun.com/j2se/1.3/ja/docs/ja/guide/beans/ http://java.sun.com/products/javabeans/software/bdk_download.html Beans Development
More information(Incomplete) History of GUIs
CMSC 433 Programming Language Technologies and Paradigms Spring 2004 Graphical User Interfaces April 20, 2004 (Incomplete) History of GUIs 1973: Xerox Alto 3-button mouse, bit-mapped display, windows 1981:
More informationObject-Oriented Software Engineering Re-exam, 2012 (Also Object-Oriented Analysis, Design and Programming, Re-exam, 2012)
Object-Oriented Software Engineering Re-exam, 2012 (Also Object-Oriented Analysis, Design and Programming, Re-exam, 2012) Medialogy, 4 th Semester, Aalborg Thursday 23 August 2012, 09.00 12.00 Instructions
More informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC124, WINTER TERM, 2009 FINAL EXAMINATION 7pm to 10pm, 18 APRIL 2009, Dunning Hall Instructor: Alan McLeod If the
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 informationFORMAS DE IMPLEMENTAR LOS OYENTES. A).- El oyente en una clase independiente con el constructor con un argumento y usando el método getactioncommand.
FORMAS DE IMPLEMENTAR LOS OYENTES A).- El oyente en una clase independiente con el constructor con un argumento y usando el método getactioncommand. public class VentanaOyente extends Frame{ private Oyente
More informationCOMP16121 Sample Code Lecture 1
COMP16121 Sample Code Lecture 1 Sean Bechhofer, University of Manchester, Manchester, UK sean.bechhofer@manchester.ac.uk 1 SimpleFrame 1 import javax.swing.jframe; 2 3 public class SimpleFrame { 4 5 /*
More information5/29/2006. Announcements. Last Time. Today. Text File I/O Sample Programs. The File Class. Without using FileReader. Reviewed method overloading.
Last Time Reviewed method overloading. A few useful Java classes: Other handy System class methods Wrapper classes String class StringTokenizer class Assn 3 posted. Announcements Final on June 14 or 15?
More informationClass Hierarchy II. Discussion E
Class Hierarchy II Discussion E Hierarchy A mail order business sells catalog merchandise all over the country. The rules for taxation on the merchandise vary from state to state. Also, the rate of taxation
More informationGUI 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 informationSE1021 Exam 2. When returning your exam, place your note-sheet on top. Page 1: This cover. Page 2 (Multiple choice): 10pts
SE1021 Exam 2 Name: You may use a note-sheet for this exam. But all answers should be your own, not from slides or text. Review all questions before you get started. The exam is printed single-sided. Write
More informationII 12, JFileChooser. , 2. SolidEllipse ( 2), PolyLine.java ( 3). Draw.java
II 12, 13 (ono@isnagoya-uacjp) 2007 1 15, 17 2 : 1 2, JFileChooser, 2,,, Draw 1, SolidEllipse ( 2), PolyLinejava ( 3) 1 Drawjava 2 import javaxswing*; 3 import javaawtevent*; import javautil*; 5 import
More informationCS 51 Laboratory # 12
CS 51 Laboratory # 12 Pictionary Objective: To gain experience with Streams. Networked Pictionary This week s assignment will give you the opportunity to practice working with Streams in the context of
More informationMultimedia Programming
Multimedia Programming Medialogy, 8 th Semester, Aalborg University Wednesday 6 June 2012, 09.00 12.00 Instructions and notes You have 3 hours to complete this examination. Neither written material nor
More informationLaborator 2 Aplicatii Java
Laborator 2 Aplicatii Java Introducere in programarea vizuala - Pachetul AWT Scrieti, compilati si rulati toate exemplele din acest laborator: 1. import java.awt.*; class First extends Frame First() Button
More informationCSCI 201L Midterm Written Summer % of course grade
CSCI 201L Summer 2016 10% of course grade 1. Abstract Classes and Interfaces Give two differences between an interface and an abstract class in which all of the methods are abstract. (0.5% + 0.5%) 2. Serialization
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 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 informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
Solution HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2007 FINAL EXAMINATION 7pm to 10pm, 10 DECEMBER 2007, Jeffery Hall Instructor: Alan McLeod
More informationGrouping objects. Main concepts to be covered
Grouping objects Collections and iterators 3.0 Main concepts to be covered Collections Loops Iterators Arrays Objects First with Java - A Practical Introduction using BlueJ, David J. Barnes, Michael Kölling
More information17 GUI API: Container 18 Hello world with a GUI 19 GUI API: JLabel 20 GUI API: Container: add() 21 Hello world with a GUI 22 GUI API: JFrame: setdefau
List of Slides 1 Title 2 Chapter 13: Graphical user interfaces 3 Chapter aims 4 Section 2: Example:Hello world with a GUI 5 Aim 6 Hello world with a GUI 7 Hello world with a GUI 8 Package: java.awt and
More informationInterfaces: Listeners and Adapters Java Programming 3 Lesson 6
Interfaces: Listeners and Adapters Java Programming 3 Lesson 6 Interfaces in Java In previous lessons, we discussed classes and subclasses, and the way inheritance works within them. Java allows only single
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 informationPrinciples, Models, and Applications for Distributed Systems M
Università degli Studi di Bologna Facoltà di Ingegneria Principles, Models, and Applications for Distributed Systems M Exercitation 3 Connected Java Sockets Jacopo De Benedetto Distributed architecture
More informationObject- Oriented Analysis, Design and Programming. Instructions. Medialogy, 4 th Semester, Aalborg. Tuesday 30 August 2011,
Object- Oriented Analysis, Design and Programming Medialogy, 4 th Semester, Aalborg Tuesday 30 August 2011, 10.00-13.00 Instructions You have 3 hours to complete this examination. Neither written material
More informationPrinciples, Models, and Applications for Distributed Systems M
Università degli Studi di Bologna Facoltà di Ingegneria Principles, Models, and Applications for Distributed Systems M Lab assignment 4 (worked-out) Connection-oriented Java Sockets Luca Foschini Winter
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 informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC124, WINTER TERM, 2009 FINAL EXAMINATION 7pm to 10pm, 18 APRIL 2009, Dunning Hall Instructor: Alan McLeod
More information10/10/2018 Programming Data Structures
10/10/2018 Programming Data Structures pair discussion: assignment 08 (up to 45 min) prior class session: read files and write to files more about File I/O in-class assignment AND take-home assignment
More informationProgrammierpraktikum
Programmierpraktikum Claudius Gros, SS2012 Institut für theoretische Physik Goethe-University Frankfurt a.m. 1 of 21 05/07/2012 10:31 AM Input / Output Streams 2 of 21 05/07/2012 10:31 AM Java I/O streams
More informationCS 180 Final Exam Review 12/(11, 12)/08
CS 180 Final Exam Review 12/(11, 12)/08 Announcements Final Exam Thursday, 18 th December, 10:20 am 12:20 pm in PHYS 112 Format 30 multiple choice questions 5 programming questions More stress on topics
More informationEclipsing Your IDE. Figure 1 The first Eclipse screen.
Eclipsing Your IDE James W. Cooper I have been hearing about the Eclipse project for some months, and decided I had to take some time to play around with it. Eclipse is a development project (www.eclipse.org)
More informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2008 FINAL EXAMINATION 7pm to 10pm, 17 DECEMBER 2008, Grant Hall Instructor: Alan McLeod
More informationGraphical User Interfaces in Java - SWING
Graphical User Interfaces in Java - SWING Graphical User Interfaces (GUI) Each graphical component that the user can see on the screen corresponds to an object of a class Component: Window Button Menu...
More informationIPM 12/13 P4 Handling Events in AWT
IPM 12/13 P4 Handling Events in AWT Licenciatura em Ciência de Computadores Miguel Tavares Coimbra Why Events? Components need a way to: Receive messages. Send messages. Examples: A TextField needs to
More informationString temp [] = {"a", "b", "c"}; where temp[] is String array.
SCJP 1.6 (CX-310-065, CX-310-066) Subject: String, I/O, Formatting, Regex, Serializable, Console Total Questions : 57 Prepared by : http://www.javacertifications.net SCJP 6.0: String,Files,IO,Date and
More informationJava Input/Output Streams
Java Input/Output Streams Rui Moreira Some useful links: http://java.sun.com/docs/books/tutorial/essential/toc.html#io Input Stream Output Stream Rui Moreira 2 1 JVM creates the streams n System.in (type
More informationCOMP200 GENERICS. OOP using Java, from slides by Shayan Javed
1 1 COMP200 GENERICS OOP using Java, from slides by Shayan Javed 2 ArrayList and Java Generics 3 Collection A container object that groups multiple objects 4 Collection A container object that groups multiple
More informationBasic Java IO Decorator pattern Advanced Java IO. Java IO - part 2 BIU OOP. BIU OOP Java IO - part 2
Java IO - part 2 BIU OOP Table of contents 1 Basic Java IO What do we know so far? What s next? 2 Example Overview General structure 3 Stream Decorators Serialization What do we know so far? What s next?
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 informationSimple Java I/O. Part I General Principles
Simple Java I/O Part I General Principles Streams All modern I/O is stream based A stream is a connec8on to a source of data or to a des8na8on for data (some8mes both) An input stream may be associated
More informationJAVA NOTES GRAPHICAL USER INTERFACES
1 JAVA NOTES GRAPHICAL USER INTERFACES Terry Marris July 2001 8 DROP-DOWN LISTS 8.1 LEARNING OUTCOMES By the end of this lesson the student should be able to understand and use JLists understand and use
More informationFile Input and Output Recitation 04/03/2009. CS 180 Department of Computer Science, Purdue University
File Input and Output Recitation 04/03/2009 CS 180 Department of Computer Science, Purdue University Announcements Project 7 is out Fun project! With animation! Start early Exam grade has been released
More informationAPPENDIX. public void cekroot() { System.out.println("nilai root : "+root.data); }
APPENDIX CLASS NODE AS TREE OBJECT public class Node public int data; public Node left; public Node right; public Node parent; public Node(int i) data=i; PROCEDURE BUILDING TREE public class Tree public
More informationExample: Building a Java GUI
Steven Zeil October 25, 2013 Contents 1 Develop the Model 2 2 Develop the layout of those elements 3 3 Add listeners to the elements 9 4 Implement custom drawing 12 1 The StringArt Program To illustrate
More informationActive Source Routing Protocol for Mobile Network:
www.ijecs.in International Journal Of Engineering And Computer Science ISSN:2319-7242 Volume 2 Issue 4 April, 2013 Page No. 1394-1425 Active Source Routing Protocol for Mobile Network: Anil Kumar Prasad,
More informationThe Islamic University Gaza Department of Electrical & Computer Engineering. Midterm Exam Spring 2012 Computer Programming II (Java) ECOM 2324
The Islamic University Gaza Department of Electrical & Computer Engineering Midterm Exam Spring 2012 Computer Programming II (Java) ECOM 2324 Instructor: Dipl.-Ing. Abdelnasser Abdelhadi Date: 31.03.2013
More informationExample: Building a Java GUI
Steven Zeil October 25, 2013 Contents 1 Develop the Model 3 2 Develop the layout of those elements 4 3 Add listeners to the elements 12 4 Implement custom drawing 15 1 The StringArt Program To illustrate
More informationChapter 17 Binary I/O. Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
Chapter 17 Binary I/O 1 Motivations Data stored in a text file is represented in human-readable form. Data stored in a binary file is represented in binary form. You cannot read binary files. They are
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 informationCS180 Review. Recitation Week 15
CS180 Review Recitation Week 15 Announcement Final exam will be held on Thursday(12/17) 8:00~10:00 AM The coverage is comprehensive Project 5 is graded. Check your score in Blackboard. Classes and Methods
More informationI VE GOT A LITTLE LIST
1 I VE GOT A LITTLE LIST James W. Cooper As someday it may happen that a sorted list must be found, Java s got the list. I was thinking about the problem of sorted terms in a list box when I was writing
More information