public class demo1swing extends JFrame implements ActionListener{

Size: px
Start display at page:

Download "public class demo1swing extends JFrame implements ActionListener{"

Transcription

1 import java.io.*; import java.net.*; import java.io.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class demo1swing extends JFrame implements ActionListener JButton demodulacion; JButton cerrar; JTextField frecuenciatextf; String programa; Process proceso=null; BufferedWriter stdoutput=null; public static void main(string args[]) float fc, coeff; demo1swing mod = new demo1swing(); mod.ventanafrecuencia(); private void ventanafrecuencia() JFrame frame = new JFrame("Demodulador de AM "); Container c = frame.getcontentpane(); JLabel frecuencialabel = new JLabel("Introduzca la frecuencia de la portadora en Hz: "); frecuenciatextf = new JTextField(" "); demodulacion = new JButton("Demodular"); demodulacion.setactioncommand("demodulacion"); demodulacion.addactionlistener(this); cerrar = new JButton("Cerrar Ventana"); cerrar.setactioncommand("cerrar"); cerrar.addactionlistener(this); c.setlayout(new GridLayout(2,2)); c.add(frecuencialabel); c.add(frecuenciatextf); c.add(demodulacion); c.add(cerrar); //frame.pack(); frame.setsize(450,130); frame.setvisible(true); private void showinfodialog( String dialogo) JOptionPane.showMessageDialog(new JFrame(), dialogo); public void actionperformed( ActionEvent e )

2 String eventostr = e.getactioncommand(); if (eventostr.equals("demodulacion")) if (!(frecuenciatextf.gettext()).equals("")) float f=(new Float(frecuenciaTextF.getText())).floatValue(); selecciona(f); else showinfodialog("no se ha introducido ninguna frecuencia"); if (eventostr.equals("cerrar")) if(proceso!=null) try "Esc" en octal stdoutput.write("\033"); // Diagonal invertida: \033 = stdoutput.flush(); proceso.destroy(); System.out.println(proceso.exitValue()); proceso=null; catch(exception i) i.printstacktrace(); private void selecciona(float fc) BufferedReader br=null; FileInputStream in=null; PrintStream misalida=null; FileOutputStream fout=null; String s=null; int n=15;

3 int contador=1; if(fc <= && fc >= ) programa=("start dsk5l demo5"); else if(fc <= && fc >= ) programa=("start dsk5l demo51"); else if(fc <= && fc >= ) programa=("start dsk5l demo52"); else if(fc <= && fc >= ) programa=("start dsk5l demo53"); else if(fc <= && fc >= ) programa=("start dsk5l demo54"); else if(fc <= && fc >= ) programa=("start dsk5l demo55"); else if(fc <= && fc >= ) programa=("start dsk5l demo56"); else if(fc <= && fc >= ) programa=("start dsk5l demo57"); else if(fc <= && fc >= ) programa=("start dsk5l demo58"); else if(fc <= && fc >= ) programa=("start dsk5l demo59"); //programa mayor que 6 y menor que 7kHz else if(fc <= && fc >= )

4 programa=("start dsk5l demo6"); else if(fc <= && fc >= ) programa=("start dsk5l demo61"); else if(fc <= && fc >= ) programa=("start dsk5l demo62"); else if(fc <= && fc >= ) programa=("start dsk5l demo63"); else if(fc <= && fc >= ) programa=("start dsk5l demo64"); else if(fc <= && fc >= ) programa=("start dsk5l demo65"); else if(fc <= && fc >= ) programa=("start dsk5l demo66"); else if(fc <= && fc >= ) programa=("start dsk5l demo67"); else if(fc <= && fc >= ) programa=("start dsk5l demo68"); else if(fc <= && fc >= ) programa=("start dsk5l demo69"); //programa mayor que 7 y menor que 8kHz else if(fc <= && fc >= ) programa=("start dsk5l demo7"); else if(fc <= && fc >= )

5 programa=("start dsk5l demo71"); else if(fc <= && fc >= ) programa=("start dsk5l demo72"); else if(fc <= && fc >= ) programa=("start dsk5l demo73"); else if(fc <= && fc >= ) programa=("start dsk5l demo74"); else if(fc <= && fc >= ) programa=("start dsk5l demo75"); else if(fc <= && fc >= ) programa=("start dsk5l demo76"); else if(fc <= && fc >= ) programa=("start dsk5l demo77"); else if(fc <= && fc >= ) programa=("start dsk5l demo78"); else if(fc <= && fc >= ) programa=("start dsk5l demo79"); else if(fc <= && fc >= ) programa=("start dsk5l demo8"); try proceso = Runtime.getRuntime().exec(programa); stdoutput = new BufferedWriter (new OutputStreamWriter(proceso.getOutputStream()));

6 BufferedReader stdinput = new BufferedReader(new InputStreamReader(proceso.getInputStream())); BufferedReader stderror = new BufferedReader(new InputStreamReader(proceso.getErrorStream())); //read the output from the command while((s=stdinput.readline())!=null && (contador <= n)) System.out.println(s); contador=(contador+1); //Al terminar de imprimir la salida, regresa a habilitar la ventana de diálogo // read any errors from the attempted command // Deshabilitando esta parte del programa, se habilita nuevamente la ventana de diálogo /* while((s = stderror.readline())!= null) System.out.println(s); */ //cierra try catch (IOException e) System.out.println("Error al ejecutar el comando en MS-DOS para correr el programa"); e.printstacktrace(); System.exit(-1); //Cierra selecciona

Advanced Network Programming Lab using Java. Angelos Stavrou

Advanced Network Programming Lab using Java. Angelos Stavrou Advanced Network Programming Lab using Java Angelos Stavrou Table of Contents A simple Java Client...3 A simple Java Server...4 An advanced Java Client...5 An advanced Java Server...8 A Multi-threaded

More information

L4j1 - Event Handling in Java. Event-based Programming

L4j1 - Event Handling in Java. Event-based Programming L4j1 - Event Handling in Java 1 12.1 Introduction 12.3 JLabel 12.4 Event Handling Model 12.6 JButton 12.5.1 How Event Handling Works Event-based Programming 2 Main assumption: A widget can get an event

More information

INTRODUCTION TO COMPUTER PROGRAMMING. Richard Pierse. Class 7: Object-Oriented Programming. Introduction

INTRODUCTION TO COMPUTER PROGRAMMING. Richard Pierse. Class 7: Object-Oriented Programming. Introduction INTRODUCTION TO COMPUTER PROGRAMMING Richard Pierse Class 7: Object-Oriented Programming Introduction One of the key issues in programming is the reusability of code. Suppose that you have written a program

More information

CS 335 Lecture 06 Java Programming GUI and Swing

CS 335 Lecture 06 Java Programming GUI and Swing CS 335 Lecture 06 Java Programming GUI and Swing Java: Basic GUI Components Swing component overview Event handling Inner classes and anonymous inner classes Examples and various components Layouts Panels

More information

// Correntista. //Conta Corrente. package Banco; public class Correntista { String nome, sobrenome; int cpf;

// Correntista. //Conta Corrente. package Banco; public class Correntista { String nome, sobrenome; int cpf; // Correntista public class Correntista { String nome, sobrenome; int cpf; public Correntista(){ nome = "zé"; sobrenome = "Pereira"; cpf = 123456; public void setnome(string n){ nome = n; public void setsobrenome(string

More information

Homework/Program #5 Solutions

Homework/Program #5 Solutions Homework/Program #5 Solutions Problem #1 (20 points) Using the standard Java Scanner class. Look at http://natch3z.blogspot.com/2008/11/read-text-file-using-javautilscanner.html as an exampleof using the

More information

CS 335 Java Programming GUI and Swing

CS 335 Java Programming GUI and Swing CS 335 Java Programming GUI and Swing Java: Basic GUI Components Swing component overview Event handling Inner classes and anonymous inner classes Examples and various components Layouts Panels Alternatives

More information

Software Development (cs2500)

Software Development (cs2500) Software Development (cs2500) Lecture 37: Event Handlers M.R.C. van Dongen January 24, 2011 Contents 1 Outline 1 2 The Observer Pattern 1 2.1 Case Study.................................................

More information

5.17 GUI. Xiaoyi Jiang Informatik I Grundlagen der Programmierung

5.17 GUI. Xiaoyi Jiang Informatik I Grundlagen der Programmierung AWT vs. Swing AWT (Abstract Window Toolkit; Package java.awt) Benutzt Steuerelemente des darunterliegenden Betriebssystems Native Code (direkt für die Maschine geschrieben, keine VM); schnell Aussehen

More information

Events, Listeners and Actions. Agenda GUI 8/14/2008. Review. Events. Listeners. Actions

Events, Listeners and Actions. Agenda GUI 8/14/2008. Review. Events. Listeners. Actions Events, Listeners and Actions 2 4 pm Tuesday 8/14/2008 @JD2211 1 Agenda Review GUI Components, Layout and Appearance Events Listeners Actions 2 GUI In the 1980s, the transition from terminalbased interface

More information

Tema: Encriptación por Transposición

Tema: Encriptación por Transposición import java.awt.*; import java.awt.event.*; import javax.swing.*; public class PrincipalSO extends JApplet implements ActionListener { // Declaración global JLabel lblclave, lblencriptar, lblencriptado,

More information

Informatik II. // ActionListener hinzufügen btnconvert.addactionlistener(this); super.setdefaultcloseoperation(jframe.

Informatik II. // ActionListener hinzufügen btnconvert.addactionlistener(this); super.setdefaultcloseoperation(jframe. Universität Augsburg, Institut für Informatik Sommersemester 2006 Prof. Dr. Werner Kießling 20. Juli. 2006 M. Endres, A. Huhn, T. Preisinger Lösungsblatt 11 Aufgabe 1: Währungsrechner CurrencyConverter.java

More information

Math methods. Lecture Seven Math methods. GUI review Interest Calculator. Read Chapter 5, pg. 115

Math methods. Lecture Seven Math methods. GUI review Interest Calculator. Read Chapter 5, pg. 115 Lecture Seven Math methods GUI review Interest Calculator Math methods Math comparisons Math constants Formatting numbers Roll Dice program Random numbers Rounding numbers Casting Drill Read Chapter 5,

More information

Listeners, sources, and events

Listeners, sources, and events Event driven programming Listeners, sources, and events GUI programming Asynchronous programing / event-based programming Events Keyboard Mouse Must respond to events in arbitrary order Simplistic approach:

More information

Apéndice C: Código Fuente del Programa DBConnection.java

Apéndice C: Código Fuente del Programa DBConnection.java Apéndice C: Código Fuente del Programa DBConnection.java import java.sql.*; import java.io.*; import java.*; import java.util.*; import java.net.*; public class DBConnection Connection pgsqlconn = null;

More information

CISC 213- Practice Test 2

CISC 213- Practice Test 2 CISC 213- Practice Test 2 Part A- The following questions are multiple choice or short answer: 1. Say we define a class called ABC and we don't define any constructor. Then which of the following is true:

More information

1.00 Lecture 17. Swing

1.00 Lecture 17. Swing 1.00 Lecture 17 Introduction to Swing Reading for next time: Big Java: sections 12.1-12.6 Swing Package of user interface classes for windows, menus, scroll bars, buttons, etc. Independent of hardware

More information

Supplement: Text IO Using Reader and Writer. For Introduction to Java Programming By Y. Daniel Liang

Supplement: Text IO Using Reader and Writer. For Introduction to Java Programming By Y. Daniel Liang 0 Introduction Supplement: Text IO Using Reader and Writer For Introduction to Java Programming By Y. Daniel Liang The text introduced text I/O using the Scanner class and PrintWriter class, which greatly

More information

GUI Event Driven Programming

GUI Event Driven Programming GUI Event Driven Programming When programming for a Graphics User Interface (GUI), the designer must take into account the wide variety of possible interactions with the user. In old style programming,

More information

Chulalongkorn University International School of Engineering Department of Computer Engineering 2140105 Computer Programming Lab.

Chulalongkorn University International School of Engineering Department of Computer Engineering 2140105 Computer Programming Lab. Chulalongkorn University Name International School of Engineering Student ID Department of Computer Engineering Station No. 2140105 Computer Programming Lab. Date Lab 2 Using Java API documents, command

More information

Bit Manipulation and the Bitwise Operators

Bit Manipulation and the Bitwise Operators ecture 20 slide 1 Bit Manipulation and the Bitwise Operators Bitwise operators Used for bit manipulation Used for getting down to bit-and-bytes level ecture 20 Bit Manipulation and the Bitwise Operators

More information

HBV201G Viðmótsforritun

HBV201G Viðmótsforritun HBV201G Viðmótsforritun Forritunarverkefni 4 Ágiskunarleikur eða RPN reiknivél (Java Swing) 5. mars 2012 Nemandi: Dæmakennari: Sveinn Flóki Guðmundsson Elvar Helgason 1 of 5 GuessGame.java import java.awt.*;

More information

public class Craps extends JFrame implements ActionListener { final int WON = 0,LOST =1, CONTINUE = 2;

public class Craps extends JFrame implements ActionListener { final int WON = 0,LOST =1, CONTINUE = 2; Lecture 15 The Game of "Craps" In the game of "craps" a player throws a pair of dice. If the sum on the faces of the pair of dice after the first toss is 7 or 11 the player wins; if the sum on the first

More information

Programming with Java GUI components

Programming with Java GUI components Programming with Java GUI components Java includes libraries to provide multi-platform support for Graphic User Interface objects. The multi-platform aspect of this is that you can write a program on a

More information

!"# $ %!&' # &! ())*!$

!# $ %!&' # &! ())*!$ !"# $ %!&' # &! ())*!$ !" #!$ %& ' ( ) * +,--!&"" $.!! /+010!" +!, 31! 4)&/0! $ #"5!! & + 6+ " 5 0 7 /&8-9%& ( +" 5)& /*#.! &( $ 1(" 5 # ( 8 +1 + # + 7$ (+!98 +&%& ( +!" (!+!/ (!-. 5 7 (! 7 1+1( & + ":!

More information

Managing Input Events in Swing

Managing Input Events in Swing Managing Input Events in Swing Week 5 Workshop 8.02.2008 Lyn Bartram Today Introduction Java s event delegation model event sources and event listeners Event classes Examples Window events Adding simple

More information

Michele Van Dyne MUS 204B https://katie.mtech.edu/classes/csci136. Graphics / Event Handling

Michele Van Dyne MUS 204B https://katie.mtech.edu/classes/csci136. Graphics / Event Handling Michele Van Dyne MUS 204B mvandyne@mtech.edu https://katie.mtech.edu/classes/csci136 Graphics / Event Handling Command line versus GUI apps Java GUI applications JFrame Layout managers Popular widgets

More information

Introduction to the Java Programming Language

Introduction to the Java Programming Language Software Design Introduction to the Java Programming Language Material drawn from [JDK99,Sun96,Mitchell99,Mancoridis00] Java Features Write Once, Run Anywhere. Portability is possible because of Java virtual

More information

1.00 Lecture 23. Streams

1.00 Lecture 23. Streams 1.00 Lecture 23 Input/Output Introduction to Streams Exceptions Reading for next time: Big Java 19.3-19.4 Streams Java can communicate with the outside world using streams Picture a pipe feeding data into

More information

Chapter Four: DFA Applications. Formal Language, chapter 4, slide 1

Chapter Four: DFA Applications. Formal Language, chapter 4, slide 1 Chapter Four: DFA Applications Formal Language, chapter 4, slide 1 1 We have seen how DFAs can be used to define formal languages. In addition to this formal use, DFAs have practical applications. DFAbased

More information

Topics. Swing Event. ActionListener. Component gets the keyboard focus

Topics. Swing Event. ActionListener. Component gets the keyboard focus Tutorial 6 Topics Event handling in Swing o Swing events o Event listeners o Register an event handler to an object o Implement the event-handling SwingApplication o GUI o Event handling o Multiple events

More information

Laborator 5 Java. Elemente de programare vizuala AWT (Abstract Window Toolkit) Scrieti, compilati si rulati toate exemplele din acest laborator:

Laborator 5 Java. Elemente de programare vizuala AWT (Abstract Window Toolkit) Scrieti, compilati si rulati toate exemplele din acest laborator: Laborator 5 Java Elemente de programare vizuala AWT (Abstract Window Toolkit) Scrieti, compilati si rulati toate exemplele din acest laborator: 1. class First extends Frame First() Button b=new Button("click

More information

Object Oriented Programming and Design in Java. Session 6 Instructor: Bert Huang

Object Oriented Programming and Design in Java. Session 6 Instructor: Bert Huang Object Oriented Programming and Design in Java Session 6 Instructor: Bert Huang Announcements Homework 1 due Wednesday Feb. 17 th 11 AM Lauren's office hours moved to 8:30-10:30 PM (just this week) For

More information

Internet Technology. 02r. Programming with Sockets Paul Krzyzanowski. Rutgers University. Spring 2013

Internet Technology. 02r. Programming with Sockets Paul Krzyzanowski. Rutgers University. Spring 2013 Internet Technology 02r. Programming with Sockets Paul Krzyzanowski Rutgers University Spring 2013 February 7, 2013 2013 Paul Krzyzanowski 1 Sample Client-Server Program To illustrate programming with

More information

Groovy SwingBuilder and Threading. Griffon in Action EARLY ACCESS EDITION

Groovy SwingBuilder and Threading. Griffon in Action EARLY ACCESS EDITION Groovy SwingBuilder and Threading Excerpted from Griffon in Action EARLY ACCESS EDITION Andres Almiray and Danno Ferrin MEAP Began: March 2009 Softbound print: Summer 2010 375 pages ISBN: 9781935182238

More information

Threads - Chapter 13. Concurrent Programming Needs. The Implicit AWT Thread

Threads - Chapter 13. Concurrent Programming Needs. The Implicit AWT Thread Threads - Chapter 13 Threads allow a program to "do more than one thing at a time." If the hardware has multiple processing units, then this can result in faster execution of a program. In distributed

More information

Supplement: Case Study: AddressBook. For Introduction to Java Programming By Y. Daniel Liang

Supplement: Case Study: AddressBook. For Introduction to Java Programming By Y. Daniel Liang Supplement: Case Study: AddressBook For Introduction to Java Programming By Y. Daniel Liang This case study can be presented after Chapter 19, Binary I/O. Now let us use RandomAccessFile to create a useful

More information

Graphical User Interfaces

Graphical User Interfaces M14_REGE1813_02_SE_C14.qxd 2/10/10 3:43 PM Page 822 Chapter14 Graphical User Interfaces 14.1 GUI Basics Graphical Input and Output with Option Panes Working with Frames Buttons, Text Fields, and Labels

More information

Introduction to Java. Module 12: Networking (Java Sockets) Prepared by Costantinos Costa for EPL 233. ΕΠΛ233 Αντικειμενοστρεφής Προγραμματισμός 1

Introduction to Java. Module 12: Networking (Java Sockets) Prepared by Costantinos Costa for EPL 233. ΕΠΛ233 Αντικειμενοστρεφής Προγραμματισμός 1 Introduction to Java Module 12: Networking (Java Sockets) Prepared by Costantinos Costa for EPL 233 ΕΠΛ233 Αντικειμενοστρεφής Προγραμματισμός 1 What Is a Socket? A socket is one end-point of a two-way

More information

Java, Swing, and Eclipse: The Calculator Lab.

Java, Swing, and Eclipse: The Calculator Lab. Java, Swing, and Eclipse: The Calculator Lab. ENGI 5895, Winter 2010 January 14, 2010 1 A very simple application This was prepared with Eclipse 3.4 as the development environment. Recommendation. Access

More information

University of Cape Town Department of Computer Science. Computer Science CSC117F

University of Cape Town Department of Computer Science. Computer Science CSC117F University of Cape Town Department of Computer Science Computer Science CSC117F Class Test 4 Wednesday 18 May 2005 Marks: 35 Approximate marks per question are shown in brackets Time: 40 minutes The use

More information

WRITING CLASSES ( CHAPTER 4)

WRITING CLASSES ( CHAPTER 4) WRITING CLASSES ( CHAPTER 4) Three fundemental concepts of object-oriented programming : - encapsulation - inheritance - polymorphism students attributes name major address DOB GPA operations(methods)

More information

CSE 8B Intro to CS: Java

CSE 8B Intro to CS: Java CSE 8B Intro to CS: Java Winter, 2006 Review of Swing Components are visible objects in the GUI Example: JButton, JLabel Containers are areas where the components can be placed Containers are in a hierarchy

More information

www.virtualians.pk CS506 Web Design and Development Solved Online Quiz No. 01 www.virtualians.pk

www.virtualians.pk CS506 Web Design and Development Solved Online Quiz No. 01 www.virtualians.pk CS506 Web Design and Development Solved Online Quiz No. 01 Which of the following is a general purpose container? JFrame Dialog JPanel JApplet Which of the following package needs to be import while handling

More information

Using A Frame for Output

Using A Frame for Output Eventos Roteiro Frames Formatting Output Event Handling Entering Data Using Fields in a Frame Creating a Data Entry Field Using a Field Reading Data in an Event Handler Handling Multiple Button Events

More information

DHBW Karlsruhe, Vorlesung Programmieren, Remote Musterlösungen

DHBW Karlsruhe, Vorlesung Programmieren, Remote Musterlösungen DHBW Karlsruhe, Vorlesung Programmieren, Remote Musterlösungen Aufgabe 1 RMI - TimeService public interface TimeServerInterface extends Remote { public String gettime() throws RemoteException; import java.util.date;

More information

NOTES: Working with Graphical User Interfaces

NOTES: Working with Graphical User Interfaces NOTES: Working with Graphical User Interfaces A JLabel Object A JTextField Object A JButton Object A GUI in Java has at least three kinds of objects: components an object that defines a screen element

More information

Java Appletek II. Applet GUI

Java Appletek II. Applet GUI THE INTERNET,mapped on the opposite page, is a scalefree network in that Java Appletek II. dis.'~tj port,from BYALBERTU\SZLOBARABASI ANDERICBONABEAU THE INTERNET,mapped on the opposite page, is a scalefree

More information

CS360 Lecture 9 Exception Handling

CS360 Lecture 9 Exception Handling CS360 Lecture 9 Exception Handling Tuesday, March 2, 2004 Reading Nested Classes: Section 10.9 Exception Handling: Chapter 15 Nested Classes Java allows classes to be declared inside of other classes.

More information

Essentials of the Java(TM) Programming Language, Part 1

Essentials of the Java(TM) Programming Language, Part 1 Essentials of the Java(TM) Programming Language, Part 1 http://developer.java.sun.com/developer...ining/programming/basicjava1/index.html Training Index Essentials of the Java TM Programming Language:

More information

file://c:\dokumente und Einstellungen\Marco Favorito\Desktop\ScanCmds.html

file://c:\dokumente und Einstellungen\Marco Favorito\Desktop\ScanCmds.html file:c:\dokumente und Einstellungen\Marco Favorito\Desktop\ScanCmds.html Seite 1 von 5 ScanCmds.java ------------------------------------------------------------------------------- ScanCmds Demontration

More information

JFC / Swing. JFC - Java Foundation Classes. JFC Components. The Java GUI toolkit (Reading: The Sun JFC/Swing Tutorial -- see WWW page)

JFC / Swing. JFC - Java Foundation Classes. JFC Components. The Java GUI toolkit (Reading: The Sun JFC/Swing Tutorial -- see WWW page) JFC / Swing The Java GUI toolkit (Reading: The Sun JFC/Swing Tutorial -- see WWW page) JFC - Java Foundation Classes JFC is a GUI toolkit. It is the successor of AWT, which is the foundation of JFC (usually

More information

Topic Java Class. Library INTRODUCTION LEARNING OUTCOMES. By the end of this topic, you should be able to:

Topic Java Class. Library INTRODUCTION LEARNING OUTCOMES. By the end of this topic, you should be able to: Topic Java Class Library 8 LEARNING OUTCOMES By the end of this topic, you should be able to: 1. Describe the meaning of package in Java; 2. Describe the purpose of keyword import; 3. Describe of how classes

More information

http://netbeans.org/kb/docs/java/gui-functionality.html?print=yes

http://netbeans.org/kb/docs/java/gui-functionality.html?print=yes Page 1 of 6 Introduction to GUI Building Contributed by Saleem Gul and Tomas Pavek, maintained by Ruth Kusterer and Irina Filippova This beginner tutorial teaches you how to create a simple graphical user

More information

INPUT AND OUTPUT STREAMS

INPUT AND OUTPUT STREAMS INPUT AND OUTPUT The Java Platform supports different kinds of information sources and information sinks. A program may get data from an information source which may be a file on disk, a network connection,

More information

CSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus

CSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus CSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus 1. Purpose This assignment exercises how to write a peer-to-peer communicating program using non-blocking

More information

COMP 303 SWING Tutorial (For a GUI in Java)

COMP 303 SWING Tutorial (For a GUI in Java) COMP 303 SWING Tutorial (For a GUI in Java) Sokhom Pheng McGill University January 22, 2004 More info can be found on the java.sun website: http://java.sun.com/docs/books/tutorial/uiswing/index.html Important

More information

COMPSCI 125 Practice Final Exam (Summer 2012)

COMPSCI 125 Practice Final Exam (Summer 2012) COMPSCI 125 Practice Final Exam (Summer 2012) Time: 120 minutes Name : email address (for grade) : This exam has 13 questions, for a total of 200 points. Question Points Score 1 35 2 15 3 10 4 20 5 10

More information

1.00 Tutorial 7. Swing I

1.00 Tutorial 7. Swing I 1.00 Tutorial 7 Swing I Agenda Swing Components Event Handling (download Tutorial7.java and Tutorial7Inner.java) By implementing ActionListner Interface (Example 3) Using Anonymous Inner Class (Example

More information

Division of Informatics, University of Edinburgh

Division of Informatics, University of Edinburgh CS1Bh Lecture Note 20 Client/server computing A modern computing environment consists of not just one computer, but several. When designing such an arrangement of computers it might at first seem that

More information

Interface Based Programming! Venkat Subramaniam

Interface Based Programming! Venkat Subramaniam Interface Based Programming! Venkat Subramaniam venkats@durasoftcorp.com http://www.durasoftcorp.com When I ask people why they want to use the object paradigm, invariably one of the top answers is Reusability.

More information

Schueler-Organisiertes Lernen am Beispiel von Grafischen Benutzer-Schnittstellen in Java Tag der Offenen Tür - GTS 2008

Schueler-Organisiertes Lernen am Beispiel von Grafischen Benutzer-Schnittstellen in Java Tag der Offenen Tür - GTS 2008 Schueler-Organisiertes Lernen am Beispiel von Grafischen Benutzer-Schnittstellen in Java Tag der Offenen Tür - GTS 2008 http://worgtsone.scienceontheweb.net/worgtsone/ - mailto: worgtsone @ hush.com Sa

More information

Java I/O and Exceptions

Java I/O and Exceptions Java I/O and Exceptions CS1316: Representing Structure and Behavior Writing to a Text File We have to create a stream that allows us access to a file. We re going to want to write strings to it. We re

More information

Chapter 11. Graphical User Interfaces

Chapter 11. Graphical User Interfaces Chapter 11. Graphical User Interfaces To this point in the text, our programs have interacted with their users to two ways: The programs in Chapters 1-5, implemented in Processing, displayed graphical

More information

CIS 212: Object oriented programming Notes and Program Listings-Part 8 Adding Action Listeners

CIS 212: Object oriented programming Notes and Program Listings-Part 8 Adding Action Listeners CIS 212: Object oriented programming Notes and Program Listings-Part 8 Adding Action Listeners C. Cooper, MCS, Goldsmiths c Version 1 1 Topics Making a button Capturing an event (Read Eckel 707-710) Model-View-Controller

More information

Lösningsförslag till tentamen 121217

Lösningsförslag till tentamen 121217 Uppgift 1 Lösningsförslag till tentamen 121217 a) Utskriften blir: a = 5 och b = 10 a = 5 och b = 10 b) Utskriften blir 1 2 3 4 5 5 2 3 4 1 c) Utskriften blir 321 Uppgift 2 Med användning av dialogrutor:

More information

Extending Desktop Applications to the Web

Extending Desktop Applications to the Web Extending Desktop Applications to the Web Arno Puder San Francisco State University Computer Science Department 1600 Holloway Avenue San Francisco, CA 94132 arno@sfsu.edu Abstract. Web applications have

More information

Programming Languages 2nd edition Tucker and Noonan

Programming Languages 2nd edition Tucker and Noonan Programming Languages 2nd edition Tucker and Noonan Chapter 16 Event-Driven Programming Of all men s miseries the bitterest is this, to know so much and to have control over nothing. Herodotus (484-432

More information

Option Panes CSCI 201 Principles of Software Development

Option Panes CSCI 201 Principles of Software Development Option Panes CSCI 201 Principles of Software Development Jeffrey Miller, Ph.D. jeffrey.miller@usc.edu Outline Program USC CSCI 201L Option Panes Option panes are popup dialog boxes There are four types

More information

Fondamenti di Java. Introduzione alla costruzione di GUI (graphic user interface)

Fondamenti di Java. Introduzione alla costruzione di GUI (graphic user interface) Fondamenti di Java Introduzione alla costruzione di GUI (graphic user interface) component - container - layout Un Container contiene [0 o +] Components Il Layout specifica come i Components sono disposti

More information

import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.*; import javax.swing.jfilechooser.

import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.*; import javax.swing.jfilechooser. /* */ Date: 03/01/13 Purpose: Demonstrate GUI and Event Handling Input: GUI user input numeric values Output: GUI Resulting calculations Author: Crosby, David Class: CS 1302A Program: TestMyOwnCalculator.java

More information

Lesson: All About Sockets

Lesson: All About Sockets All About Sockets http://java.sun.com/docs/books/tutorial/networking/sockets/index.html Page 1 sur 1 The Java TM Tutorial Start of Tutorial > Start of Trail Trail: Custom Networking Lesson: All About Sockets

More information

FILE I/O IN JAVA. Prof. Chris Jermaine cmj4@cs.rice.edu. Prof. Scott Rixner rixner@cs.rice.edu

FILE I/O IN JAVA. Prof. Chris Jermaine cmj4@cs.rice.edu. Prof. Scott Rixner rixner@cs.rice.edu FILE I/O IN JAVA Prof. Chris Jermaine cmj4@cs.rice.edu Prof. Scott Rixner rixner@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

More information

TemperatureServer interface.

TemperatureServer interface. CHAPTER 20 REMOTE METHOD INVOCATION (RMI) 983 1 // Fig. 20.1: TemperatureServer.java 2 // TemperatureServer interface definition 3 import java.rmi.*; 4 5 public interface TemperatureServer extends Remote

More information

Altas, Bajas y Modificaciones de Registros en tabla MYSQL

Altas, Bajas y Modificaciones de Registros en tabla MYSQL Altas, Bajas y Modificaciones de Registros en tabla MYSQL 1. En MySql crear una base de datos de nombre EmpresaABC y dentro de ella la tabla Empleados con la siguiente estructura: DNI integer(8) Definir

More information

WRITING DATA TO A BINARY FILE

WRITING DATA TO A BINARY FILE WRITING DATA TO A BINARY FILE TEXT FILES VS. BINARY FILES Up to now, we have looked at how to write and read characters to and from a text file. Text files are files that contain sequences of characters.

More information

Chapter 2 Introduction to Java programming

Chapter 2 Introduction to Java programming Chapter 2 Introduction to Java programming 1 Keywords boolean if interface class true char else package volatile false byte final switch while throws float private case return native void protected break

More information

On event-driven programming. Java GUI programming. On event-driven programming (cont.) AWT vs. Swing

On event-driven programming. Java GUI programming. On event-driven programming (cont.) AWT vs. Swing On event-driven programming Java GUI programming a user interface combines three functions: input, output, and data handling in batch-oriented processing the control of execution is within the program

More information

CPSC 324 Topics in Java Programming

CPSC 324 Topics in Java Programming CPSC 324 Topics in Java Programming Lecture 13 Today Quiz 5 Inner classes Exercise 7 Lab 4 Readings: Ch. 6 pages 269-271 CPSC 324 Spring 2010 2 1 Panel with two buttons public class MyPanel extends JPanel

More information

TP1 : Correction. Rappels : Stream, Thread et Socket TCP

TP1 : Correction. Rappels : Stream, Thread et Socket TCP Université Paris 7 M1 II Protocoles réseaux TP1 : Correction Rappels : Stream, Thread et Socket TCP Tous les programmes seront écrits en Java. 1. (a) Ecrire une application qui lit des chaines au clavier

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. Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) can generate mouse events. (choose all that apply) A) JButton B) JLabel C) JPanel D)

More information

Object-oriented programming using JAVA Winter 2005 Final Examination Duration: 3 hours

Object-oriented programming using JAVA Winter 2005 Final Examination Duration: 3 hours School of Computer Science 0360-212 Object-oriented programming using JAVA Winter 2005 Final Examination Duration: 3 hours Student information Last name First name Student ID# Lab section University regulations:

More information

ExempleRMI.java. // Fichier de defintion des droits et proprietes // System.setProperty("java.security.policy","../server.java.

ExempleRMI.java. // Fichier de defintion des droits et proprietes // System.setProperty(java.security.policy,../server.java. ExempleRMI.java import java.lang.*; import java.rmi.registry.*; import java.rmi.server.*; import java.io.*; import java.util.*; ExempleRMI.java import pkgexemple.*; public class ExempleRMI public static

More information

Final Project Report E3390 Electronic Circuit Design Lab. Electronic Notepad

Final Project Report E3390 Electronic Circuit Design Lab. Electronic Notepad Final Project Report E3390 Electronic Circuit Design Lab Electronic Notepad Keith Dronson Sam Subbarao Submitted in partial fulfillment of the requirements for the Bachelor of Science Degree May 10, 2008

More information

The Java I/O System. Binary I/O streams (ascii, 8 bits) The decorator design pattern Character I/O streams (Unicode, 16 bits)

The Java I/O System. Binary I/O streams (ascii, 8 bits) The decorator design pattern Character I/O streams (Unicode, 16 bits) Binary I/O streams (ascii, 8 bits) InputStream OutputStream The Java I/O System The decorator design pattern Character I/O streams (Unicode, 16 bits) Reader Writer Comparing Binary I/O to Character I/O

More information

School of Informatics, University of Edinburgh

School of Informatics, University of Edinburgh CS1Bh Lecture Note 13 Event-driven programming The best practice in user-interface code development is the event-driven programming model in which code fragments can be associated with particular events

More information

Simple GUI Input. String input Use showinputdialog() of JOptionPane class

Simple GUI Input. String input Use showinputdialog() of JOptionPane class CS1706 Intro to Object Oriented Dev II - Fall 04 Announcements Week 11 Project 2 due 11/01 Project 3 posted in a few days Exam 2 next week Material Java Graphical User Interfaces (GUI) Simple GUI Input

More information

Concepts of Programming Languages

Concepts of Programming Languages Concepts of Programming Languages Lecture 20 - Event-Driven Programming Patrick Donnelly Montana State University Spring 2014 Patrick Donnelly (Montana State University) Concepts of Programming Languages

More information

Graphical User Interface (GUI), Part 1

Graphical User Interface (GUI), Part 1 Graphical User Interface (GUI), Part 1 Applets The Model-View-Controller GUI Architecture Separated Model Architecture Abstract Windowing Toolkit (AWT) Java Foundation Classes (JFC) Note this is a huge

More information

An interface is similar to an abstract class, but is different in that all it contains is empty functions and, perhaps, static final, constants.

An interface is similar to an abstract class, but is different in that all it contains is empty functions and, perhaps, static final, constants. Lecture 13 Interfaces An interface is similar to an abstract class, but is different in that all it contains is empty functions and, perhaps, static final, constants. As an example, we have public interface

More information

Event-Driven Programming

Event-Driven Programming Event-Driven Programming Lecture 4 Jenny Walter Fall 2008 Simple Graphics Program import acm.graphics.*; import java.awt.*; import acm.program.*; public class Circle extends GraphicsProgram { public void

More information

CS193j, Stanford Handout #12. Listeners

CS193j, Stanford Handout #12. Listeners CS193j, Stanford Handout #12 Winter, 2002-03 Nick Parlante Listeners Anonymous inner class Before getting to listeners, we will need anonymous inner classes... An "anonymous" inner class is a type of inner

More information

Preet raj Core Java and Databases CS4PR. Time Allotted: 3 Hours. Final Exam: Total Possible Points 75

Preet raj Core Java and Databases CS4PR. Time Allotted: 3 Hours. Final Exam: Total Possible Points 75 Preet raj Core Java and Databases CS4PR Time Allotted: 3 Hours Final Exam: Total Possible Points 75 Q1. What is difference between overloading and overriding? 10 points a) In overloading, there is a relationship

More information

Lab #2 Java s Basic Elements and Loan Calculator

Lab #2 Java s Basic Elements and Loan Calculator Lab #2 Java s Basic Elements and Loan Calculator Objectives: Introduce Java s primitive data types, assignment, arithmetic operators, and the String class. Walkthrough examples of the above. Problem Statement

More information

ADDING SOUND TO JAVA APPLICATIONS

ADDING SOUND TO JAVA APPLICATIONS ADDING SOUND TO JAVA APPLICATIONS It s now time to add sound effects to our programs. Fortunately, Java provides built-in support for playing sound and music files. Java supports a variety of audio formats,

More information

Lecture 4: Input and Output

Lecture 4: Input and Output Input and Output Lecture 4: Input and Output Input devices. Keyboard Mouse Storage Network Digital camera 3D Scanner Speakers Storage Network Printer MP3 Player Output devices. Display Our approach. Define

More information

NOTE: This supplement can be used after Chapter 6, Containers and Layout Managers.

NOTE: This supplement can be used after Chapter 6, Containers and Layout Managers. Creating Internal Frames NOTE: This supplement can be used after Chapter 6, Containers and Layout Managers. You can create multiple windows as shown in Example 11.12, Creating Multiple Windows, in Chapter

More information

Using NetBeans IDE for Desktop Development. Geertjan Wielenga http://blogs.sun.com/geertjan

Using NetBeans IDE for Desktop Development. Geertjan Wielenga http://blogs.sun.com/geertjan Using NetBeans IDE for Desktop Development Geertjan Wielenga http://blogs.sun.com/geertjan Agenda Goals Design: Matisse GUI Builder Medium Applications: JSR-296 Tooling Large Applications: NetBeans Platform

More information

More on Buttons ( ) Frank Ducrest

More on Buttons ( ) Frank Ducrest More on Buttons (2006.11.20) Frank Ducrest More Swing 2 JRadioButton and ButtonGroup JRadioButton class objects act like JCheckbox objects, but are added to ButtonGroup objects only one JRadioButton object

More information