APPENDIX. public void cekroot() { System.out.println("nilai root : "+root.data); }

Size: px
Start display at page:

Download "APPENDIX. public void cekroot() { System.out.println("nilai root : "+root.data); }"

Transcription

1 APPENDIX CLASS NODE AS TREE OBJECT public class Node public int data; public Node left; public Node right; public Node parent; public Node(int i) data=i; PROCEDURE BUILDING TREE public class Tree public Node root; public void cekroot() System.out.println("nilai root : "+root.data); public boolean isempty() return root==null; public void insert(int i) Node temp = new Node(i); Node y = null; Node x = root; if (isempty()) System.out.println("nilai "+i+" menjadi root"); root = temp; else while(x!= null) A

2 y = x; if(i < x.data) x= x.left; else x = x.right; if( i < y.data) if(y.left == null) y.left=temp; System.out.println("nilai "+i+" masuk sebelah kiri "+y.data); else y.right = temp; System.out.println("nilai "+i+" masuk sebelah kanan "+y.data); else if(y.right == null) y.right = temp; System.out.println("nilai "+i+" masuk sebelah kanan "+y.data); else y.left=temp; System.out.println("nilai "+i+" masuk sebelah kiri "+y.data); public void min() Node temp=root; while(temp.left!=null) temp=temp.left; System.out.println("nilai min :" +temp.data); public void max() B

3 Node temp=root; while(temp.right!=null) temp=temp.right; System.out.println("nilai max:" +temp.data); public void cetak(node i) Node temp=i; if(temp!=null) cetak(temp.parent); System.out.println(temp.data); cetak(temp.left); cetak(temp.right); public void printnode() System.out.println("Cetak Tree"); cetak(root); DisplayThread dt = new DisplayThread(); public void maxheap(node root, Node prev, PaintTree painttree) if(root==null) return; try maxheap(root.left,root,painttree); maxheap(root.right,root,painttree); if( prev!= null && root.data < prev.data) swapper(root,prev); prev = root; maxheap(prev, prev,painttree); catch (Exception e) e.printstacktrace(); C

4 public void swapper(node node1, Node node2) int temp= node1.data; node1.data = node2.data; node2.data = temp; public void swapmax(painttree painttree) maxheap(root, root,painttree); public void printmax() System.out.println("\nHasil swap:"); cetak(root); public Node[] dualheap(node root) Node data = root; Node result[] = new Node[2]; Tree tree1 = new Tree(); tree1.root = root.left; Tree tree2 = new Tree(); tree2.root = root.right; result[0] = tree1.root; result[1] = tree2.root; cetakheap(root); System.out.println("\n===Tree Split Pertama==="); tree1.cetakheap(tree1.root); System.out.println("\n===Tree Split kedua==="); tree2.cetakheap(tree2.root); return result; public void cetakdual() dualheap(root); public void cetakheap(node root) if(root == null) return; if(this.root.data == root.data ) System.out.println("nilai "+root.data+" Sebagai root"); if(root.right!= null) D

5 System.out.println("nilai "+root.right.data+" masuk sebelah kanan "+root.data); cetakheap(root.right); if(root.left!= null) System.out.println("nilai "+root.left.data+" masuk sebelah kiri "+root.data); cetakheap(root.left); public void deletetree() root = null; System.out.println("Tree deleted"); CLASS TREE DISPLAY import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.border; public class TreeDisplay extends JPanel private Tree tree; private JTextField jtfkey = new JTextField(5); private PaintTree painttree; private PaintTree painttree1; private PaintTree painttree2; private JButton jbtinsert = new JButton("Insert"); private JButton jbtsorting = new JButton("Sorting"); private JButton jbtclear = new JButton("Clear"); private Timer timer; public TreeDisplay(Tree tree) this.tree = tree; painttree = new PaintTree(tree); SwingUtilities.invokeLater(new Runnable() public void run() setui(); ); E

6 public void setui() this.setlayout(new BorderLayout()); add(painttree, BorderLayout.CENTER); JPanel panel = new JPanel(); panel.add(new JLabel("Enter a key: ")); panel.add(jtfkey); panel.add(jbtinsert); panel.add(jbtclear); panel.add(jbtsorting); panel.add(jbtsorting); add(panel, BorderLayout.SOUTH); jbtclear.addactionlistener(new ActionListener() public void actionperformed(actionevent e) tree.deletetree(); panel.repaint(); painttree.repaint(); ); jbtsorting.addactionlistener(new public void actionperformed(actionevent e) painttree.swapmax(painttree); tree.cetakdual(); //painttree1.dualheap(1); //dualheapdisp(painttree1); //painttree2.dualheap(2); //dualheapdisp2(painttree2); //painttree2.repaint(); painttree.timer.start(); painttree.revalidate(); painttree.repaint(); ); jbtinsert.addactionlistener(new ActionListener() public void actionperformed(actionevent e) int key = Integer.parseInt(jtfKey.getText()); tree.insert(key); F

7 ); painttree.repaint(); CLASS PAINT TREE import java.awt.graphics; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.sql.time; import javax.swing.timer; import javax.swing.jpanel; import java.awt.color; import java.awt.graphics2d; import java.awt.font; class PaintTree extends JPanel private int radius = 20; private int vgap = 50; private Tree tree; public Timer timer; public Timer timer2; public PaintTree(Tree tree2) this.tree = tree2; protected void paintcomponent(graphics g) super.paintcomponent(g); Font font = new Font("Verdana", Font.BOLD, 12); g.setfont(font); 4); if (tree.root!= null) displaytree(g, tree.root, getwidth() / 2, 30, getwidth() / public void dualheap(int i) Node dual[] = tree.dualheap(tree.root); if(i == 1) tree.root = dual[0]; G

8 else if(i == 2) tree.root = dual[1]; public void cetakdual() dualheap(tree.root); private void displaytree(graphics g, Node root, int x, int y, int hgap) g.drawoval(x - radius, y - radius, 2 * radius, 2 * radius); g.drawstring(root.data + "", x - 6, y + 4); g.setcolor(color.black); if(root.right!=null) g.drawstring(root.data + "", x - 6, y + 4); g.setcolor(color.red); else g.setcolor(color.blue); if(root.left!=null) g.drawstring(root.data + "", x - 6, y + 4); g.setcolor(color.magenta); else g.setcolor(color.green); 2); if (root.left!= null) connectleftchild(g, x - hgap, y + vgap, x, y); displaytree(g, root.left, x - hgap, y + vgap, hgap / if (root.right!= null) connectrightchild(g, x + hgap, y + vgap, x, y); displaytree(g, root.right, x + hgap, y + vgap, hgap / 2); public Tree gettree() return tree; H

9 public void settree(tree tree) this.tree = tree; private void connectleftchild(graphics g, int x1, int y1, int x2, int y2) double d = Math.sqrt(vGap * vgap + (x2 - x1) * (x2 - x1)); int x11 = (int)(x1 + radius * (x2 - x1) / d); int y11 = (int)(y1 - radius * vgap / d); int x21 = (int)(x2 - radius * (x2 - x1) / d); int y21 = (int)(y2 + radius * vgap / d); g.drawline(x11, y11, x21, y21); private void connectrightchild(graphics g, int x1, int y1, int x2, int y2) double d = Math.sqrt(vGap * vgap + (x2 - x1) * (x2 - x1)); int x11 = (int)(x1 - radius * (x1 - x2) / d); int y11 = (int)(y1 - radius * vgap / d); int x21 = (int)(x2 + radius * (x1 - x2) / d); int y21 = (int)(y2 + radius * vgap / d); g.drawline(x11, y11, x21, y21); public void maxheap(node root, Node prev, PaintTree painttree) if(root==null) return; timer = new Timer(2000, new public void actionperformed(actionevent e) maxheap(root.left,root,painttree); maxheap(root.right,root,painttree); prev.data) if( prev!= null && root.data < swapper(root,prev); //prev = root; Node prev2 = root; maxheap(prev2, prev2,painttree); repaint(); ); timer.start(); I

10 public void swapper(node node1, Node node2) int temp= node1.data; node1.data = node2.data; node2.data = temp; public void swapmax(painttree painttree) maxheap(tree.root, tree.root,painttree); CLASS DISPLAY THREAD public class DisplayThread implements Runnable PaintTree painttree; public PaintTree getpainttree() return painttree; public void setpainttree(painttree painttree) this.painttree = public void run() painttree.repaint(); CLASS MAIN GUI import java.awt.borderlayout; import java.awt.dimension; import java.awt.frame; import java.awt.graphics; import java.awt.graphics2d; import javax.swing.jtextfield; import javax.swing.swingutilities; import javax.swing.japplet; J

11 import javax.swing.jbutton; import javax.swing.jframe; import javax.swing.jlabel; import javax.swing.jpanel; public class MainGui extends JPanel public MainGui() public static void main(string[] args) JFrame frame; frame = new JFrame("Simulation"); frame.setdefaultcloseoperation(jframe.exit_on_close); JButton jbtinsert = new JButton("Insert"); JButton jbtdelete = new JButton("Delete"); JTextField jtfkey = new JTextField(5); JPanel panel = new JPanel(); panel.add(new JLabel("Enter a key: ")); panel.add(jtfkey); panel.add(jbtinsert); panel.add(jbtdelete); Tree a=new Tree(); /*a.insert(5); a.insert(4); a.insert(7); a.insert(6); a.insert(9); a.insert(10); a.insert(8);*/ SwingUtilities.invokeLater(new Runnable() public void run() TreeDisplay treedisplay = new TreeDisplay(a); frame.getcontentpane().add(treedisplay); ); frame.pack(); frame.setsize(new Dimension(1360, 700)); frame.setvisible(true); K

12 L

13 M

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CMPE212, FALL TERM, 2012 FINAL EXAMINATION 18 December 2012, 2pm Instructor: Alan McLeod If the instructor is unavailable

More information

FirstSwingFrame.java Page 1 of 1

FirstSwingFrame.java Page 1 of 1 FirstSwingFrame.java Page 1 of 1 2: * A first example of using Swing. A JFrame is created with 3: * a label and buttons (which don t yet respond to events). 4: * 5: * @author Andrew Vardy 6: */ 7: import

More information

G51PRG: Introduction to Programming Second semester Applets and graphics

G51PRG: 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

AppBisect > PrBisect > class Functie. AppBisect > PrBisect > class Punct. public class Functie { double x(double t) { return t;

AppBisect > PrBisect > class Functie. AppBisect > PrBisect > class Punct. public class Functie { double x(double t) { return t; 1 AppBisect > PrBisect > class Punct public class Punct { double x,y; public Punct(double x, double y) { this.x = x; this.y = y; public void setx(double x) { this.x = x; public double getx() { return x;

More 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

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC124, WINTER TERM, 2009 FINAL EXAMINATION 7pm to 10pm, 18 APRIL 2009, Dunning Hall Instructor: Alan McLeod If the

More information

Dr. Hikmat A. M. AbdelJaber

Dr. Hikmat A. M. AbdelJaber Dr. Hikmat A. M. AbdelJaber Portion of the Java class hierarchy that include basic graphics classes and Java 2D API classes and interfaces. java.lang.object Java.awt.Color Java.awt.Component Java.awt.Container

More information

Example: Building a Java GUI

Example: Building a Java GUI Steven Zeil October 25, 2013 Contents 1 Develop the Model 2 2 Develop the layout of those elements 3 3 Add listeners to the elements 9 4 Implement custom drawing 12 1 The StringArt Program To illustrate

More information

Example: Building a Java GUI

Example: Building a Java GUI Steven Zeil October 25, 2013 Contents 1 Develop the Model 3 2 Develop the layout of those elements 4 3 Add listeners to the elements 12 4 Implement custom drawing 15 1 The StringArt Program To illustrate

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor:

More information

// autor igre Ivan Programerska sekcija package mine;

// autor igre Ivan Programerska sekcija package mine; // autor igre Ivan Bauk @ Programerska sekcija package mine; import java.awt.color; import java.awt.flowlayout; import java.awt.gridlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener;

More information

AnimatedImage.java. Page 1

AnimatedImage.java. Page 1 1 import javax.swing.japplet; 2 import javax.swing.jbutton; 3 import javax.swing.jpanel; 4 import javax.swing.jcombobox; 5 import javax.swing.jlabel; 6 import javax.swing.imageicon; 7 import javax.swing.swingutilities;

More information

Graphic User Interfaces. - GUI concepts - Swing - AWT

Graphic User Interfaces. - GUI concepts - Swing - AWT Graphic User Interfaces - GUI concepts - Swing - AWT 1 What is GUI Graphic User Interfaces are used in programs to communicate more efficiently with computer users MacOS MS Windows X Windows etc 2 Considerations

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC124, WINTER TERM, 2009 FINAL EXAMINATION 7pm to 10pm, 18 APRIL 2009, Dunning Hall Instructor: Alan McLeod

More information

GUI (Graphic User Interface) Programming. Part 2 (Chapter 8) Chapter Goals. Events, Event Sources, and Event Listeners. Listeners

GUI (Graphic User Interface) Programming. Part 2 (Chapter 8) Chapter Goals. Events, Event Sources, and Event Listeners. Listeners GUI (Graphic User Interface) Programming Part 2 (Chapter 8) Chapter Goals To understand the Java event model To install action and mouse event listeners To accept input from buttons, text fields, and the

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor: Alan

More information

RobotPlanning.java Page 1

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

class BankFilter implements Filter { public boolean accept(object x) { BankAccount ba = (BankAccount) x; return ba.getbalance() > 1000; } }

class BankFilter implements Filter { public boolean accept(object x) { BankAccount ba = (BankAccount) x; return ba.getbalance() > 1000; } } 9.12) public interface Filter boolean accept(object x); Describes any class whose objects can measure other objects. public interface Measurer double measure(object anobject); This program tests the use

More information

Systems Programming. Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid

Systems Programming. Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid Systems Programming Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid Leganés, 21st of March, 2014. Duration: 75 min. Full

More information

AP CS Unit 11: Graphics and Events

AP CS Unit 11: Graphics and Events AP CS Unit 11: Graphics and Events This packet shows how to create programs with a graphical interface in a way that is consistent with the approach used in the Elevens program. Copy the following two

More information

User interfaces and Swing

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

Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms.

Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms. Java GUI Windows Events Drawing 1 Java GUI Toolkits Toolkit AWT Description Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms.

More information

Using Several Components

Using Several Components Ch. 16 pt 2 GUIs Using Several Components How do we arrange the GUI components? Using layout managers. How do we respond to event from several sources? Create separate listeners, or determine the source

More information

CSC 1051 Data Structures and Algorithms I. Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University

CSC 1051 Data Structures and Algorithms I. Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Events and Listeners CSC 1051 Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: www.csc.villanova.edu/~map/1051/ Some slides

More information

DAFTAR LAMPIRAN. Source Code Java Aplikasi Keyword to Image Renamer Split

DAFTAR LAMPIRAN. Source Code Java Aplikasi Keyword to Image Renamer Split DAFTAR LAMPIRAN Source Code Java Aplikasi Keyword to Image Renamer Split Source Code Menu Utama package spin_text; import java.awt.color; import java.awt.event.actionevent; import java.awt.event.actionlistener;

More information

Goals. Lecture 7 More GUI programming. The application. The application D&D 12. CompSci 230: Semester JFrame subclass: ListOWords

Goals. Lecture 7 More GUI programming. The application. The application D&D 12. CompSci 230: Semester JFrame subclass: ListOWords Goals By the end of this lesson, you should: Lecture 7 More GUI programming 1. Be able to write Java s with JTextField, JList, JCheckBox and JRadioButton components 2. Be able to implement a ButtonGroup

More information

Answer on question #61311, Programming & Computer Science / Java

Answer on question #61311, Programming & Computer Science / Java Answer on question #61311, Programming & Computer Science / Java JSP JSF for completion Once the user starts the thread by clicking a button, the program must choose a random image out of an image array,

More information

import java.applet.applet; import java.applet.audioclip; import java.net.url; public class Vjesala2 {

import java.applet.applet; import java.applet.audioclip; import java.net.url; public class Vjesala2 { import java.awt.color; import java.awt.flowlayout; import java.awt.font; import java.awt.gridlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.jbutton;

More information

Building Java Programs Bonus Slides

Building Java Programs Bonus Slides Building Java Programs Bonus Slides Graphical User Interfaces Copyright (c) Pearson 2013. All rights reserved. Graphical input and output with JOptionPane JOptionPane An option pane is a simple dialog

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

Chapter 9 Designing Graphical User Interfaces (GUIs)

Chapter 9 Designing Graphical User Interfaces (GUIs) Chapter 9 Designing Graphical User Interfaces (GUIs) Overview The basics of GUIs in Java A tour of Java GUI libraries Containers and components Swing: the full picture Layout managers Understanding events

More information

Multi-Threading : Doing Things in Parallel

Multi-Threading : Doing Things in Parallel Steven Zeil November 17, 2013 Contents 1 Overview 3 1.1 Fundamental Ideas............ 3 1.2 Parallel versus Concurrent........ 8 2 Spawning Processes 10 2.1 Processes in Unix - Fork......... 11 2.2 Heavy

More information

Multi-Threading : Doing Things in Parallel

Multi-Threading : Doing Things in Parallel Steven Zeil November 17, 2013 Contents 1 Overview 2 1.1 Fundamental Ideas....... 2 1.2 Parallel versus Concurrent... 7 2 Spawning Processes 8 2.1 Processes in Unix - Fork.... 8 2.2 Heavy & Light Weight

More information

MTAT Systems Modelling Statechart modeling, simulation and execution using Yakindu

MTAT Systems Modelling Statechart modeling, simulation and execution using Yakindu MTAT.03.083 Systems Modelling Statechart modeling, simulation and execution using Yakindu Abel Armas-Cervantes, Marlon Dumas and Luciano García-Bañuelos In this practice session, you will learn how to

More information

COMP16121 Sample Code Lecture 1

COMP16121 Sample Code Lecture 1 COMP16121 Sample Code Lecture 1 Sean Bechhofer, University of Manchester, Manchester, UK sean.bechhofer@manchester.ac.uk 1 SimpleFrame 1 import javax.swing.jframe; 2 3 public class SimpleFrame { 4 5 /*

More 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

17 GUI API: Container 18 Hello world with a GUI 19 GUI API: JLabel 20 GUI API: Container: add() 21 Hello world with a GUI 22 GUI API: JFrame: setdefau

17 GUI API: Container 18 Hello world with a GUI 19 GUI API: JLabel 20 GUI API: Container: add() 21 Hello world with a GUI 22 GUI API: JFrame: setdefau List of Slides 1 Title 2 Chapter 13: Graphical user interfaces 3 Chapter aims 4 Section 2: Example:Hello world with a GUI 5 Aim 6 Hello world with a GUI 7 Hello world with a GUI 8 Package: java.awt and

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2007 FINAL EXAMINATION 7pm to 10pm, 10 DECEMBER 2007, Jeffery Hall Instructor: Alan McLeod If the

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 32 April 9, 2018 Swing I: Drawing and Event Handling Chapter 29 HW8: Spellchecker Available on the web site Due: Tuesday! Announcements Parsing, working

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. Solution HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2007 FINAL EXAMINATION 7pm to 10pm, 10 DECEMBER 2007, Jeffery Hall Instructor: Alan McLeod

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2008 FINAL EXAMINATION 7pm to 10pm, 17 DECEMBER 2008, Grant Hall Instructor: Alan McLeod

More information

Java Coordinate System

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

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2010 FINAL EXAMINATION 11 DECEMBER 2010, 9am SOLUTION HAND IN Answers Are Recorded on Question Paper Instructor: Alan McLeod If the instructor

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

Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how to paint graphics on GUI components

Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how to paint graphics on GUI components CS112-Section2 Hakan Guldas Burcin Ozcan Meltem Kaya Muge Celiktas Notes of 6-8 May Graphics Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how

More information

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class CHAPTER GRAPHICAL USER INTERFACES 10 Slides by Donald W. Smith TechNeTrain.com Final Draft 10/30/11 10.1 Frame Windows Java provides classes to create graphical applications that can run on any major graphical

More information

Lecture 3: Java Graphics & Events

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

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. Page 1 of 16 SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2005 FINAL EXAMINATION 9am to 12noon, 19 DECEMBER 2005 Instructor: Alan McLeod

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2009 FINAL EXAMINATION 14 DECEMBER 2009 Instructor: Alan McLeod If the instructor is unavailable

More information

Object-Oriented Software Engineering Re-exam, 2012 (Also Object-Oriented Analysis, Design and Programming, Re-exam, 2012)

Object-Oriented Software Engineering Re-exam, 2012 (Also Object-Oriented Analysis, Design and Programming, Re-exam, 2012) Object-Oriented Software Engineering Re-exam, 2012 (Also Object-Oriented Analysis, Design and Programming, Re-exam, 2012) Medialogy, 4 th Semester, Aalborg Thursday 23 August 2012, 09.00 12.00 Instructions

More information

Theory Test 3A. University of Cape Town ~ Department of Computer Science. Computer Science 1016S ~ For Official Use

Theory Test 3A. University of Cape Town ~ Department of Computer Science. Computer Science 1016S ~ For Official Use Please fill in your Student Number and, optionally, Name. For Official Use Student Number : Mark : Name : Marker : University of Cape Town ~ Department of Computer Science Computer Science 1016S ~ 2007

More information

EPITA Première Année Cycle Ingénieur. Atelier Java - J5

EPITA Première Année Cycle Ingénieur. Atelier Java - J5 EPITA Première Année Cycle Ingénieur marwan.burelle@lse.epita.fr http://www.lse.epita.fr Overview 1 2 Different toolkits AWT: the good-old one, lakes some features and has a plateform specific look n

More information

Building a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver

Building a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver Building a GUI in Java with Swing CITS1001 extension notes Rachel Cardell-Oliver Lecture Outline 1. Swing components 2. Building a GUI 3. Animating the GUI 2 Swing A collection of classes of GUI components

More information

Section Basic graphics

Section Basic graphics Chapter 16 - GUI Section 16.1 - Basic graphics Java supports a set of objects for developing graphical applications. A graphical application is a program that displays drawings and other graphical objects.

More information

Calculator Class. /** * Create a new calculator and show it. */ public Calculator() { engine = new CalcEngine(); gui = new UserInterface(engine); }

Calculator Class. /** * Create a new calculator and show it. */ public Calculator() { engine = new CalcEngine(); gui = new UserInterface(engine); } A Calculator Project This will be our first exposure to building a Graphical User Interface (GUI) in Java The functions of the calculator are self-evident The Calculator class creates a UserInterface Class

More information

CSIS 10A Assignment 7 SOLUTIONS

CSIS 10A Assignment 7 SOLUTIONS CSIS 10A Assignment 7 SOLUTIONS Read: Chapter 7 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 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

/* Write a Program implementing GUI based Calculator using Swing */

/* Write a Program implementing GUI based Calculator using Swing */ /* Write a Program implementing GUI based Calculator using Swing */ import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.*; public class Calculator extends JFrame

More information

AP CS Unit 12: Drawing and Mouse Events

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

import javax.swing.*; import java.awt.*; import java.awt.event.*;

import javax.swing.*; import java.awt.*; import java.awt.event.*; I need to be walked through with why the stocks are being recognized "half way." They will print out in the console but won't be recognized by certain code. Every line of code seems to look right and that's

More 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

DM503 Programming B. Peter Schneider-Kamp.

DM503 Programming B. Peter Schneider-Kamp. DM503 Programming B Peter Schneider-Kamp petersk@imada.sdu.dk! http://imada.sdu.dk/~petersk/dm503/! ADVANCED OBJECT-ORIENTATION 2 Object-Oriented Design classes often do not exist in isolation from each

More information

Datenbank-Praktikum. Universität zu Lübeck Sommersemester 2006 Lecture: Swing. Ho Ngoc Duc 1

Datenbank-Praktikum. Universität zu Lübeck Sommersemester 2006 Lecture: Swing. Ho Ngoc Duc 1 Datenbank-Praktikum Universität zu Lübeck Sommersemester 2006 Lecture: Swing Ho Ngoc Duc 1 Learning objectives GUI applications Font, Color, Image Running Applets as applications Swing Components q q Text

More information

6.092 Introduction to Software Engineering in Java January (IAP) 2009

6.092 Introduction to Software Engineering in Java January (IAP) 2009 MIT OpenCourseWare http://ocw.mit.edu 6.092 Introduction to Software Engineering in Java January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.

More information

Introduction. Introduction

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

Client-side GUI. A simple Swing-gui for searching for proudcts

Client-side GUI. A simple Swing-gui for searching for proudcts Client-side GUI A simple Swing-gui for searching for proudcts Working from a sketch to a rough GUI We make a list of the features / requirements We ll then start with a sketch of how a GUI for searching

More information

(listener)... MouseListener, ActionLister. (adapter)... MouseAdapter, ActionAdapter. java.awt AWT Abstract Window Toolkit GUI

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

Graphical User Interfaces in Java - SWING

Graphical User Interfaces in Java - SWING Graphical User Interfaces in Java - SWING Graphical User Interfaces (GUI) Each graphical component that the user can see on the screen corresponds to an object of a class Component: Window Button Menu...

More information

Introduction to the JAVA UI classes Advanced HCI IAT351

Introduction to the JAVA UI classes Advanced HCI IAT351 Introduction to the JAVA UI classes Advanced HCI IAT351 Week 3 Lecture 1 17.09.2012 Lyn Bartram lyn@sfu.ca About JFC and Swing JFC Java TM Foundation Classes Encompass a group of features for constructing

More information

News! Feedback after Lecture 4! About Java and OOP!

News! Feedback after Lecture 4! About Java and OOP! this Example: SignalGUI News Orphans Recursive References D0010E Object-Oriented Programming and Design Lecture 5 GUI Design Patterns Applets Model-View- Control Observer Hints for Lab 2 Use a Vector to

More information

Graphical User Interfaces (GUIs)

Graphical User Interfaces (GUIs) CMSC 132: Object-Oriented Programming II Graphical User Interfaces (GUIs) Department of Computer Science University of Maryland, College Park Model-View-Controller (MVC) Model for GUI programming (Xerox

More information

Chapter Nine: Interfaces and Polymorphism. Big Java by Cay Horstmann Copyright 2008 by John Wiley & Sons. All rights reserved.

Chapter Nine: Interfaces and Polymorphism. Big Java by Cay Horstmann Copyright 2008 by John Wiley & Sons. All rights reserved. Chapter Nine: Interfaces and Polymorphism Chapter Goals To learn about interfaces To be able to convert between class and interface references To understand the concept of polymorphism To appreciate how

More information

3/7/2012. Chapter Nine: Interfaces and Polymorphism. Chapter Goals

3/7/2012. Chapter Nine: Interfaces and Polymorphism. Chapter Goals Chapter Nine: Interfaces and Polymorphism Chapter Goals To learn about interfaces To be able to convert between class and interface references To understand the concept of polymorphism To appreciate how

More information

10/27/2011. Chapter Goals

10/27/2011. Chapter Goals Chapter Goals To learn about interfaces To be able to convert between class and interface references To understand the concept of polymorphism To appreciate how interfaces can be used to decouple classes

More information

COSC 123 Computer Creativity. Graphics and Events. Dr. Ramon Lawrence University of British Columbia Okanagan

COSC 123 Computer Creativity. Graphics and Events. Dr. Ramon Lawrence University of British Columbia Okanagan COSC 123 Computer Creativity Graphics and Events Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Key Points 1) Draw shapes, text in various fonts, and colors. 2) Build

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

State Application Using MVC

State Application Using MVC State Application Using MVC 1. Getting ed: Stories and GUI Sketch This example illustrates how applications can be thought of as passing through different states. The code given shows a very useful way

More information

Graphical User Interface

Graphical User Interface Lecture 10 Graphical User Interface An introduction Sahand Sadjadee sahand.sadjadee@liu.se Programming Fundamentals 725G61 http://www.ida.liu.se/~725g61/ Department of Computer and Information Science

More information

PART 22. Java GUI Library SWT GUI Library SWING GUI Library Swing First Program

PART 22. Java GUI Library SWT GUI Library SWING GUI Library Swing First Program PART 22 Java GUI Library 22.1 SWT GUI Library There is also another GUI library for the Java programming language. It is called SWT (The Standard widget toolkit). The SWT library was initially developed

More information

1 Looping Constructs (4 minutes, 2 points)

1 Looping Constructs (4 minutes, 2 points) Name: Career Account ID: Recitation#: 1 CS180 Spring 2011 Final Exam, 3 May, 2011 Prof. Chris Clifton Turn Off Your Cell Phone. Use of any electronic device during the test is prohibited. Time will be

More information

Clasa frsin.java: import java.awt.*; import javax.swing.*;

Clasa frsin.java: import java.awt.*; import javax.swing.*; 1 Clasa frsin.java: import java.awt.*; import javax.swing.*; public class frsin extends JFrame { private sin2d jpanel1 = new sin2d(); private JCheckBox cbcreion = new JCheckBox(); private JCheckBox cbfond

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

Advanced Java Unit 6: Review of Graphics and Events

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

We are on the GUI fast track path

We are on the GUI fast track path We are on the GUI fast track path Chapter 13: Exception Handling Skip for now Chapter 14: Abstract Classes and Interfaces Sections 1 9: ActionListener interface Chapter 15: Graphics Skip for now Chapter

More information

encompass a group of features for building Graphical User Interfaces (GUI).

encompass a group of features for building Graphical User Interfaces (GUI). Java GUI (intro) JFC Java Foundation Classes encompass a group of features for building Graphical User Interfaces (GUI). javax.swing.* used for building GUIs. Some basic functionality is already there

More information

G51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread

G51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread G51PGP Programming Paradigms Lecture 008 Inner classes, anonymous classes, Swing worker thread 1 Reminder subtype polymorphism public class TestAnimals public static void main(string[] args) Animal[] animals

More information

Java for Interfaces and Networks (DT3010, HT10)

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

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

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

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

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

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction CSC 160 LAB 8-1 DIGITAL PICTURE FRAME PROFESSOR GODFREY MUGANDA DEPARTMENT OF COMPUTER SCIENCE 1. Introduction Download and unzip the images folder from the course website. The folder contains 28 images

More information

CSCI 201L Midterm Written Summer % of course grade

CSCI 201L Midterm Written Summer % of course grade CSCI 201L Summer 2016 10% of course grade 1. Abstract Classes and Interfaces Give two differences between an interface and an abstract class in which all of the methods are abstract. (0.5% + 0.5%) 2. Serialization

More 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

THE UNIVERSITY OF AUCKLAND

THE UNIVERSITY OF AUCKLAND CompSci 101 with answers THE UNIVERSITY OF AUCKLAND FIRST SEMESTER, 2012 Campus: City COMPUTER SCIENCE Principles of Programming (Time Allowed: TWO hours) NOTE: You must answer all questions in this test.

More information

CS193k, Stanford Handout #10. Threads 4 / RMI

CS193k, Stanford Handout #10. Threads 4 / RMI CS193k, Stanford Handout #10 Spring, 2000-01 Nick Parlante Threads 4 / RMI Semaphore2 Alternate implementation -- possibly more readable. Does the wait/decrement in a different order. Uses the classic

More information

Chapter 13 GUI Basics. Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved.

Chapter 13 GUI Basics. Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved. Chapter 13 GUI Basics 1 Motivations The design of the API for Java GUI programming is an excellent example of how the object-oriented principle is applied. In the chapters that follow, you will learn the

More information

EXCEPTIONS & GUI. Errors are signals that things are beyond help. Review Session for. -Ankur Agarwal

EXCEPTIONS & 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 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