Apéndice A. Código fuente de aplicación desarrollada para probar. implementación de IPv6

Size: px
Start display at page:

Download "Apéndice A. Código fuente de aplicación desarrollada para probar. implementación de IPv6"

Transcription

1 Apéndice A Código fuente de aplicación desarrollada para probar implementación de IPv6 import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; import java.net.*; import java.util.enumeration; public class interfazipng extends JFrame implements ActionListener{ JButton BotonEjecutar; JComboBox VersionIP; JTextField TextFieldParametroIp; JComboBox ComboComando; JScrollPane scrollpane_1; JScrollPane scrollpane_2; JTextArea resultadoipv4; JTextArea resultadoipv6; JLabel label_1; JLabel label_2; JButton BotonSocketServer4; 59

2 JButton BotonSoketCliente4; JButton BotonSoketServer6; JButton BotonSocketClient6; public interfazipng() { interfazipnglayout customlayout = new interfazipnglayout(); getcontentpane().setfont(new Font("Helvetica", Font.PLAIN, 12)); getcontentpane().setlayout(customlayout); BotonEjecutar = new JButton("Ejecutar"); BotonEjecutar.addActionListener(this); getcontentpane().add(botonejecutar); VersionIP = new JComboBox(); VersionIP.addItem("IPv4"); VersionIP.addItem("IPv6"); VersionIP.addActionListener(this); getcontentpane().add(versionip); TextFieldParametroIp = new JTextField("IP"); TextFieldParametroIp.addActionListener(this); getcontentpane().add(textfieldparametroip); ComboComando = new JComboBox(); 60

3 ComboComando.addItem("IP"); ComboComando.addItem("Ipconfig"); ComboComando.addItem("Ipconfig OS"); ComboComando.addItem("Ping"); ComboComando.addItem("NsLookUp"); ComboComando.addActionListener(this); getcontentpane().add(combocomando); /*scrollpane_1 = new JScrollPane(); getcontentpane().add(scrollpane_1); scrollpane_2 = new JScrollPane(); getcontentpane().add(scrollpane_2);*/ resultadoipv4 = new JTextArea(); resultadoipv4.seteditable(true); resultadoipv4.setautoscrolls(true); getcontentpane().add(resultadoipv4); resultadoipv6 = new JTextArea(); resultadoipv6.seteditable(true); resultadoipv6.setautoscrolls(true); getcontentpane().add(resultadoipv6); label_1 = new JLabel("Resultado IPv4"); 61

4 getcontentpane().add(label_1); label_2 = new JLabel("Resultado IPv6"); getcontentpane().add(label_2); BotonSocketServer4 = new JButton("ServidorSocket 4"); BotonSocketServer4.addActionListener(this); getcontentpane().add(botonsocketserver4); BotonSoketCliente4 = new JButton("Cliente Socket 4"); BotonSoketCliente4.addActionListener(this); getcontentpane().add(botonsoketcliente4); BotonSoketServer6 = new JButton("Servidor Socket 6"); BotonSoketServer6.addActionListener(this); getcontentpane().add(botonsoketserver6); BotonSocketClient6 = new JButton("Cliente Socket 6"); BotonSocketClient6.addActionListener(this); getcontentpane().add(botonsocketclient6); setsize(getpreferredsize()); addwindowlistener(new WindowAdapter() { public void windowclosing(windowevent e) { 62

5 System.exit(0); ); public static void main(string args[]) { interfazipng window = new interfazipng(); window.settitle("interfazipng"); window.pack(); window.show(); /* Metodos que controla las acciones */ public void actionperformed(actionevent event) { Object source = event.getsource(); if(botonejecutar.equals(source)){ //System.out.println("Entre aqui"); //System.out.println("ComboComando: " + ComboComando.getSelectedItem()); //System.out.println("ComboComando: " + ComboComando.getSelectedItem()); if ((ComboComando.getSelectedItem().equals("IP")) && (VersionIP.getSelectedItem().equals("IPv4"))){ 63

6 System.out.println("texto de prueba"); try { ip4(); catch (Exception e) { System.out.println("Unexpected exception"); e.printstacktrace(); finally { if ((ComboComando.getSelectedItem().equals("IP")) && (VersionIP.getSelectedItem().equals("IPv6"))){ System.out.println("texto de prueba"); try { ip6(); catch (Exception e) { System.out.println("Unexpected exception"); e.printstacktrace(); finally { if (ComboComando.getSelectedItem().equals("Ipconfig")) { System.out.println("texto de prueba"); try { 64

7 ipconfigjava(); catch (Exception e) { System.out.println("Unexpected exception"); e.printstacktrace(); finally { if (ComboComando.getSelectedItem().equals("Ipconfig OS")) { System.out.println("texto de prueba"); try { ipconfigos(); catch (Exception e) { System.out.println("Unexpected exception"); e.printstacktrace(); finally { if ((ComboComando.getSelectedItem().equals("Ping")) && (VersionIP.getSelectedItem().equals("IPv4")) && (TextFieldParametroIp!=null)){ String IP = TextFieldParametroIp.getText(); System.out.println("texto de prueba"); try { Ping6(IP); 65

8 catch (Exception e) { System.out.println("Unexpected exception"); e.printstacktrace(); finally { if ((ComboComando.getSelectedItem().equals("Ping")) && (VersionIP.getSelectedItem().equals("IPv6")) && (TextFieldParametroIp!=null)){ String IP = TextFieldParametroIp.getText(); System.out.println("texto de prueba"); try { Ping6(IP); catch (Exception e) { System.out.println("Unexpected exception"); e.printstacktrace(); finally { /* Metodos que realizan las funciones de la interfaz 66

9 */ public void ip4() throws java.io.ioexception { System.setProperty("java.net.preferIPv6Addresses", "false"); java.net.inetaddress direccip = java.net.inetaddress.getlocalhost(); // Class classname = direccip.getclass(); // System.out.println(className); // Imprimiendo la dirección IP System.out.println(direccIP.getHostAddress()); resultadoipv4.settext(direccip.gethostaddress()); //System.out.println(System.getProperty("java.net.preferIPv6Addresses")); //System.clearProperty("java.net.preferIPv6Addresses"); public void ip6() throws java.io.ioexception { System.out.println(System.getProperty("java.net.preferIPv6Addresses")); System.setProperty("java.net.preferIPv6Addresses", "true"); System.out.println(System.getProperty("java.net.preferIPv6Addresses")); java.net.inetaddress direccip6 = java.net.inetaddress.getlocalhost(); // Class classname = direccip.getclass(); // System.out.println(className); // Imprimiendo la dirección IP System.out.println(direccIP6.getHostAddress()); 67

10 resultadoipv6.settext(direccip6.gethostaddress()); System.out.println(System.getProperty("java.net.preferIPv6Addresses")); public void foo4() { System.setProperty("java.net.preferIPv6Addresses", "false"); DoATest("literal", "3ffe:1200:301b:0:2d0:b7ff:febe:e2a8"); DoATest("Host A and AAAA", "quack.kfu.com"); DoATest(" solo host AAAA", "morpheus.kfu.com"); public void foo6() { System.setProperty("java.net.preferIPv6Addresses", "true"); DoATest("literal", "3ffe:1200:301b:0:2d0:b7ff:febe:e2a8"); DoATest("Host A and AAAA", "quack.kfu.com"); DoATest(" solo host AAAA", "morpheus.kfu.com"); private static void DoATest(String pruebanombre, String host) { System.out.println("Comenzando la prueba " + pruebanombre); try { InetAddress ad = InetAddress.getByName(host); System.out.println("Exitoso: " + ad); Socket socket = new Socket(ad, 22); System.out.println("Conectado."); 68

11 socket.close(); catch(unknownhostexception e) { System.out.println("Host desconocido"); return; catch(ioexception e) { System.out.println("Error E/S"); return; public void ipconfigjava() throws SocketException { Enumeration enumera = NetworkInterface.getNetworkInterfaces(); while (enumera.hasmoreelements()) { NetworkInterface red = (NetworkInterface)enumera.nextElement(); System.out.println("Nombres: " + red.getname() + " / " + red.getdisplayname()); Enumeration enumera2 = red.getinetaddresses(); while (enumera2.hasmoreelements()) { InetAddress direccion = (InetAddress)enumera2.nextElement(); System.out.println("\tDirección: " + direccion.gethostaddress()); 69

12 public void ipconfigos() { BufferedReader in = null; try { Runtime r = Runtime.getRuntime(); Process p = r.exec("ipconfig /all"); if (p == null) { System.out.println("Could not connect"); in = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; while ((line = in.readline())!= null) { System.out.println(line); resultadoipv4.append(line + "\n"); in.close(); catch (IOException io) { System.err.println(io.toString()); public void Ping6(String IP6) { BufferedReader in = null; 70

13 try { Runtime r = Runtime.getRuntime(); Process p = r.exec("ping " + IP6); if (p == null) { System.out.println("Could not connect"); in = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; while ((line = in.readline())!= null) { System.out.println(line); in.close(); catch (IOException io) { System.err.println(io.toString()); public void lookup4 () { try{ String direccion=""; String hostname=""; InetAddress inetaddress; hostname=" System.setProperty("java.net.preferIPv6Addresses", "false"); 71

14 System.out.println("\tEl hostname inicial es:\t"+hostname); inetaddress = InetAddress.getByName(hostname); direccion = inetaddress.gethostaddress().tostring(); System.out.println("\tLa dirección IP es:\t\t"+direccion); inetaddress = InetAddress.getByName(direccion); System.out.println("\tEl lookup de vuelta del hostname es:\t"+inetaddress.gethostname()); catch (Exception e){ e.printstacktrace(system.err); System.out.println("error:\t"+e); public void lookup6 () { try{ String direccion=""; String hostname=""; InetAddress inetaddress; hostname=" System.setProperty("java.net.preferIPv6Addresses", "true"); 72

15 System.out.println("\tEl hostname inicial es:\t"+hostname); inetaddress = InetAddress.getByName(hostname); direccion = inetaddress.gethostaddress().tostring(); System.out.println("\tLa dirección IP es:\t\t"+direccion); inetaddress = InetAddress.getByName(direccion); System.out.println("\tEl lookup de vuelta del hostname es:\t"+inetaddress.gethostname()); catch (Exception e){ e.printstacktrace(system.err); System.out.println("error:\t"+e); class interfazipnglayout implements LayoutManager { public interfazipnglayout() { public void addlayoutcomponent(string name, Component comp) { 73

16 public void removelayoutcomponent(component comp) { public Dimension preferredlayoutsize(container parent) { Dimension dim = new Dimension(0, 0); Insets insets = parent.getinsets(); dim.width = insets.left + insets.right; dim.height = insets.top + insets.bottom; return dim; public Dimension minimumlayoutsize(container parent) { Dimension dim = new Dimension(0, 0); return dim; public void layoutcontainer(container parent) { Insets insets = parent.getinsets(); Component c; c = parent.getcomponent(0); 74

17 if (c.isvisible()) {c.setbounds(insets.left+328,insets.top+16,104,24); c = parent.getcomponent(1); if (c.isvisible()) {c.setbounds(insets.left+240,insets.top+16,72,24); c = parent.getcomponent(2); if (c.isvisible()) {c.setbounds(insets.left+456,insets.top+16,232,24); c = parent.getcomponent(3); if (c.isvisible()) {c.setbounds(insets.left+48,insets.top+16,160,24); c = parent.getcomponent(4); if (c.isvisible()) {c.setbounds(insets.left+40,insets.top+72,288,376); c = parent.getcomponent(5); if (c.isvisible()) {c.setbounds(insets.left+384,insets.top+72,288,376); c = parent.getcomponent(6); if (c.isvisible()) {c.setbounds(insets.left+88,insets.top+48,176,24); c = parent.getcomponent(7); if (c.isvisible()) {c.setbounds(insets.left+432,insets.top+48,176,24); c = parent.getcomponent(8); if (c.isvisible()) {c.setbounds(insets.left+104,insets.top+472,144,24); c = parent.getcomponent(9); if (c.isvisible()) {c.setbounds(insets.left+104,insets.top+496,144,24); c = parent.getcomponent(10); if (c.isvisible()) {c.setbounds(insets.left+456,insets.top+472,136,24); c = parent.getcomponent(11); if (c.isvisible()) {c.setbounds(insets.left+456,insets.top+496,136,24); 75

Layout. Dynamic layout Layout design pattern Layout strategies

Layout. Dynamic layout Layout design pattern Layout strategies Layout Dynamic layout Layout design pattern Layout strategies 2.6 Layout 2 https://www.bostonglobe.com/ 2.6 Layout 3 Responsive vs. Adaptive Responsive: universal design reflows spatial layout to fit width

More information

Layout. Dynamic layout Layout design pattern Layout strategies. 2.6 Layout 2

Layout. Dynamic layout Layout design pattern Layout strategies. 2.6 Layout 2 Layout Dynamic layout Layout design pattern Layout strategies 2.6 Layout 2 Two Interface Layout Tasks 1. Designing a spatial layout of widgets in a container 2. Adjusting that spatial layout when container

More information

JAVA NOTES GRAPHICAL USER INTERFACES

JAVA 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 information

Input from Files. Buffered Reader

Input 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 information

Networking Basics. network communication.

Networking Basics. network communication. JAVA NETWORKING API Networking Basics When you write Java programs that communicate over the network, you are programming at the application layer. Typically, you don't need to concern yourself with the

More information

CS193k, Stanford Handout #16

CS193k, Stanford Handout #16 CS193k, Stanford Handout #16 Spring, 99-00 Nick Parlante Practice Final Final Exam Info Our regular exam time is Sat June 3rd in Skilling Aud (our regular room) from 3:30-5:30. The alternate will be Fri

More information

Principles, Models and Applications for Distributed Systems M

Principles, 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 2 (worked-out) Connectionless Java Sockets Luca Foschini 2010/2011 Exercise

More information

Example 3-1. Password Validation

Example 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 information

JAVA NOTES GRAPHICAL USER INTERFACES

JAVA 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 information

PRÁCTICO 1: MODELOS ESTÁTICOS INGENIERÍA INVERSA DIAGRAMAS DE CLASES

PRÁCTICO 1: MODELOS ESTÁTICOS INGENIERÍA INVERSA DIAGRAMAS DE CLASES PRÁCTICO 1: MODELOS ESTÁTICOS INGENIERÍA INVERSA DIAGRAMAS DE CLASES Una parte importante dentro del proceso de re-ingeniería de un sistema es la ingeniería inversa del mismo, es decir, la obtención de

More information

Lesson: Programmatic Access to Network Parameters

Lesson: Programmatic Access to Network Parameters Lesson: Programmatic Access to Network Parameters Systems often run with multiple active network connections, such as wired Ethernet, 802.11 b/g (wireless), and bluetooth. Some applications might need

More information

Java Networking (sockets)

Java Networking (sockets) Java Networking (sockets) Rui Moreira Links: http://java.sun.com/docs/books/tutorial/networking/toc.html#sockets http://www.javaworld.com/javaworld/jw-12-1996/jw-12-sockets_p.html Networking Computers

More information

RAIK 183H Examination 2 Solution. November 10, 2014

RAIK 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 information

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp DM550 / DM857 Introduction to Programming Peter Schneider-Kamp petersk@imada.sdu.dk http://imada.sdu.dk/~petersk/dm550/ http://imada.sdu.dk/~petersk/dm857/ GRAPHICAL USER INTERFACES 2 HelloWorld Reloaded

More information

URL Kullanımı Get URL

URL Kullanımı Get URL Networking 1 URL Kullanımı Get URL URL info 2 import java.io.*; import java.net.*; public class GetURL { public static void main(string[] args) { InputStream in = null; OutputStream out = null; // Check

More information

Introduction This assignment will ask that you write a simple graphical user interface (GUI).

Introduction This assignment will ask that you write a simple graphical user interface (GUI). Computing and Information Systems/Creative Computing University of London International Programmes 2910220: Graphical Object-Oriented and Internet programming in Java Coursework one 2011-12 Introduction

More information

TP 2 : Application SnapTchat 20 février 2015

TP 2 : Application SnapTchat 20 février 2015 TP 2 : Application SnapTchat 20 février 2015 SnapTchat : cahier de charges L objectif de ce TP est de développer une simple application d échange de messages courts entre deux utilisateurs. Le cahier des

More information

) / Java ( )

) / 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 information

A Simple Text Editor Application

A 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 information

2018/2/5 话费券企业客户接入文档 语雀

2018/2/5 话费券企业客户接入文档 语雀 1 2 2 1 2 1 1 138999999999 2 1 2 https:lark.alipay.com/kaidi.hwf/hsz6gg/ppesyh#2.4-%e4%bc%81%e4%b8%9a%e5%ae%a2%e6%88%b7%e6%8e%a5%e6%94%b6%e5%85%85%e5 1/8 2 1 3 static IAcsClient client = null; public static

More information

A sample print out is: is is -11 key entered was: w

A 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 information

protected void printserial() { System.out.println("> NO." + this.serialno); this.serialno++; }

protected void printserial() { System.out.println(> NO. + this.serialno); this.serialno++; } NumberedTicketGenerator.java package j2.exam.ex01; public abstract class NumberedTicketGenerator { protected int serialno; public NumberedTicketGenerator() { super(); this.serialno = 1000; public void

More information

Multiplayer Game Programming 2/26

Multiplayer Game Programming 2/26 Multiplayer Game Programming 2/26 1. Turn off Windows Firewall 2. Download and install Python and Notepad++ a. Python.org downloads/python/install b. Notepad-plus-plus.org download/install 3. Download

More information

COMP 213. Advanced Object-oriented Programming. Lecture 20. Network Programming

COMP 213. Advanced Object-oriented Programming. Lecture 20. Network Programming COMP 213 Advanced Object-oriented Programming Lecture 20 Network Programming Network Programming A network consists of several computers connected so that data can be sent from one to another. Network

More information

Part 3: Graphical User Interface (GUI) & Java Applets

Part 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 information

Java Technologies. Lecture VII. Valdas Rapševičius. Vilnius University Faculty of Mathematics and Informatics

Java Technologies. Lecture VII. Valdas Rapševičius. Vilnius University Faculty of Mathematics and Informatics Preparation of the material was supported by the project Increasing Internationality in Study Programs of the Department of Computer Science II, project number VP1 2.2 ŠMM-07-K-02-070, funded by The European

More information

Midterm assessment - MAKEUP Fall 2010

Midterm assessment - MAKEUP Fall 2010 M257 MTA Faculty of Computer Studies Information Technology and Computing Date: /1/2011 Duration: 60 minutes 1-Version 1 M 257: Putting Java to Work Midterm assessment - MAKEUP Fall 2010 Student Name:

More information

Control Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User

Control 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 information

PART1: Choose the correct answer and write it on the answer sheet:

PART1: Choose the correct answer and write it on the answer sheet: PART1: Choose the correct answer and write it on the answer sheet: (15 marks 20 minutes) 1. Which of the following is included in Java SDK? a. Java interpreter c. Java disassembler b. Java debugger d.

More information

public static void main(string[] args) throws IOException { sock = new Socket(args[0], Integer.parseInt(args[1]));

public static void main(string[] args) throws IOException { sock = new Socket(args[0], Integer.parseInt(args[1])); Echo Client&Server Application EchoClient import java.net.*; import java.io.*; class EchoClient public static void main(string[] args) throws IOException if (args.length < 2) number>"); System.err.println("Usage:

More information

H212 Introduction to Software Systems Honors

H212 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 information

1005ICT Object Oriented Programming Lecture Notes

1005ICT 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 information

Layout. Dynamic layout, Swing and general layout strategies

Layout. Dynamic layout, Swing and general layout strategies Layout Dynamic layout, Swing and general layout strategies Two Interface Layout Tasks Designing a spatial layout of widgets in a container Adjusting that spatial layout when container is resized Both

More information

Swing from A to Z Some Simple Components. Preface

Swing from A to Z Some Simple Components. Preface By Richard G. Baldwin baldwin.richard@iname.com Java Programming, Lecture Notes # 1005 July 31, 2000 Swing from A to Z Some Simple Components Preface Introduction Sample Program Interesting Code Fragments

More information

Java for Interfaces and Networks (DT3010, HT10)

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

More information

MIT AITI Swing Event Model Lecture 17

MIT 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 information

Graphical User Interfaces. Swing. Jose Jesus García Rueda

Graphical User Interfaces. Swing. Jose Jesus García Rueda Graphical User Interfaces. Swing Jose Jesus García Rueda Introduction What are the GUIs? Well known examples Basic concepts Graphical application. Containers. Actions. Events. Graphical elements: Menu

More information

Chapter 13 Lab Advanced GUI Applications Lab Objectives. Introduction. Task #1 Creating a Menu with Submenus

Chapter 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 information

CS11 Java. Fall Lecture 4

CS11 Java. Fall Lecture 4 CS11 Java Fall 2014-2015 Lecture 4 Java File Objects! Java represents files with java.io.file class " Can represent either absolute or relative paths! Absolute paths start at the root directory of the

More information

Chapter 13 Lab Advanced GUI Applications

Chapter 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 information

1 (6) Lösningsförslag Objektorienterade applikationer Provdatum Program DAI 2 Läsår 2016/2017, lp 3. Uppgift 1 (1+1+1 p) a)

1 (6) Lösningsförslag Objektorienterade applikationer Provdatum Program DAI 2 Läsår 2016/2017, lp 3. Uppgift 1 (1+1+1 p) a) till dugga P r e l i m i n ä r 1 (6) Kursnamn Objektorienterade applikationer Provdatum 2017-02-09 Program DAI 2 Läsår 2016/2017, lp 3 Examinator Uno Holmer Uppgift 1 (1+1+1 p) a) b) c) public interface

More information

FORMAS 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. 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 information

HomeWork 3. In this homework, an ArchJava application that allows one to query one s scores in a networked environment is presented.

HomeWork 3. In this homework, an ArchJava application that allows one to query one s scores in a networked environment is presented. HomeWork 3 In this homework, an ArchJava application that allows one to query one s scores in a networked environment is presented. [1] Acme Description The architecture that has been implemented using

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 information

Networking Code CSCI 201 Principles of Software Development

Networking Code CSCI 201 Principles of Software Development Networking Code CSCI 201 Principles of Software Development Jeffrey Miller, Ph.D. jeffrey.miller@usc.edu Server Networking Client Networking Program Outline USC CSCI 201L Server Software A server application

More information

RAIK 183H Examination 2 Solution. November 11, 2013

RAIK 183H Examination 2 Solution. November 11, 2013 RAIK 183H Examination 2 Solution November 11, 2013 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 information

Multimedia Programming

Multimedia 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 information

Java for Interfaces and Networks

Java for Interfaces and Networks Java for Interfaces and Networks Threads and Networking Federico Pecora School of Science and Technology Örebro University federico.pecora@oru.se Federico Pecora Java for Interfaces and Networks Lecture

More information

agentmom User's Manual

agentmom 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 information

Window Interfaces Using Swing Objects

Window 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 information

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling

Handout 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 information

1.00/1.001 Introduction to Computers and Engineering Problem Solving Final Examination - December 15, 2003

1.00/1.001 Introduction to Computers and Engineering Problem Solving Final Examination - December 15, 2003 1.00/1.001 Introduction to Computers and Engineering Problem Solving Final Examination - December 15, 2003 Name: E-mail Address: TA: Section: You have 3 hours to complete this exam. For coding questions,

More information

Frames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling

Frames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling Frames, GUI and events Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling Introduction to Swing The Java AWT (Abstract Window Toolkit)

More information

APPENDIX B: Code Samples from the GUI Supervisor: Graham Kendall

APPENDIX B: Code Samples from the GUI Supervisor: Graham Kendall Applying a windows look and feel The program has been developed using a windows look and feel, and the code below, tries to set the look to windows. This is called in the constructor. If the look can t

More information

CSEN401 Computer Programming Lab. Topics: Graphical User Interface Window Interfaces using Swing

CSEN401 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 information

Previous lecture: threads G51PRG: Introduction to Programming Second semester Lecture 12 URL

Previous lecture: threads G51PRG: Introduction to Programming Second semester Lecture 12 URL Previous lecture: threads G51PRG: Introduction to Programming Second semester Lecture 12 What is a thread Why use multiple threads Issues and problems involved Java threads Natasha Alechina School of Computer

More information

First Name: AITI 2004: Exam 2 July 19, 2004

First Name: AITI 2004: Exam 2 July 19, 2004 First Name: AITI 2004: Exam 2 July 19, 2004 Last Name: Standard Track Read Instructions Carefully! This is a 3 hour closed book exam. No calculators are allowed. Please write clearly if we cannot understand

More information

COMP Assignment #10 (Due: Monday, March 11:30pm)

COMP Assignment #10 (Due: Monday, March 11:30pm) COMP1406 - Assignment #10 (Due: Monday, March 31st @ 11:30pm) In this assignment you will practice using recursion with data structures. (1) Consider the following BinaryTree class: public class BinaryTree

More information

GUI Applications. Let s start with a simple Swing application in Java, and then we will look at the same application in Jython. See Listing 16-1.

GUI Applications. Let s start with a simple Swing application in Java, and then we will look at the same application in Jython. See Listing 16-1. GUI Applications The C implementation of Python comes with Tkinter for writing Graphical User Interfaces (GUIs). The GUI toolkit that you get automatically with Jython is Swing, which is included with

More information

Lösningsförslag till exempeldugga

Lö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 information

Graphical User Interfaces 2

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

More information

Network Programming Benoît Garbinato

Network Programming Benoît Garbinato Network Programming Benoît Garbinato 1 Network programming Network programming is not distributed programming (somewhat lower-level) They both rely on: computers as processing & storage resources a network

More information

Dr. Hikmat A. M. AbdelJaber

Dr. Hikmat A. M. AbdelJaber Dr. Hikmat A. M. AbdelJaber JWindow: is a window without a title bar or move controls. The program can move and resize it, but the user cannot. It has no border at all. It optionally has a parent JFrame.

More information

CSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

CSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT CSE 143 Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/

More information

JRadioButton account_type_radio_button2 = new JRadioButton("Current"); ButtonGroup account_type_button_group = new ButtonGroup();

JRadioButton 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 information

Reading from URL. Intent - open URL get an input stream on the connection, and read from the input stream.

Reading from URL. Intent - open URL  get an input stream on the connection, and read from the input stream. Simple Networking Loading applets from the network. Applets are referenced in a HTML file. Java programs can use URLs to connect to and retrieve information over the network. Uniform Resource Locator (URL)

More information

First Name: AITI 2004: Exam 2 July 19, 2004

First Name: AITI 2004: Exam 2 July 19, 2004 First Name: AITI 2004: Exam 2 July 19, 2004 Last Name: JSP Track Read Instructions Carefully! This is a 3 hour closed book exam. No calculators are allowed. Please write clearly if we cannot understand

More information

CISC 4700 L01 Network & Client-Server Programming Spring Harold, Chapter 4: Internet Addresses

CISC 4700 L01 Network & Client-Server Programming Spring Harold, Chapter 4: Internet Addresses CISC 4700 L01 Network & Client-Server Programming Spring 2016 Harold, Chapter 4: Internet Addresses IPv4 address: four bytes (150.108.64.64) IPv6 address: sixteen bytes (2001:0250:02FF:0210:0250:8BFF:FEDE:67C8)

More information

Java - Applications. The following code sets up an application with a drop down menu, as yet the menu does not do anything.

Java - Applications. The following code sets up an application with a drop down menu, as yet the menu does not do anything. Java - Applications C&G Criteria: 5.3.2, 5.5.2, 5.5.3 Java applets require a web browser to run independently of the Java IDE. The Dos based console applications will run outside the IDE but have no access

More information

PDA User Interface for a Data Acquisition System

PDA User Interface for a Data Acquisition System PDA User Interface for a Data Acquisition System Thomas Rodriguez CEN 3213 - Embedded Systems Programming - Dr. Zalewski Florida Gulf Coast University March 28, 2007 Rodriguez 2 of 16 Section 1. Introduction

More information

Attempt FOUR questions Marking Scheme Time: 120 mins

Attempt 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 information

Window Interfaces Using Swing Objects

Window 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 information

Java for Interfaces and Networks (DT3029)

Java for Interfaces and Networks (DT3029) Java for Interfaces and Networks (DT3029) Lecture 3 Threads and Networking Federico Pecora federico.pecora@oru.se Center for Applied Autonomous Sensor Systems (AASS) Örebro University, Sweden Capiscum

More information

Lösningsförslag till tentamen

Lö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 information

CS 2113 Software Engineering

CS 2113 Software Engineering CS 2113 Software Engineering Java 6: File and Network IO https://github.com/cs2113f18/template-j-6-io.git Professor Tim Wood - The George Washington University Project 2 Zombies Basic GUI interactions

More information

The Design and Implementation of Multimedia Software

The Design and Implementation of Multimedia Software Chapter 3 Programs The Design and Implementation of Multimedia Software David Bernstein Jones and Bartlett Publishers www.jbpub.com David Bernstein (jbpub.com) Multimedia Software Jones and Bartlett 1

More information

1. Swing Note: Most of the stuff stolen from or from the jdk documentation. Most programs are modified or written by me. This section explains the

1. Swing Note: Most of the stuff stolen from or from the jdk documentation. Most programs are modified or written by me. This section explains the 1. Swing Note: Most of the stuff stolen from or from the jdk documentation. Most programs are modified or written by me. This section explains the various elements of the graphical user interface, i.e.,

More information

Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008

Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008 Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008 Announcements A3 is up, due Friday, Oct 10 Prelim 1 scheduled for Oct 16 if you have a conflict, let us know now 2 Interactive

More information

Swing/GUI Cheat Sheet

Swing/GUI Cheat Sheet General reminders To display a Swing component, you must: Swing/GUI Cheat Sheet Construct and initialize the component. Example: button = new JButton ("ButtonLabel"); Add it to the content pane of the

More information

Network Programming. Powered by Pentalog. by Vlad Costel Ungureanu for Learn Stuff

Network Programming. Powered by Pentalog. by Vlad Costel Ungureanu for Learn Stuff Network Programming by Vlad Costel Ungureanu for Learn Stuff Java Network Protocols 2 Java Network Protocols 3 Addresses Innet4Address (32-bit) 85.122.23.145 - numeric pentalog.com symbolic Innet6Address

More information

Chapter 2. Network Chat

Chapter 2. Network Chat Chapter 2. Network Chat In a multi-player game, different players interact with each other. One way of implementing this is to have a centralized server that interacts with each client using a separate

More information

Swing - JTextField. Adding a text field to the main window (with tooltips and all)

Swing - JTextField. Adding a text field to the main window (with tooltips and all) Swing - JTextField Adding a text field to the main window (with tooltips and all) Prerequisites - before this lecture You should have seen: The lecture on JFrame The lecture on JButton Including having

More information

COMPSCI 230. Software Design and Construction. Swing

COMPSCI 230. Software Design and Construction. Swing COMPSCI 230 Software Design and Construction Swing 1 2013-04-17 Recap: SWING DESIGN PRINCIPLES 1. GUI is built as containment hierarchy of widgets (i.e. the parent-child nesting relation between them)

More information

Week 12. Streams and File I/O. Overview of Streams and File I/O Text File I/O

Week 12. Streams and File I/O. Overview of Streams and File I/O Text File I/O Week 12 Streams and File I/O Overview of Streams and File I/O Text File I/O 1 I/O Overview I/O = Input/Output In this context it is input to and output from programs Input can be from keyboard or a file

More information

Swing. By Iqtidar Ali

Swing. By Iqtidar Ali Swing By Iqtidar Ali Background of Swing We have been looking at AWT (Abstract Window ToolKit) components up till now. Programmers were not comfortable when doing programming with AWT. Bcoz AWT is limited

More information

Packages: Putting Classes Together

Packages: 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 information

IT101. File Input and Output

IT101. File Input and Output IT101 File Input and Output IO Streams A stream is a communication channel that a program has with the outside world. It is used to transfer data items in succession. An Input/Output (I/O) Stream represents

More information

Programmi di utilità

Programmi di utilità Programmi di utilità La classe SystemData per il calcolo dei tempi e della occupazione di memoria Per calcolare i tempi e la occupazione di memoria è necessario interagire con il sistema operativo, questo

More information

Getting started with Winstone. Minimal servlet container

Getting started with Winstone. Minimal servlet container Getting started with Winstone Minimal servlet container What is Winstone? Winstone is a small servlet container, consisting of a single JAR file. You can run Winstone on your computer using Java, and get

More information

Chapter 12. Network Programming

Chapter 12. Network Programming Chapter 12 Network Programming What is in This Chapter? This chapter explains how to connect your JAVA application to a network. You will learn how to read files from over the internet as well as have

More information

Distributed Programming - Sockets

Distributed Programming - Sockets Distributed Programming - Sockets Piet van Oostrum May 25, 2009 Concurrency In praktische situaties krijgen we concurrency door: Processen Threads Interrupts (alleen intern in het O.S.) Processen Onafhankelijke

More information

CSPP : Introduction to Object-Oriented Programming

CSPP : Introduction to Object-Oriented Programming CSPP 511-01: Introduction to Object-Oriented Programming Harri Hakula Ryerson 256, tel. 773-702-8584 hhakula@cs.uchicago.edu August 7, 2000 CSPP 511-01: Lecture 15, August 7, 2000 1 Exceptions Files: Text

More information

Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks)

Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks) M257 MTA Spring2010 Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks) 1. If we need various objects that are similar in structure, but

More information

SampleApp.java. Page 1

SampleApp.java. Page 1 SampleApp.java 1 package msoe.se2030.sequence; 2 3 /** 4 * This app creates a UI and processes data 5 * @author hornick 6 */ 7 public class SampleApp { 8 private UserInterface ui; // the UI for this program

More information

SWING - GROUPLAYOUT CLASS

SWING - GROUPLAYOUT CLASS SWING - GROUPLAYOUT CLASS http://www.tutorialspoint.com/swing/swing_grouplayout.htm Copyright tutorialspoint.com Introduction The class GroupLayout hierarchically groups components in order to position

More information

CS 51 Laboratory # 12

CS 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 information

Lab Assignment 13 (week 13)

Lab Assignment 13 (week 13) Lab Assignment 13 (week 13) In this lab you are going to learn how to use the StringTokenizer class. Please look at the API for StringTokenizer at the below link. http://java.sun.com/j2se/1.4.2/docs/api/java/util/stringtokenizer.html

More information

Object-Oriented Programming in Java

Object-Oriented Programming in Java CSCI/CMPE 3326 Object-Oriented Programming in Java 1. Socket Programming Dongchul Kim Department of Computer Science University of Texas Rio Grande Valley Two types of TCP Socket java.net.serversocket

More information

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

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

More information

Principles, Models, and Applications for Distributed Systems M

Principles, 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 information