CS 335 Lecture 06 Java Programming GUI and Swing

Size: px
Start display at page:

Download "CS 335 Lecture 06 Java Programming GUI and Swing"

Transcription

1 CS 335 Lecture 06 Java Programming GUI and Swing

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

3 Alternatives AWT (almost obsolete now) SWT (The Standard Widget Toolkit) Open source from IBM Using native window calls fast response Very much like MFC

4 Swing Components Lightweight vs. heavyweight components: Lightweight: platform independent Heavyweight: tied to platform; windowing system Peer object: object responsible for interactions between heavyweight object and local system Swing components are lightweight

5 A Java Screen Layout Frame JFrame Menu Bar (optional) Content Pane

6 import java.awt.*; import java.awt.event.*; import javax.swing.*; public class FrameDemo public static void main(string s[]) JFrame frame = new JFrame("FrameDemo"); frame.addwindowlistener(new WindowAdapter() public void windowclosing(windowevent e) System.exit(0); ); JLabel mylabel = new JLabel( Hello World"); mylabel.setpreferredsize(new Dimension(175, 100)); frame.getcontentpane().add(mylabel, BorderLayout.CENTER); frame.pack(); frame.setvisible(true); // show() is deprecated

7 Choose Look and Feel Only available under Swing try UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName()); catch (Exception e) Always give me the java look! Ref: available look and feel at

8 The Event Handing Model GUI components are event-driven Programmer must register events implement event handlers Event registration: add listeners Event implementation: define listener methods

9 3 Steps for an Event Handler 1. either implements a listener interface or extends a class that implements a listener interface public class MyClass implements ActionListener 2. Register your listener somecomponent. addactionlistener(instanceofmyclass); 3. Implement user action public void actionperformed(actionevent e)...//code that reacts to the action...

10 Example: Registering Events public class TextFieldTest extends JFrame private JTextField text1, text2, text3; private JPasswordField password; public TextFieldTest() super( "Testing JTextField and JPasswordField" ); Container c = getcontentpane(); c.setlayout( new FlowLayout() ); // construct textfield with default sizing text1 = new JTextField( 10 ); c.add( text1 ); // construct textfield with default text text2 = new JTextField( "Enter text here" ); c.add( text2 );

11 // construct textfield with default text and // 20 visible elements and no event handler text3 = new JTextField( "Uneditable text field", 20 ); text3.seteditable( false ); c.add( text3 ); // construct textfield with default text password = new JPasswordField( "Hidden text" ); c.add( password ); TextFieldHandler handler = new TextFieldHandler(); text1.addactionlistener( handler ); text2.addactionlistener( handler ); text3.addactionlistener( handler ); password.addactionlistener( handler ); setsize( 325, 100 ); show();

12 Event Registration

13 Listeners for Event Types ActionListener MouseListener MouseMotionListener KeyListener ButtonChangeListener AncestorListener PropertyChangeListener...

14 Example: Handling Events // inner class for event handling private class TextFieldHandler implements ActionListener public void actionperformed( ActionEvent e ) String s = ""; if ( e.getsource() == text1 ) s = "text1: " + e.getactioncommand(); else if ( e.getsource() == text2 ) s = "text2: " + e.getactioncommand(); else if ( e.getsource() == text3 ) s = "text3: " + e.getactioncommand(); else if ( e.getsource() == password ) JPasswordField pwd = (JPasswordField) e.getsource(); s = "password: " + new String( pwd.getpassword() ); JOptionPane.showMessageDialog( null, s );

15 Driver for Example public static void main( String args[] ) TextFieldTest app = new TextFieldTest(); app.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); );

16 Event Handling and Inner Classes Event handler classes are usually private Often event handlers are anonymous inner classes defined purely to implement the handing method: app.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); );

17 GUI Components For example JTextField and JPasswordField JButton JCheckBox and JRadioButton JComboBox JList and Multiple Selection Lists

18 JTextField and JPasswordField

19 JButton public class ButtonTest extends JFrame private JButton plainbutton, fancybutton; public ButtonTest() super( "Testing Buttons" ); Container c = getcontentpane(); c.setlayout( new FlowLayout() ); // create buttons plainbutton = new JButton( "Plain Button" ); c.add( plainbutton );

20 Icon bug1 = new ImageIcon( "bug1.gif" ); Icon bug2 = new ImageIcon( "bug2.gif" ); fancybutton = new JButton( "Fancy Button", bug1 ); fancybutton.setrollovericon( bug2 ); c.add( fancybutton ); // create an instance of inner class ButtonHandler // to use for button event handling ButtonHandler handler = new ButtonHandler(); fancybutton.addactionlistener( handler ); plainbutton.addactionlistener( handler ); setsize( 275, 100 ); show();

21 public static void main( String args[] ) ButtonTest app = new ButtonTest(); app.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); ); // or NEW for ver 1.3 of java 2 // frame.setdefaultcloseoperation(jframe.exit_on_close); // inner class for button event handling private class ButtonHandler implements ActionListener public void actionperformed( ActionEvent e ) JOptionPane.showMessageDialog( null, "You pressed: " + e.getactioncommand() );

22 Event Handling: The Mouse mousepressed mouseclicked mousereleased mouseentered, mouseexited mousedragged mousemoved

23 // Fig : MouseTracker.java // Demonstrating mouse events. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MouseTracker extends JFrame implements MouseListener, MouseMotionListener private JLabel statusbar; public MouseTracker() super( "Demonstrating Mouse Events" ); statusbar = new JLabel(); getcontentpane().add( statusbar, BorderLayout.SOUTH ); // application listens to its own mouse events addmouselistener( this ); addmousemotionlistener( this ); setsize( 275, 100 ); show();

24 // MouseListener event handlers public void mouseclicked( MouseEvent e ) statusbar.settext( "Clicked at [" + e.getx() + ", " + e.gety() + "]" ); public void mousepressed( MouseEvent e ) statusbar.settext( "Pressed at [" + e.getx() + ", " + e.gety() + "]" ); public void mousereleased( MouseEvent e ) statusbar.settext( "Released at [" + e.getx() + ", " + e.gety() + "]" ); public void mouseentered( MouseEvent e ) statusbar.settext( "Mouse in window" ); public void mouseexited( MouseEvent e ) statusbar.settext( "Mouse outside window" );

25 // MouseMotionListener event handlers public void mousedragged( MouseEvent e ) statusbar.settext( "Dragged at [" + e.getx() + ", " + e.gety() + "]" ); public void mousemoved( MouseEvent e ) statusbar.settext( "Moved at [" + e.getx() + ", " + e.gety() + "]" ); public static void main( String args[] ) MouseTracker app = new MouseTracker(); app.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); );

26 Adapter Classes Interfaces with many methods to implement can be cumbersome The adapter class provides a default implementation of all interface methods Application can over-ride interface methods that are of interest

27

28 // Fig : Painter.java // Using class MouseMotionAdapter. import javax.swing.*; import java.awt.event.*; import java.awt.*; public class Painter extends JFrame private int xvalue = -10, yvalue = -10; public Painter() super( "A simple paint program" ); getcontentpane().add( new Label( "Drag the mouse to draw" ), BorderLayout.SOUTH ); addmousemotionlistener( new MouseMotionAdapter() public void mousedragged( MouseEvent e ) xvalue = e.getx(); yvalue = e.gety(); repaint(); ); setsize( 300, 150 ); show(); Inner Class

29 public void paint( Graphics g ) g.filloval( xvalue, yvalue, 4, 4 ); public static void main( String args[] ) Painter app = new Painter(); app.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); );

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

The class JOptionPane (javax.swing) allows you to display a dialog box containing info. showmessagedialog(), showinputdialog()

The class JOptionPane (javax.swing) allows you to display a dialog box containing info. showmessagedialog(), showinputdialog() // Fig. 2.8: Addition.java An addition program import javax.swing.joptionpane; public class Addition public static void main( String args[] ) String firstnumber, secondnumber; int number1, number2, sum;

More information

Providing Information (Accessors)

Providing Information (Accessors) Providing Information (Accessors) C++ allows you to declare a method as const. As a result the compiler warns you if statements in the method change the object s state. Java has no such facility, and so

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

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

GUI Event-Driven Programming

GUI Event-Driven Programming GUI Event-Driven Programming CSE 331 Software Design & Implementation Slides contain content by Hal Perkins and Michael Hotan 1 Outline User events and callbacks Event objects Event listeners Registering

More information

Swing. A Quick Tutorial on Programming Swing Applications

Swing. A Quick Tutorial on Programming Swing Applications Swing A Quick Tutorial on Programming Swing Applications 1 MVC Model View Controller Swing is based on this design pattern It means separating the implementation of an application into layers or components:

More information

GUIs with Swing. Principles of Software Construction: Objects, Design, and Concurrency. Jonathan Aldrich and Charlie Garrod Fall 2012

GUIs with Swing. Principles of Software Construction: Objects, Design, and Concurrency. Jonathan Aldrich and Charlie Garrod Fall 2012 GUIs with Swing Principles of Software Construction: Objects, Design, and Concurrency Jonathan Aldrich and Charlie Garrod Fall 2012 Slides copyright 2012 by Jeffrey Eppinger, Jonathan Aldrich, William

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

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

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

GUI Components: Part 2

GUI Components: Part 2 GUI Components: Part 2 JComboBox and Using an Anonymous Inner Class for Event Handling A combo box (or drop-down list) enables the user to select one item from a list. Combo boxes are implemented with

More information

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

The Abstract Windowing Toolkit. Java Foundation Classes. Swing. In April 1997, JavaSoft announced the Java Foundation Classes (JFC).

The Abstract Windowing Toolkit. Java Foundation Classes. Swing. In April 1997, JavaSoft announced the Java Foundation Classes (JFC). The Abstract Windowing Toolkit Since Java was first released, its user interface facilities have been a significant weakness The Abstract Windowing Toolkit (AWT) was part of the JDK form the beginning,

More information

How To Build A Swing Program In Java.Java.Netbeans.Netcode.Com (For Windows) (For Linux) (Java) (Javax) (Windows) (Powerpoint) (Netbeans) (Sun) (

How To Build A Swing Program In Java.Java.Netbeans.Netcode.Com (For Windows) (For Linux) (Java) (Javax) (Windows) (Powerpoint) (Netbeans) (Sun) ( 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

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

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

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

How to Convert an Application into an Applet.

How to Convert an Application into an Applet. How to Convert an Application into an Applet. A java application contains a main method. An applet is a java program part of a web page and runs within a browser. I am going to show you three different

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

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

Mouse Event Handling (cont.)

Mouse Event Handling (cont.) GUI Components: Part II Mouse Event Handling (cont.) Each mouse event-handling method receives a MouseEvent object that contains information about the mouse event that occurred, including the x- and y-coordinates

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

core 2 Handling Mouse and Keyboard Events

core 2 Handling Mouse and Keyboard Events core Web programming Handling Mouse and Keyboard Events 1 2001-2003 Marty Hall, Larry Brown http:// Agenda General event-handling strategy Handling events with separate listeners Handling events by implementing

More information

How Scala Improved Our Java

How Scala Improved Our Java How Scala Improved Our Java Sam Reid PhET Interactive Simulations University of Colorado http://spot.colorado.edu/~reids/ PhET Interactive Simulations Provides free, open source educational science simulations

More information

Developing GUI Applications: Architectural Patterns Revisited

Developing GUI Applications: Architectural Patterns Revisited Developing GUI Applications: Architectural Patterns Revisited A Survey on MVC, HMVC, and PAC Patterns Alexandros Karagkasidis karagkasidis@gmail.com Abstract. Developing large and complex GUI applications

More information

Callbacks. Callbacks Copyright 2007 by Ken Slonneger 1

Callbacks. Callbacks Copyright 2007 by Ken Slonneger 1 Callbacks Callbacks refer to a mechanism in which a library or utility class provides a service to clients that are unknown to it when it is defined. Suppose, for example, that a server class creates a

More information

Artificial Intelligence. Class: 3 rd

Artificial Intelligence. Class: 3 rd Artificial Intelligence Class: 3 rd Teaching scheme: 4 hours lecture credits: Course description: This subject covers the fundamentals of Artificial Intelligence including programming in logic, knowledge

More information

Tutorial Reference Manual. Java WireFusion 4.1

Tutorial Reference Manual. Java WireFusion 4.1 Tutorial Reference Manual Java WireFusion 4.1 Contents INTRODUCTION...1 About this Manual...2 REQUIREMENTS...3 User Requirements...3 System Requirements...3 SHORTCUTS...4 DEVELOPMENT ENVIRONMENT...5 Menu

More information

Principles of Software Construction: Objects, Design and Concurrency. GUIs with Swing. toad 15-214. Spring 2013

Principles of Software Construction: Objects, Design and Concurrency. GUIs with Swing. toad 15-214. Spring 2013 Principles of Software Construction: Objects, Design and Concurrency GUIs with Swing 15-214 toad Spring 2013 Christian Kästner Charlie Garrod School of Computer Science 2012-13 C Garrod, C Kästner, J Aldrich,

More information

Java Mouse and Keyboard Methods

Java Mouse and Keyboard Methods 7 Java Mouse and Keyboard Methods 7.1 Introduction The previous chapters have discussed the Java programming language. This chapter investigates event-driven programs. Traditional methods of programming

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

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

The Basic Java Applet and JApplet

The Basic Java Applet and JApplet I2PUJ4 - Chapter 6 - Applets, HTML, and GUI s The Basic Java Applet and JApplet Rob Dempster robd@cs.ukzn.ac.za School of Computer Science University of KwaZulu-Natal Pietermaritzburg Campus I2PUJ4 - Chapter

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

public class demo1swing extends JFrame implements ActionListener{

public class demo1swing extends JFrame implements ActionListener{ 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;

More information

Fachbereich Informatik und Elektrotechnik Java Swing. Advanced Java. Java Swing Programming. Programming in Java, Helmut Dispert

Fachbereich Informatik und Elektrotechnik Java Swing. Advanced Java. Java Swing Programming. Programming in Java, Helmut Dispert Java Swing Advanced Java Java Swing Programming Java Swing Design Goals The overall goal for the Swing project was: To build a set of extensible GUI components to enable developersto more rapidly develop

More information

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca

More information

GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT COURSE CURRICULUM COURSE TITLE: ADVANCE JAVA PROGRAMMING (COURSE CODE: 3360701)

GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT COURSE CURRICULUM COURSE TITLE: ADVANCE JAVA PROGRAMMING (COURSE CODE: 3360701) GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT COURSE CURRICULUM COURSE TITLE: ADVANCE JAVA PROGRAMMING (COURSE CODE: 3360701) Diploma Programme in which this course is offered Computer Engineering/

More information

Skills and Topics for TeenCoder: Java Programming

Skills and Topics for TeenCoder: Java Programming Skills and Topics for TeenCoder: Java Programming Our Self-Study Approach Our courses are self-study and can be completed on the student's own computer, at their own pace. You can steer your student in

More information

Essentials of the Java Programming Language

Essentials of the Java Programming Language Essentials of the Java Programming Language A Hands-On Guide by Monica Pawlan 350 East Plumeria Drive San Jose, CA 95134 USA May 2013 Part Number TBD v1.0 Sun Microsystems. Inc. All rights reserved If

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

Lecture VII JAVA SWING GUI TUTORIAL

Lecture VII JAVA SWING GUI TUTORIAL 2. First Step: JFrame Lecture VII Page 1 Lecture VII JAVA SWING GUI TUTORIAL These notes are based on the excellent book, Core Java, Vol 1 by Horstmann and Cornell, chapter 7, graphics programming. Introduction

More information

Java is commonly used for deploying applications across a network. Compiled Java code

Java is commonly used for deploying applications across a network. Compiled Java code Module 5 Introduction to Java/Swing Java is commonly used for deploying applications across a network. Compiled Java code may be distributed to different machine architectures, and a native-code interpreter

More information

@ - Internal # - External @- Online TH PR OR TW TOTAL HOURS 04 --- 04 03 100 50# --- 25@ 175

@ - Internal # - External @- Online TH PR OR TW TOTAL HOURS 04 --- 04 03 100 50# --- 25@ 175 COURSE NAME : COMPUTER ENGINEERING GROUP COURSE CODE SEMESTER SUBJECT TITLE : CO/CM/IF/CD : SIXTH : ADVANCED JAVA PROGRAMMING SUBJECT CODE : Teaching and Examination Scheme: @ - Internal # - External @-

More information

JiST Graphical User Interface Event Viewer. Mark Fong mjf21@cornell.edu

JiST Graphical User Interface Event Viewer. Mark Fong mjf21@cornell.edu JiST Graphical User Interface Event Viewer Mark Fong mjf21@cornell.edu Table of Contents JiST Graphical User Interface Event Viewer...1 Table of Contents...2 Introduction...3 What it does...3 Design...3

More information

Software Design: Figures

Software Design: Figures Software Design: Figures Today ColorPicker Layout Manager Observer Pattern Radio Buttons Prelimiary Discussion Exercise 5 ColorPicker They don't teach you the facts of death, Your mum and dad. They give

More information

How To Write A Program For The Web In Java (Java)

How To Write A Program For The Web In Java (Java) 21 Applets and Web Programming As noted in Chapter 2, although Java is a general purpose programming language that can be used to create almost any type of computer program, much of the excitement surrounding

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

During the process of creating ColorSwitch, you will learn how to do these tasks:

During the process of creating ColorSwitch, you will learn how to do these tasks: GUI Building in NetBeans IDE 3.6 This short tutorial guides you through the process of creating an application called ColorSwitch. You will build a simple program that enables you to switch the color of

More information

Cours de Java. Sciences-U Lyon. Java - Introduction Java - Fondamentaux Java Avancé. http://www.rzo.free.fr

Cours de Java. Sciences-U Lyon. Java - Introduction Java - Fondamentaux Java Avancé. http://www.rzo.free.fr Cours de Java Sciences-U Lyon Java - Introduction Java - Fondamentaux Java Avancé http://www.rzo.free.fr Pierre PARREND 1 Octobre 2004 Sommaire Java Introduction Java Fondamentaux Java Avancé GUI Graphical

More information

Remote Method Invocation

Remote Method Invocation Goal of RMI Remote Method Invocation Implement distributed objects. Have a program running on one machine invoke a method belonging to an object whose execution is performed on another machine. Remote

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

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

Dev Articles 05/25/07 11:07:33

Dev Articles 05/25/07 11:07:33 Java Crawling the Web with Java Contributed by McGraw Hill/Osborne 2005 06 09 Access Your PC from Anywhere Download Your Free Trial Take your office with you, wherever you go with GoToMyPC. It s the remote

More information

Java GUI Programming. Building the GUI for the Microsoft Windows Calculator Lecture 2. Des Traynor 2005

Java GUI Programming. Building the GUI for the Microsoft Windows Calculator Lecture 2. Des Traynor 2005 Java GUI Programming Building the GUI for the Microsoft Windows Calculator Lecture 2 Des Traynor 2005 So, what are we up to Today, we are going to create the GUI for the calculator you all know and love.

More information

Karsten Lentzsch JGoodies SWING WITH STYLE

Karsten Lentzsch JGoodies SWING WITH STYLE Karsten Lentzsch JGoodies SWING WITH STYLE JGoodies: Karsten Lentzsch Open source Swing libraries Example applications Consultant for Java desktop Design assistance Training for visual design and implementation

More information

Assignment # 2: Design Patterns and GUIs

Assignment # 2: Design Patterns and GUIs CSUS COLLEGE OF ENGINEERING AND COMPUTER SCIENCE Department of Computer Science CSc 133 Object-Oriented Computer Graphics Programming Spring 2014 John Clevenger Assignment # 2: Design Patterns and GUIs

More information

Tutorial: Time Of Day Part 2 GUI Design in NetBeans

Tutorial: Time Of Day Part 2 GUI Design in NetBeans Tutorial: Time Of Day Part 2 GUI Design in NetBeans October 7, 2010 Author Goals Kees Hemerik / Gerard Zwaan Getting acquainted with NetBeans GUI Builder Illustrate the separation between GUI and computation

More information

Model-View-Controller (MVC) Design Pattern

Model-View-Controller (MVC) Design Pattern Model-View-Controller (MVC) Design Pattern Computer Science and Engineering College of Engineering The Ohio State University Lecture 23 Motivation Basic parts of any application: Data being manipulated

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

Here's the code for our first Applet which will display 'I love Java' as a message in a Web page

Here's the code for our first Applet which will display 'I love Java' as a message in a Web page Create a Java Applet Those of you who purchased my latest book, Learn to Program with Java, know that in the book, we create a Java program designed to calculate grades for the English, Math and Science

More information

Programação Orientada a Objetos. Programando Interfaces Gráficas Orientadas a Objeto Parte 2

Programação Orientada a Objetos. Programando Interfaces Gráficas Orientadas a Objeto Parte 2 Programação Orientada a Objetos Programando Interfaces Gráficas Orientadas a Objeto Parte 2 Paulo André Castro CES-22 IEC - ITA Sumário Programando Interfaces Gráficas Orientadas a Objeto - Parte 2 2.2.1

More information

Syllabus. Java programs for creating applets for display of images, text and animation. Input output and random files programs in java

Syllabus. Java programs for creating applets for display of images, text and animation. Input output and random files programs in java WEB DEVELOPMENT LAB Syllabus Java programs using classes &objects and various control constructs such as loops etc, and structure such as arrays, structures and functions. Java programs for creating applets

More information

Syllabus for CS 134 Java Programming

Syllabus for CS 134 Java Programming - Java Programming Syllabus Page 1 Syllabus for CS 134 Java Programming Computer Science Course Catalog 2000-2001: This course is an introduction to objectoriented programming using the Java language.

More information

Event processing in Java: what happens when you click?

Event processing in Java: what happens when you click? Event processing in Java: what happens when you click? Alan Dix In the HCI book chapter 8 (fig 8.5, p. 298), notification-based user interface programming is described. Java uses this paradigm and you

More information

method is never called because it is automatically called by the window manager. An example of overriding the paint() method in an Applet follows:

method is never called because it is automatically called by the window manager. An example of overriding the paint() method in an Applet follows: Applets - Java Programming for the Web An applet is a Java program designed to run in a Java-enabled browser or an applet viewer. In a browser, an applet is called into execution when the APPLET HTML tag

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

Analysis Of Source Lines Of Code(SLOC) Metric

Analysis Of Source Lines Of Code(SLOC) Metric Analysis Of Source Lines Of Code(SLOC) Metric Kaushal Bhatt 1, Vinit Tarey 2, Pushpraj Patel 3 1,2,3 Kaushal Bhatt MITS,Datana Ujjain 1 kaushalbhatt15@gmail.com 2 vinit.tarey@gmail.com 3 pushpraj.patel@yahoo.co.in

More information

JIDE Action Framework Developer Guide

JIDE Action Framework Developer Guide JIDE Action Framework Developer Guide Contents PURPOSE OF THIS DOCUMENT... 1 WHAT IS JIDE ACTION FRAMEWORK... 1 PACKAGES... 3 MIGRATING FROM EXISTING APPLICATIONS... 3 DOCKABLEBARMANAGER... 9 DOCKABLE

More information

Twin A Design Pattern for Modeling Multiple Inheritance

Twin A Design Pattern for Modeling Multiple Inheritance Twin A Design Pattern for Modeling Multiple Inheritance Hanspeter Mössenböck University of Linz, Institute of Practical Computer Science, A-4040 Linz moessenboeck@ssw.uni-linz.ac.at Abstract. We introduce

More information

Lab 1A. Create a simple Java application using JBuilder. Part 1: make the simplest Java application Hello World 1. Start Jbuilder. 2.

Lab 1A. Create a simple Java application using JBuilder. Part 1: make the simplest Java application Hello World 1. Start Jbuilder. 2. Lab 1A. Create a simple Java application using JBuilder In this lab exercise, we ll learn how to use a Java integrated development environment (IDE), Borland JBuilder 2005, to develop a simple Java application

More information

Automated Data Collection for Usability Evaluation in Early Stages of Application Development

Automated Data Collection for Usability Evaluation in Early Stages of Application Development Automated Data Collection for Usability Evaluation in Early Stages of Application Development YONGLEI TAO School of Computing and Information Systems Grand Valley State University Allendale, MI 49401 USA

More information

Course/Year W080/807 Expected Solution Subject: Software Development to Question No: 1

Course/Year W080/807 Expected Solution Subject: Software Development to Question No: 1 Subject: Software Development to Question No: 1 Page 1 of 2 Allocation: 33 marks (a) (i) A layout manager is an object that implements the LayoutManager interface and determines the size and position of

More information

Handout 3 cs180 - Programming Fundamentals Spring 15 Page 1 of 6. Handout 3. Strings and String Class. Input/Output with JOptionPane.

Handout 3 cs180 - Programming Fundamentals Spring 15 Page 1 of 6. Handout 3. Strings and String Class. Input/Output with JOptionPane. Handout 3 cs180 - Programming Fundamentals Spring 15 Page 1 of 6 Handout 3 Strings and String Class. Input/Output with JOptionPane. Strings In Java strings are represented with a class type String. Examples:

More information

Platform-Specific Event Handling

Platform-Specific Event Handling In this appendix: The Results Test Program C Platform-Specific Event Handling My life with Java began in September of 1995. I started on a Sun Sparc20 and have since used Java on Windows 95, Windows NT

More information

Eclipse with Mac OSX Getting Started Selecting Your Workspace. Creating a Project.

Eclipse with Mac OSX Getting Started Selecting Your Workspace. Creating a Project. Eclipse with Mac OSX Java developers have quickly made Eclipse one of the most popular Java coding tools on Mac OS X. But although Eclipse is a comfortable tool to use every day once you know it, it is

More information

Example 1: Creating Jframe. Example 2: CenterFrame. Jaeki Song, Ph.D. Box 42101 Lubbock, TX, 79409-2101 PH: 806 784 0435 jsong@ba.ttu.

Example 1: Creating Jframe. Example 2: CenterFrame. Jaeki Song, Ph.D. Box 42101 Lubbock, TX, 79409-2101 PH: 806 784 0435 jsong@ba.ttu. Example 1: Creating Jframe import javax.swing.*; public class MyFrame public static void main(string[] args) JFrame frame = new JFrame("Test Frame"); frame.setsize(400, 300); frame.setvisible(true); frame.setdefaultcloseoperation(

More information

Lab 9. Spam, Spam, Spam. Handout 11 CSCI 134: Spring, 2015. To gain experience with Strings. Objective

Lab 9. Spam, Spam, Spam. Handout 11 CSCI 134: Spring, 2015. To gain experience with Strings. Objective Lab 9 Handout 11 CSCI 134: Spring, 2015 Spam, Spam, Spam Objective To gain experience with Strings. Before the mid-90s, Spam was a canned meat product. These days, the term spam means just one thing unwanted

More information

public class Application extends JFrame implements ChangeListener, WindowListener, MouseListener, MouseMotionListener {

public class Application extends JFrame implements ChangeListener, WindowListener, MouseListener, MouseMotionListener { Application.java import javax.swing.*; import java.awt.geom.*; import java.awt.event.*; import javax.swing.event.*; import java.util.*; public class Application extends JFrame implements ChangeListener,

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

Summer Internship 2013

Summer Internship 2013 Summer Internship 2013 Group IV - Enhancement of Jmeter Week 4 Report 1 9 th June 2013 Shekhar Saurav Report on Configuration Element Plugin 'SMTP Defaults' Configuration Elements or config elements are

More information

Tutorial : Getting started with the Java TM Media Framework

Tutorial : Getting started with the Java TM Media Framework Tutorial : Getting started with the Java TM Media Framework With the growth of Internet there has been a radical change in the method of software design and deployment. Software applications are becoming

More information

11. Applets, normal window applications, packaging and sharing your work

11. Applets, normal window applications, packaging and sharing your work 11. Applets, normal window applications, packaging and sharing your work In this chapter Converting Full Screen experiments into normal window applications, Packaging and sharing applications packaging

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

Illustration 1: An applet showing constructed responses in an intuitive mode. Note the misprint!

Illustration 1: An applet showing constructed responses in an intuitive mode. Note the misprint! Applets in Java using NetBeans as an IDE (Part 1) C.W. David Department of Chemistry University of Connecticut Storrs, CT 06269-3060 Carl.David@uconn.edu We are interested in creating a teaching/testing

More information

GOPAL RAMALINGAM MEMORIAL ENGINEERING COLLEGE. Rajeshwari nagar, Panapakkam, Near Padappai, Chennai-601301.

GOPAL RAMALINGAM MEMORIAL ENGINEERING COLLEGE. Rajeshwari nagar, Panapakkam, Near Padappai, Chennai-601301. GOPAL RAMALINGAM MEMORIAL ENGINEERING COLLEGE Rajeshwari nagar, Panapakkam, Near Padappai, Chennai-601301. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING OOAD LAB MANUAL Sub. Code/Sub. Name: CS2357-Object

More information

Konzepte objektorientierter Programmierung

Konzepte objektorientierter Programmierung Konzepte objektorientierter Programmierung Prof. Dr. Peter Müller Werner Dietl Software Component Technology Exercises 5: Frameworks Wintersemester 05/06 2 Homework 1 Observer Pattern From: Gamma, Helm,

More information

Object Oriented Programming with Java. School of Computer Science University of KwaZulu-Natal

Object Oriented Programming with Java. School of Computer Science University of KwaZulu-Natal Object Oriented Programming with Java School of Computer Science University of KwaZulu-Natal January 30, 2006 2 Object Oriented Programming with Java Notes for the Computer Science Module Object Oriented

More information

Demo: Embedding Windows Presentation Foundation elements inside a Java GUI application. Version 7.3

Demo: Embedding Windows Presentation Foundation elements inside a Java GUI application. Version 7.3 Demo: Embedding Windows Presentation Foundation elements inside a Java GUI application Version 7.3 JNBridge, LLC www.jnbridge.com COPYRIGHT 2002 2015 JNBridge, LLC. All rights reserved. JNBridge is a registered

More information

Nexawebホワイトペーパー. Developing with Nexaweb ~ Nexaweb to Improve Development Productivity and Maintainability

Nexawebホワイトペーパー. Developing with Nexaweb ~ Nexaweb to Improve Development Productivity and Maintainability Nexawebホワイトペーパー Developing with Nexaweb ~ Nexaweb to Improve Development Productivity and Maintainability Nexaweb Technologies, Inc. February 2012 Overview Many companies today are creating rich internet

More information

Introduction to Object-Oriented Programming

Introduction to Object-Oriented Programming Introduction to Object-Oriented Programming Programs and Methods Christopher Simpkins chris.simpkins@gatech.edu CS 1331 (Georgia Tech) Programs and Methods 1 / 8 The Anatomy of a Java Program It is customary

More information

16.1 DataFlavor. 16.1.1 DataFlavor Methods. Variables

16.1 DataFlavor. 16.1.1 DataFlavor Methods. Variables In this chapter: DataFlavor Transferable Interface ClipboardOwner Interface Clipboard StringSelection UnsupportedFlavorException Reading and Writing the Clipboard 16 Data Transfer One feature that was

More information

VAASAN AMMATTIKORKEAKOULU UNIVERSITY OF APPLIED SCIENCES. Xiaoling Yu IMPLEMENTATION OF A SECURE SHELL FILE TRANSFER PROGRAM IN JAVA

VAASAN AMMATTIKORKEAKOULU UNIVERSITY OF APPLIED SCIENCES. Xiaoling Yu IMPLEMENTATION OF A SECURE SHELL FILE TRANSFER PROGRAM IN JAVA VAASAN AMMATTIKORKEAKOULU UNIVERSITY OF APPLIED SCIENCES Xiaoling Yu IMPLEMENTATION OF A SECURE SHELL FILE TRANSFER PROGRAM IN JAVA Information Technology 2010 2 FOREWORD First of all, I would like to

More information

1 Hour, Closed Notes, Browser open to Java API docs is OK

1 Hour, Closed Notes, Browser open to Java API docs is OK CSCI 143 Exam 2 Name 1 Hour, Closed Notes, Browser open to Java API docs is OK A. Short Answer For questions 1 5 credit will only be given for a correct answer. Put each answer on the appropriate line.

More information

How To Use The Command Pattern In Java.Com (Programming) To Create A Program That Is Atomic And Is Not A Command Pattern (Programmer)

How To Use The Command Pattern In Java.Com (Programming) To Create A Program That Is Atomic And Is Not A Command Pattern (Programmer) CS 342: Object-Oriented Software Development Lab Command Pattern and Combinations David L. Levine Christopher D. Gill Department of Computer Science Washington University, St. Louis levine,cdgill@cs.wustl.edu

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

Implementação. Interfaces Pessoa Máquina 2010/11. 2009-11 Salvador Abreu baseado em material Alan Dix. Thursday, June 2, 2011

Implementação. Interfaces Pessoa Máquina 2010/11. 2009-11 Salvador Abreu baseado em material Alan Dix. Thursday, June 2, 2011 Implementação Interfaces Pessoa Máquina 2010/11 2009-11 baseado em material Alan Dix 1 Windowing systems Architecture Layers Higher level Tool UI Toolkit (Widgets) Window System OS Application Hardware

More information

java.applet Reference

java.applet Reference 18 In this chapter: Introduction to the Reference Chapters Package diagrams java.applet Reference Introduction to the Reference Chapters The preceding seventeen chapters cover just about all there is to

More information

The following four software tools are needed to learn to program in Java:

The following four software tools are needed to learn to program in Java: Getting Started In this section, we ll see Java in action. Some demo programs will highlight key features of Java. Since we re just getting started, these programs are intended only to pique your interest.

More information