Programmierpraktikum
|
|
- Barnard Hunter
- 6 years ago
- Views:
Transcription
1 Programmierpraktikum Claudius Gros, SS2012 Institut für theoretische Physik Goethe-University Frankfurt a.m. 1 of 18 17/01/13 11:46
2 Java Applets 2 of 18 17/01/13 11:46
3 Java applets embedding Java applications into webpages simulations, tutorials, web interfaces applet example copy Java code to file AppletDrawingLines.java run the Java compiler javac AppletDrawingLines copy html code to file anything.html open the html file with a browser firefox anything.html, sometimes you need a reload import javax.swing.*; // for JApplet,.. import java.awt.*; // for Color import java.util.*; // for sleeping /** Java applet example based on Japplet. 3 of 18 17/01/13 11:46
4 * Has no main() function, init() executed before paint(). public class AppletDrawingLines extends JApplet { int width, height; public void init() { width = getsize().width; height = getsize().height; setbackground(color.black); // size of the html applet box // executed when the applet starts // getsize() is a member function of JApplet // returning the size of the html applet box /** The.pain() function is executed whenever the applet is * asked to redraw itself. public void paint(graphics g) { g.setcolor(color.green); for (int i=0; i<10; i++) { g.drawline(width, height, i * width / 10, 0); // drawline(x-start,y-start,x-end,y-end) try { 28. Thread.sleep(700); // sleep for a short time 4 of 18 17/01/13 11:46
5 catch (InterruptedException e) { System.out.println(e.toString()); // end of loop over drawing lines // end of AppletDrawingLines.paint() // end of AppletDrawingLines html code for embedding applet html tags are like brackets: <center>...</center> <html> <head> <meta charset="utf8" /> <title>java applets</title> </head> <!-- this is a comment: a html page has a header and a body --> <body> <center> <h1>embedded Java applet</hr> <br><br> <applet width=400 height=400 code="appletdrawinglines.class"> </applet> </center> </body> </html> 5 of 18 17/01/13 11:46
6 Mouse events here Applet instead of JApplet and java.awt instead of javax.swing the interfaces MouseListener and MouseMotionListener are implemented, all their member functions need to be explicitly declared, even when void import java.applet.*; // this example with Applet instead of JApplet import java.awt.*; import java.awt.event.*; public class AppletMouseFollow extends Applet implements MouseListener, MouseMotionListener { int width, height; // size of html applet box int mx, my; // the mouse coordinates boolean isbuttonpressed = false; public void init() { 6 of 18 17/01/13 11:46
7 width = getsize().width; height = getsize().height; setbackground(color.black); mx = width/2; // starting position of my = height/2; // square addmouselistener( this ); // adding event listeners addmousemotionlistener( this ); /** Called when the pointer enters the applet's box. * All functions of the implemented interfaces * MouseListener and MouseMotionListener need to be implemented. public void mouseentered( MouseEvent e ) { setbackground(color.blue); public void mouseexited( MouseEvent e ) { setbackground(color.orange); /** Called after a press and release of a mouse button * with no motion in between. 7 of 18 17/01/13 11:46
8 * If the user presses, drags, and then releases, * there will be no click event generated. public void mouseclicked( MouseEvent e ) { setbackground(color.cyan); /** Called when mouse down but not released. public void mousepressed( MouseEvent e ) { isbuttonpressed = true; setbackground(color.gray); repaint(); // re // "Consume" the event so it won't be processed in the // default manner by the source which generated it. e.consume(); /** Called when released after drag. public void mousereleased( MouseEvent e ) { isbuttonpressed = false; setbackground(color.black); repaint(); e.consume(); 8 of 18 17/01/13 11:46
9 /** Called during motion when no buttons are down. public void mousemoved( MouseEvent e ) { mx = e.getx(); // the mouse events provides the current my = e.gety(); // mouse position showstatus( "Mouse at (" + mx + "," + my + ")" ); // browser status line repaint(); // calls the paint() method e.consume(); /** Called during motion with buttons down. public void mousedragged( MouseEvent e ) { mx = e.getx(); my = e.gety(); showstatus( "Mouse at (" + mx + "," + my + ")" ); repaint(); e.consume(); public void paint( Graphics g ) { if (isbuttonpressed) g.setcolor(color.black); // black rectangle if moused down 9 of 18 17/01/13 11:46
10 else g.setcolor(color.gray); // gray otherwise 84. // 85. g.fillrect(mx-20, my-20, 40, 40); // filled and centered rectangle // end of AppletMouseFollow 10 of 18 17/01/13 11:46
11 Bouncing with and without threads try to to change speed while bouncing double buffering for professional applications, avoiding flickering: paint first everything offscreen and then upload full graphics (not done here) import java.awt.*; import java.awt.event.*; import java.applet.applet; /** A class can extend only a single parent class * but it can implement any number of interfaces. public class AppletBounce extends Applet implements ActionListener, AdjustmentListener, Runnable { private int width, height; // width, height of applet box private int tick = 100; // length of pausini, speed control private int initialy = 70; // bouncing between these 11 of 18 17/01/13 11:46
12 14. private int lowesty; // two values private Button gothreaded = new Button("go threaded"); private Button gonotthreaded = new Button("go not threaded"); private Scrollbar speed = new Scrollbar(Scrollbar.HORIZONTAL,tick,30,20,400); /** Called when applet is loaded. public void init() { setbackground(new Color(230,230,230)); 25. width = getsize().width; height = getsize().height; lowesty = (int)(height*0.8); // --- select layout manager // use relative units 30. setlayout(new BorderLayout()); // a layout manger Panel buttons = new Panel(); // a seperate panel for the buttons // --- button for starting animation with current thread gonotthreaded.setbackground(color.lightgray); gonotthreaded.addactionlistener(this); buttons.add(gonotthreaded); 12 of 18 17/01/13 11:46
13 // --- button for starting animation in an additional thread gothreaded.setbackground(color.lightgray); gothreaded.addactionlistener(this); buttons.add(gothreaded); add("north", buttons); // add both bottoms to the top // --- the Scrollbar 'speed' is inside the Panel 'speedcontrol' Panel speedcontrol = new Panel(); speedcontrol.setbackground(color.lightgray); speed.setpreferredsize(new Dimension((int)(width*0.6),20)); speedcontrol.add(new Label("faster",Label.RIGHT)); speedcontrol.add(speed); speed.addadjustmentlistener(this); speedcontrol.add(new Label("slower")); add("south", speedcontrol); // add the speed-control bar to the bottom 54. // end of AppletBounce.init() /** Catch scrollbar event. public void adjustmentvaluechanged(adjustmentevent e) { tick = speed.getvalue(); 13 of 18 17/01/13 11:46
14 /** Catch button events. public void actionperformed(actionevent e) { if (e.getsource() == gothreaded) // the new Thread calls run() new Thread(this).start(); // running the object 'this' 67. if (e.getsource() == gonotthreaded) // calling directly 68. doanimation(); // doanimation() /** AppletBounce is implementing runnable and run() is * called when a new thread is started. public void run() { doanimation(); /** Let a ball at random position x bounce downwards * and upwards, with increasing speed (step). public void doanimation() { // --- setup of bounds 14 of 18 17/01/13 11:46
15 int minx = (int)(width*0.1); // allways use int maxx = (int)(width*0.9); // relative units int x = (int)(minx+math.random()*(maxx-minx)); // fixed random x for bouncing int y = initialy; // variable y of bouncing int step = 1; // (in)decrement for y // --- setup of graphics Graphics g = getgraphics(); Color background = getbackground(); // needed for repainting g.setcolor(color.black); g.drawline(minx, lowesty+20, // bottom line maxx, lowesty+20); // --- bouncing downwards while (y <= lowesty) { g.filloval(x, y, 20, 20); // paint ball pause(tick); // pause animation method g.setcolor(background); g.filloval(x, y, 20, 20); // turn ball to background g.setcolor(color.black); y = y+step; step++; 15 of 18 17/01/13 11:46
16 // --- hitting bottom g.setcolor(new Color(204,51,51)); g.filloval(x, lowesty, 20, 15); // extra image for lowest point g.drawstring("boing!",x-10,lowesty+35); // its 'boing' pause(tick*3); // pause for reading g.setcolor(background); g.drawstring("boing!",x-10,lowesty+35); g.filloval(x, lowesty, 20, 15); // erase the extra squeeze ball // --- bouncing upwards g.setcolor(color.black); while (step>0) { step--; y = y-step; g.filloval(x, y, 20, 20); pause(tick); g.setcolor(background); g.filloval(x, y, 20, 20); g.setcolor(color.black); // end of AppletBounce.doAnimation() of 18 17/01/13 11:46
17 129. /** Just a wrapper for the exception capture private void pause(int pauselength) { try { Thread.sleep(pauseLength); catch (InterruptedException e) { // end of AppletBounce 17 of 18 17/01/13 11:46
18 What to do with applets? physics / science simulations - visualization 1D quantum wave packet scattering one / two player collision game Conway's Game of Life... interaction web-based GUI (graphical user interface) web-based user-user interactions (maps, chat, mail,...) browser games 18 of 18 17/01/13 11:46
Applet which displays a simulated trackball in the upper half of its window.
Example: Applet which displays a simulated trackball in the upper half of its window. By dragging the trackball using the mouse, you change its state, given by its x-y position relative to the window boundaries,
More informationOBJECT ORIENTED PROGRAMMING. Course 8 Loredana STANCIU Room B613
OBJECT ORIENTED PROGRAMMING Course 8 Loredana STANCIU loredana.stanciu@upt.ro Room B613 Applets A program written in the Java programming language that can be included in an HTML page A special kind of
More informationpublic void mouseexited (MouseEvent e) setminute(getminute()+increment); 11.2 public void mouseclicked (MouseEvent e) int x = e.getx(), y = e.gety();
11 The Jav aawt Part I: Mouse Events 11.1 public void mouseentered (MouseEvent e) setminute(getminute()+increment); 53 public void mouseexited (MouseEvent e) setminute(getminute()+increment); 11.2 public
More informationG51PRG: Introduction to Programming Second semester Applets and graphics
G51PRG: Introduction to Programming Second semester Applets and graphics Natasha Alechina School of Computer Science & IT nza@cs.nott.ac.uk Previous two lectures AWT and Swing Creating components and putting
More information(listener)... MouseListener, ActionLister. (adapter)... MouseAdapter, ActionAdapter. java.awt AWT Abstract Window Toolkit GUI
51 6!! GUI(Graphical User Interface) java.awt javax.swing (component) GUI... (container) (listener)... MouseListener, ActionLister (adapter)... MouseAdapter, ActionAdapter 6.1 GUI(Graphics User Interface
More informationJava Mouse Actions. C&G criteria: 5.2.1, 5.4.1, 5.4.2,
Java Mouse Actions C&G criteria: 5.2.1, 5.4.1, 5.4.2, 5.6.2. The events so far have depended on creating Objects and detecting when they receive the event. The position of the mouse on the screen can also
More informationAn applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a
CBOP3203 An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a page. When you use a Java technology-enabled
More informationCSIS 10A Assignment 14 SOLUTIONS
CSIS 10A Assignment 14 SOLUTIONS Read: Chapter 14 Choose and complete any 10 points from the problems below, which are all included in the download file on the website. Use BlueJ to complete the assignment,
More informationPESIT Bangalore South Campus
INTERNAL ASSESSMENT TEST II Date : 20-09-2016 Max Marks: 50 Subject & Code: JAVA & J2EE (10IS752) Section : A & B Name of faculty: Sreenath M V Time : 8.30-10.00 AM Note: Answer all five questions 1) a)
More informationModule 5 Applets About Applets Hierarchy of Applet Life Cycle of an Applet
About Applets Module 5 Applets An applet is a little application. Prior to the World Wide Web, the built-in writing and drawing programs that came with Windows were sometimes called "applets." On the Web,
More informationVirtualians.ning.pk. 2 - Java program code is compiled into form called 1. Machine code 2. native Code 3. Byte Code (From Lectuer # 2) 4.
1 - What if the main method is declared as private? 1. The program does not compile 2. The program compiles but does not run 3. The program compiles and runs properly ( From Lectuer # 2) 4. The program
More informationAP Computer Science Unit 13. Still More Graphics and Animation.
AP Computer Science Unit 13. Still More Graphics and Animation. In this unit you ll learn about the following: Mouse Motion Listener Suggestions for designing better graphical programs Simple game with
More informationOOP Assignment V. For example, the scrolling text (moving banner) problem without a thread looks like:
OOP Assignment V If we don t use multithreading, or a timer, and update the contents of the applet continuously by calling the repaint() method, the processor has to update frames at a blinding rate. Too
More informationAdvanced Java Unit 6: Review of Graphics and Events
Advanced Java Unit 6: Review of Graphics and Events This is a review of the basics of writing a java program that has a graphical interface. To keep things simple, all of the graphics programs will follow
More informationUser interfaces and Swing
User interfaces and Swing Overview, applets, drawing, action listening, layout managers. APIs: java.awt.*, javax.swing.*, classes names start with a J. Java Lectures 1 2 Applets public class Simple extends
More informationCome & Join Us at VUSTUDENTS.net
Come & Join Us at VUSTUDENTS.net For Assignment Solution, GDB, Online Quizzes, Helping Study material, Past Solved Papers, Solved MCQs, Current Papers, E-Books & more. Go to http://www.vustudents.net and
More informationMethod Of Key Event Key Listener must implement three methods, keypressed(), keyreleased() & keytyped(). 1) keypressed() : will run whenever a key is
INDEX Event Handling. Key Event. Methods Of Key Event. Example Of Key Event. Mouse Event. Method Of Mouse Event. Mouse Motion Listener. Example of Mouse Event. Event Handling One of the key concept in
More informationEvent Driven Programming
Event Driven Programming 1. Objectives... 2 2. Definitions... 2 3. Event-Driven Style of Programming... 2 4. Event Polling Model... 3 5. Java's Event Delegation Model... 5 6. How to Implement an Event
More informationWhich of the following syntax used to attach an input stream to console?
Which of the following syntax used to attach an input stream to console? FileReader fr = new FileReader( input.txt ); FileReader fr = new FileReader(FileDescriptor.in); FileReader fr = new FileReader(FileDescriptor);
More informationAP CS Unit 12: Drawing and Mouse Events
AP CS Unit 12: Drawing and Mouse Events A JPanel object can be used as a container for other objects. It can also be used as an object that we can draw on. The first example demonstrates how to do that.
More informationProgrammierpraktikum
Programmierpraktikum Claudius Gros, SS2012 Institut für theoretische Physik Goethe-University Frankfurt a.m. 1 of 25 17/01/13 11:45 Swing Graphical User Interface (GUI) 2 of 25 17/01/13 11:45 Graphical
More informationOverview. Applets. A Java GUI inside your browser! Important methods Drawing images Playing audio Getting input parameters Double buffering
Java Applets don't panic about frogs!
More informationRobotPlanning.java Page 1
RobotPlanning.java Page 1 import java.awt.*; import java.awt.event.*; import java.awt.image.*; import javax.swing.*; import javax.swing.border.*; import java.util.*; * * RobotPlanning - 1030 GUI Demonstration.
More informationChapter 1 GUI Applications
Chapter 1 GUI Applications 1. GUI Applications So far we've seen GUI programs only in the context of Applets. But we can have GUI applications too. A GUI application will not have any of the security limitations
More informationThe AWT Event Model 9
The AWT Event Model 9 Course Map This module covers the event-based GUI user input mechanism. Getting Started The Java Programming Language Basics Identifiers, Keywords, and Types Expressions and Flow
More informationUNIT-3 : MULTI THREADED PROGRAMMING, EVENT HANDLING. A Multithreaded program contains two or more parts that can run concurrently.
UNIT-3 : MULTI THREADED PROGRAMMING, EVENT HANDLING 1. What are Threads? A thread is a single path of execution of code in a program. A Multithreaded program contains two or more parts that can run concurrently.
More informationCSD Univ. of Crete Fall Java Applets
Java Applets 1 Applets An applet is a Panel that allows interaction with a Java program Typically embedded in a Web page and can be run from a browser You need special HTML in the Web page to tell the
More information11/7/12. Discussion of Roulette Assignment. Objectives. Compiler s Names of Classes. GUI Review. Window Events
Objectives Event Handling Animation Discussion of Roulette Assignment How easy/difficult to refactor for extensibility? Was it easier to add to your refactored code? Ø What would your refactored classes
More informationLecture 5: Java Graphics
Lecture 5: Java Graphics CS 62 Spring 2019 William Devanny & Alexandra Papoutsaki 1 New Unit Overview Graphical User Interfaces (GUI) Components, e.g., JButton, JTextField, JSlider, JChooser, Containers,
More informationChapter 7 Applets. Answers
Chapter 7 Applets Answers 1. D The drawoval(x, y, width, height) method of graphics draws an empty oval within a bounding box, and accepts 4 int parameters. The x and y coordinates of the left/top point
More informationQuestion 1. Show the steps that are involved in sorting the string SORTME using the quicksort algorithm given below.
Name: 1.124 Quiz 2 Thursday November 9, 2000 Time: 1 hour 20 minutes Answer all questions. All questions carry equal marks. Question 1. Show the steps that are involved in sorting the string SORTME using
More informationCSC 551: Web Programming. Fall 2001
CSC 551: Web Programming Fall 2001 Java Applets! applets & HTML "default methods (init, paint, ) "APPLET & OBJECT tags, applet parameters & dimensions! graphical applets "Graphics object: drawstring, drawline,
More informationLecture 3: Java Graphics & Events
Lecture 3: Java Graphics & Events CS 62 Fall 2017 Kim Bruce & Alexandra Papoutsaki Text Input Scanner class Constructor: myscanner = new Scanner(System.in); can use file instead of System.in new Scanner(new
More informationLab 10: Inheritance (I)
CS2370.03 Java Programming Spring 2005 Dr. Zhizhang Shen Background Lab 10: Inheritance (I) In this lab, we will try to understand the concept of inheritance, and its relation to polymorphism, better;
More informationCS2110. GUIS: Listening to Events
CS2110. GUIS: Listening to Events Also anonymous classes Download the demo zip file from course website and look at the demos of GUI things: sliders, scroll bars, combobox listener, etc 1 mainbox boardbox
More informationCS 106A, Lecture 14 Events and Instance Variables
CS 106A, Lecture 14 Events and Instance Variables Reading: Art & Science of Java, Ch. 10.1-10.4 This document is copyright (C) Stanford Computer Science and Marty Stepp, licensed under Creative Commons
More informationAdvanced Internet Programming CSY3020
Advanced Internet Programming CSY3020 Java Applets The three Java Applet examples produce a very rudimentary drawing applet. An Applet is compiled Java which is normally run within a browser. Java applets
More informationJava - Applets. public class Buttons extends Applet implements ActionListener
Java - Applets Java code here will not use swing but will support the 1.1 event model. Legacy code from the 1.0 event model will not be used. This code sets up a button to be pushed: import java.applet.*;
More informationCS 106A, Lecture 14 Events and Instance Variables
CS 106A, Lecture 14 Events and Instance Variables Reading: Art & Science of Java, Ch. 10.1-10.4 This document is copyright (C) Stanford Computer Science and Marty Stepp, licensed under Creative Commons
More informationCS 201 Advanced Object-Oriented Programming Lab 10 - Recursion Due: April 21/22, 11:30 PM
CS 201 Advanced Object-Oriented Programming Lab 10 - Recursion Due: April 21/22, 11:30 PM Introduction to the Assignment In this assignment, you will get practice with recursion. There are three parts
More informationJava - Dates and Threads
Java - Dates and Threads Thread example Java uses threads to allow 1 event to break into another. If an action is to occur a number of times with a loop or to occur until some condition is satisfied then
More informationJava - Applets. C&G criteria: 1.2.2, 1.2.3, 1.2.4, 1.3.4, 1.2.4, 1.3.4, 1.3.5, 2.2.5, 2.4.5, 5.1.2, 5.2.1,
Java - Applets C&G criteria: 1.2.2, 1.2.3, 1.2.4, 1.3.4, 1.2.4, 1.3.4, 1.3.5, 2.2.5, 2.4.5, 5.1.2, 5.2.1, 5.3.2. Java is not confined to a DOS environment. It can run with buttons and boxes in a Windows
More information2IS45 Programming
Course Website Assignment Goals 2IS45 Programming http://www.win.tue.nl/~wsinswan/programmeren_2is45/ Rectangles Learn to use existing Abstract Data Types based on their contract (class Rectangle in Rectangle.
More informationJava. GUI building with the AWT
Java GUI building with the AWT AWT (Abstract Window Toolkit) Present in all Java implementations Described in most Java textbooks Adequate for many applications Uses the controls defined by your OS therefore
More informationComputer Science 210: Data Structures. Intro to Java Graphics
Computer Science 210: Data Structures Intro to Java Graphics Summary Today GUIs in Java using Swing in-class: a Scribbler program READING: browse Java online Docs, Swing tutorials GUIs in Java Java comes
More informationGUI in Java TalentHome Solutions
GUI in Java TalentHome Solutions AWT Stands for Abstract Window Toolkit API to develop GUI in java Has some predefined components Platform Dependent Heavy weight To use AWT, import java.awt.* Calculator
More informationProgramming: You will have 6 files all need to be located in the dir. named PA4:
PROGRAMMING ASSIGNMENT 4: Read Savitch: Chapter 7 and class notes Programming: You will have 6 files all need to be located in the dir. named PA4: PA4.java ShapeP4.java PointP4.java CircleP4.java RectangleP4.java
More informationAdvanced Java Programming
Advanced Java Programming Shmulik London Lecture #5 GUI Programming Part I AWT & Basics Advanced Java Programming / Shmulik London 2006 Interdisciplinary Center Herzeliza Israel 1 Agenda AWT & Swing AWT
More informationGUI Event Handling 11. GUI Event Handling. Objectives. What is an Event? Hierarchical Model (JDK1.0) Delegation Model (JDK1.1)
Objectives Write code to handle events that occur in a GUI 11 GUI Event Handling Describe the concept of adapter classes, including how and when to use them Determine the user action that originated the
More informationUsing Methods. Methods that handle events. Mairead Meagher Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics
Using Methods Methods that handle events Produced by: Mairead Meagher Dr. Siobhán Drohan Department of Computing and Mathematics http://www.wit.ie/ Caveat The term function is used in Processing e.g. line(),
More informationComputer Science II - Test 2
Computer Science II - Test 2 Question 1. (15 points) The MouseListener interface requires methods for mouseclicked, mouseentered, mouseexited, mousepressed, and mousereleased. Java s MouseAdapter implements
More informationIntroduction to Java Applets 12
Introduction to Java Applets 12 Course Map This module discusses the support for applets by the JDK, and how applets differ from applications in terms of program form, operating context, and how they are
More informationGraphical User Interfaces 2
Graphical User Interfaces 2 CSCI 136: Fundamentals CSCI 136: Fundamentals of Computer of Science Computer II Science Keith II Vertanen Keith Vertanen Copyright 2011 Extending JFrame Dialog boxes Overview
More informationChapter 14: Applets and More
Chapter 14: Applets and More Starting Out with Java: From Control Structures through Objects Fifth Edition by Tony Gaddis Chapter Topics Chapter 14 discusses the following main topics: Introduction to
More information8/23/2014. Chapter Topics. Introduction to Applets. Introduction to Applets. Introduction to Applets. Applet Limitations. Chapter 14: Applets and More
Chapter 14: Applets and More Starting Out with Java: From Control Structures through Objects Fifth Edition by Tony Gaddis Chapter Topics Chapter 14 discusses the following main topics: Introduction to
More informationIntroduction to the Java T M Language
Introduction to the Java T M Language Jan H. Meinke July 1, 2000 1 Introduction Since its introduction in 1995 Java has become one of the most popular programming language. At first powered by the popularity
More informationGUI 4.1 GUI GUI MouseTest.java import javax.swing.*; import java.awt.*; import java.awt.event.*; /* 1 */
25 4 GUI GUI GUI 4.1 4.1.1 MouseTest.java /* 1 */ public class MouseTest extends JApplet implements MouseListener /* 2 */ { int x=50, y=20; addmouselistener(this); /* 3 */ super.paint(g); /* 4 */ g.drawstring("hello
More informationCSE 331 Software Design and Implementation. Lecture 19 GUI Events
CSE 331 Software Design and Implementation Lecture 19 GUI Events Leah Perlmutter / Summer 2018 Announcements Announcements Quiz 7 due Thursday 8/9 Homework 8 due Thursday 8/9 HW8 has a regression testing
More informationIntroduction. Introduction
Introduction Many Java application use a graphical user interface or GUI (pronounced gooey ). A GUI is a graphical window or windows that provide interaction with the user. GUI s accept input from: the
More informationChapter 14: Applets and More
Chapter 14: Applets and More Starting Out with Java: From Control Structures through Objects Fourth Edition by Tony Gaddis Addison Wesley is an imprint of 2010 Pearson Addison-Wesley. All rights reserved.
More informationNITI NITI I PRIORITET
NITI public class ThreadsTest { public static void main(string args[]) { BytePrinter bp1 = new BytePrinter(); BytePrinter bp2 = new BytePrinter(); BytePrinter bp3 = new BytePrinter(); bp1.start(); bp2.start();
More informationJava Applets. Last Time. Java Applets. Java Applets. First Java Applet. Java Applets. v We created our first Java application
Last Time v We created our first Java application v What are the components of a basic Java application? v What GUI component did we use in the examples? v How do we write to the standard output? v An
More informationINTRODUCTION TO COMPUTER PROGRAMMING. Richard Pierse. Class 9: Writing Java Applets. Introduction
INTRODUCTION TO COMPUTER PROGRAMMING Richard Pierse Class 9: Writing Java Applets Introduction Applets are Java programs that execute within HTML pages. There are three stages to creating a working Java
More informationCommand-Line Applications. GUI Libraries GUI-related classes are defined primarily in the java.awt and the javax.swing packages.
1 CS257 Computer Science I Kevin Sahr, PhD Lecture 14: Graphical User Interfaces Command-Line Applications 2 The programs we've explored thus far have been text-based applications A Java application is
More informationWindows and Events. created originally by Brian Bailey
Windows and Events created originally by Brian Bailey Announcements Review next time Midterm next Friday UI Architecture Applications UI Builders and Runtimes Frameworks Toolkits Windowing System Operating
More informationDay before tests of Java Final test. IDM institution of Bandarawela. Project for department of education
Day before tests of Java Final test. IDM institution of Bandarawela Project for department of education import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Doenets extends JApplet
More informationCSE 331 Software Design & Implementation
CSE 331 Software Design & Implementation Hal Perkins Spring 2017 GUI Event-Driven Programming 1 The plan User events and callbacks Event objects Event listeners Registering listeners to handle events Anonymous
More informationJava Applet Basics. Life cycle of an applet:
Java Applet Basics Applet is a Java program that can be embedded into a web page. It runs inside the web browser and works at client side. Applet is embedded in a HTML page using the APPLET or OBJECT tag
More informationCS2110. GUIS: Listening to Events. Anonymous functions. Anonymous functions. Anonymous functions. Checkers.java. mainbox
CS2110. GUIS: Listening to Events Lunch with instructors: Visit pinned Piazza post. A4 due tonight. Consider taking course S/U (if allowed) to relieve stress. Need a letter grade of C- or better to get
More informationCS2110. GUIS: Listening to Events
CS2110. GUIS: Listening to Events Lunch with instructors: Visit pinned Piazza post. A4 due tonight. Consider taking course S/U (if allowed) to relieve stress. Need a letter grade of C- or better to get
More informationRoad Map. Introduction to Java Applets Review applets that ship with JDK Make our own simple applets
Java Applets Road Map Introduction to Java Applets Review applets that ship with JDK Make our own simple applets Introduce inheritance Introduce the applet environment html needed for applets Reading:
More informationCS2110. GUIS: Listening to Events Also anonymous classes versus Java 8 functions. Anonymous functions. Anonymous functions. Anonymous functions
CS2110. GUIS: Listening to Events Also anonymous classes versus Java 8 functions Lunch with instructors: Visit Piazza pinned post to reserve a place Download demo zip file from course website, look at
More informationCSC System Development with Java Introduction to Java Applets Budditha Hettige
CSC 308 2.0 System Development with Java Introduction to Java Applets Budditha Hettige Department of Statistics and Computer Science What is an applet? applet: a Java program that can be inserted into
More informationCS 170 Java Programming 1. Week 9: Learning about Loops
CS 170 Java Programming 1 Week 9: Learning about Loops What s the Plan? Topic 1: A Little Review ACM GUI Apps, Buttons, Text and Events Topic 2: Learning about Loops Different kinds of loops Using loops
More informationModule 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani
Module 5 The Applet Class, Swings OOC 4 th Sem, B Div 2017-18 Prof. Mouna M. Naravani The Applet Class Types of Applets (Abstract Window Toolkit) Offers richer and easy to use interface than AWT. An Applet
More informationModule 4 Multi threaded Programming, Event Handling. OOC 4 th Sem, B Div Prof. Mouna M. Naravani
Module 4 Multi threaded Programming, Event Handling OOC 4 th Sem, B Div 2016-17 Prof. Mouna M. Naravani Event Handling Any program that uses a graphical user interface, such as a Java application written
More informationCHAPTER 2. Java Overview
Networks and Internet Programming (0907522) CHAPTER 2 Java Overview Instructor: Dr. Khalid A. Darabkh Objectives The objectives of this chapter are: To discuss the classes present in the java.awt package
More informationUnit 7: Event driven programming
Faculty of Computer Science Programming Language 2 Object oriented design using JAVA Dr. Ayman Ezzat Email: ayman@fcih.net Web: www.fcih.net/ayman Unit 7: Event driven programming 1 1. Introduction 2.
More information9. APPLETS AND APPLICATIONS
9. APPLETS AND APPLICATIONS JAVA PROGRAMMING(2350703) The Applet class What is an Applet? An applet is a Java program that embedded with web content(html) and runs in a Web browser. It runs inside the
More informationJohn Cowell. Essential Java Fast. How to write object oriented software for the Internet. with 64 figures. Jp Springer
John Cowell Essential Java Fast How to write object oriented software for the Internet with 64 figures Jp Springer Contents 1 WHY USE JAVA? 1 Introduction 1 What is Java? 2 Is this book for you? 2 What
More informationUsing the API: Introductory Graphics Java Programming 1 Lesson 8
Using the API: Introductory Graphics Java Programming 1 Lesson 8 Using Java Provided Classes In this lesson we'll focus on using the Graphics class and its capabilities. This will serve two purposes: first
More informationEXCEPTIONS & GUI. Errors are signals that things are beyond help. Review Session for. -Ankur Agarwal
Review Session for EXCEPTIONS & GUI -Ankur Agarwal An Exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions. Errors are signals
More informationJava Coordinate System
Java Graphics Drawing shapes in Java such as lines, rectangles, 3-D rectangles, a bar chart, or a clock utilize the Graphics class Drawing Strings Drawing Lines Drawing Rectangles Drawing Ovals Drawing
More informationOutline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics
Topic 9: Swing Outline Swing = Java's GUI library Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 7: Expand moving shapes from Assignment 4 into game. "Programming
More informationGUI DYNAMICS Lecture July 26 CS2110 Summer 2011
GUI DYNAMICS Lecture July 26 CS2110 Summer 2011 GUI Statics and GUI Dynamics 2 Statics: what s drawn on the screen Components buttons, labels, lists, sliders, menus,... Containers: components that contain
More informationChapter 12 Advanced GUIs and Graphics
Chapter 12 Advanced GUIs and Graphics Chapter Objectives Learn about applets Explore the class Graphics Learn about the classfont Explore the classcolor Java Programming: From Problem Analysis to Program
More informationISO-2022-JP (JIS ) 1 2. (Windows95/98 MacOS ) Java UNICODE UNICODE. Java. .java.java.txt native2ascii. .java
2000 8 2000.1.24-27 0 4 1 ( (1 8 ) ASCII 1 8 1 1 8 2 ISO-2022-JP (JIS ) 1 2 EUC ( EUC) 8 Unix SJIS (MS ) EUC 8 ( (Windows95/98 MacOS Java UNICODE UNICODE ( Java.java.java.txt native2ascii.java native2ascii
More informationIT101. Graphical User Interface
IT101 Graphical User Interface Foundation Swing is a platform-independent set of Java classes used for user Graphical User Interface (GUI) programming. Abstract Window Toolkit (AWT) is an older Java GUI
More informationTwin 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 informationLab & Assignment 1. Lecture 3: ArrayList & Standard Java Graphics. Random Number Generator. Read Lab & Assignment Before Lab Wednesday!
Lab & Assignment 1 Lecture 3: ArrayList & Standard Java Graphics CS 62 Fall 2015 Kim Bruce & Michael Bannister Strip with 12 squares & 5 silver dollars placed randomly on the board. Move silver dollars
More informationModule 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani
Module 5 The Applet Class, Swings OOC 4 th Sem, B Div 2016-17 Prof. Mouna M. Naravani The Applet Class Types of Applets (Abstract Window Toolkit) Offers richer and easy to use interface than AWT. An Applet
More informationCS 120 Fall 2008 Practice Final Exam v1.0m. Name: Model Solution. True/False Section, 20 points: 10 true/false, 2 points each
CS 120 Fall 2008 Practice Final Exam v1.0m Name: Model Solution True/False Section, 20 points: 10 true/false, 2 points each Multiple Choice Section, 32 points: 8 multiple choice, 4 points each Code Tracing
More informationUML and OOD. Some terms related to OOD. Dependency. Coupling. Interfaces. Multiple Interfaces
UML and OOD Some terms related to OOD What are good systems like? Most real systems are too big for a single developer to understand everything about the system modules. How do we break a system into modules/components/classes?
More informationMarcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science
Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science mluckner@mini.pw.edu.pl http://www.mini.pw.edu.pl/~lucknerm } Abstract Window Toolkit Delegates creation and
More informationMultiple 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 informationCONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13
CONTENTS Chapter 1 Getting Started with Java SE 6 1 Introduction of Java SE 6... 3 Desktop Improvements... 3 Core Improvements... 4 Getting and Installing Java... 5 A Simple Java Program... 10 Compiling
More informationUnit 1- Java Applets. Applet Programming. Local Applet and Remote Applet ** Applet and Application
Applet Programming Applets are small Java applications that can be accessed on an Internet server, transported over Internet, and can be automatically installed and run as a part of a web document. An
More informationLecture 19 GUI Events
CSE 331 Software Design and Implementation Lecture 19 GUI Events The plan User events and callbacks Event objects Event listeners Registering listeners to handle events Anonymous inner classes Proper interaction
More informationJava Applets / Flash
Java Applets / Flash Java Applet vs. Flash political problems with Microsoft highly portable more difficult development not a problem less so excellent visual development tool Applet / Flash good for:
More informationPackages: Putting Classes Together
Packages: Putting Classes Together 1 Introduction 2 The main feature of OOP is its ability to support the reuse of code: Extending the classes (via inheritance) Extending interfaces The features in basic
More information