Property Editors and Customizers. COMP434 Software Design. Property Editors. Property Editors and. Property Editors.
|
|
- Elvin McKinney
- 5 years ago
- Views:
Transcription
1 COMP434 Software Design and Customizers and Customizers A property editor allows the user to read and modify the value of one property A customizer provides a graphical user interface that allows the user to edit multiple properties Useful for components that have complex functions Treats the component as a whole (can enforce dependencies between fields) 1 Software Design 2 A property may be represented on the Properties window in one of three ways: Its value can be displayed in a text field It can be shown as a choice element Useful for properties that are limited to a set of fixed values An image representing the property value can be painted into a small rectangle on the Properties window Eg the foreground/background Color properties of components Support for property editors: java.beans.propertyeditor Interface implemented by property editors java.beans.propertyeditorsupport No-op implementation of PropertyEditor Provides a firepropertychange() method to send a property change event to all registered listeners Software Design 3 Software Design 4 Methods in the PropertyEditor interface: addpropertychangelistener(propertychangelistener pcl) removepropertychangelistener(propertychangelistener pcl) String getastext() Returns a text representation of the property Void setastext(string str) throws IllegalArgumentException Uses str to set the property. An IllegalArgumentException is thrown if str is not formatted correctly or the property can t be set using a String Component getcustomeditor() Returns a reference to a custom property editor, or null if there is no custom editor boolean supportscustomeditor() String getjavainitializationstring() Returns a String that is a fragment of Java source code that can be used to initialize a variable with the value of a property Methods in the PropertyEditor interface (cont): String [] gettags() Return an array of strings that are the set of allowed values for this property Object getvalue() Return an Object that contains the value of this property void setvalue(object obj) Uses obj to set the value of this property boolean ispaintable() Returns true if the paintvalue() method can be used for this property void paintvalue(graphics g, Rectangle r) Paints a representation of this property in the Rectangle r on Graphics g Software Design 6 1
2 Representing properties as text fields Example code: PointViewer - a Bean that displays a square in which a point is positioned PointEditor - defines how the x and y coordinates of this point are represented (this is the property editor) PointViewerBeanInfo - associates PointEditor and PointViewer Software Design 7 package point; public class PointViewer extends JPanel { private Point point; public PointViewer() { point = new Point(0, 0); Dimension d = new Dimension(200, 200); setminimumsize(d); setpreferredsize(d); setmaximumsize(d); public Point getpoint() { return point; public void setpoint(point point) { this.point = point; // remaining code omitted package point; public class PointEditor extends PropertyEditorSupport { public String getastext() { Point point = (Point)getValue(); return "" + point.x + "," + point.y; public void setastext(string text) throws IllegalArgumentException { int index = text.indexof(","); String sx = (index == -1)? text : text.substring(0, index); String sy = (index == -1)? "0" : text.substring(index + 1); int x = Integer.parseInt(sx.trim()); int y = Integer.parseInt(sy.trim()); setvalue(new Point(x, y)); catch(exception ex) { throw new IllegalArgumentException(); package point; public class PointViewerBeanInfo extends SimpleBeanInfo { public PropertyDescriptor[] getpropertydescriptors() { PropertyDescriptor p1; p1 = new PropertyDescriptor("point", PointViewer.class); p1.setpropertyeditorclass(pointeditor.class); PropertyDescriptor pds[] = { p1 ; return pds; catch(exception ex) { ex.printstacktrace(); Representing properties as choices Example code IceCream - is a Bean that displays a square filled with the colour of the selected flavour (vanilla, chocolate, strawberry or pistachio) FlavourEditor - provides a set of choices from which the user can select one IceCreamBeanInfo - associates FlavourEditor and IceCream Software Design 12 2
3 package icecream; public class IceCream extends JPanel { private static Hashtable flavourtocolor; static { flavourtocolor = new Hashtable(); flavourtocolor.put("vanilla", new Color(255, 255, 255)); flavourtocolor.put("chocolate", new Color(119, 66, 8)); flavourtocolor.put("strawberry", new Color(236, 112, 132)); flavourtocolor.put("pistachio", new Color(113, 249, 158)); private String flavour; // the flavour property // Constructor omitted (see source code) public void paintcomponent(graphics g) { super.paintcomponent(g); Color color = (Color)flavourToColor.get(flavour); g.setcolor(color); Dimension d = getsize(); g.fillrect(0, 0, d.width 1, d.height 1); // end IceCream public String getflavour() { return flavour; public void setflavour(string flavour) { this.flavour = flavour; package icecream; public class FlavourEditor extends PropertyEditorSupport { public String[] gettags() { String flavours[] = { "Vanilla", "Chocolate", "Strawberry", "Pistachio" ; return flavours; //end FlavourEditor package icecream; public class IceCreamBeanInfo extends SimpleBeanInfo { public PropertyDescriptor[] getpropertydescriptors() { PropertyDescriptor p1; p1 = new PropertyDescriptor("flavour", IceCream.class); p1.setpropertyeditorclass(flavoureditor.class); PropertyDescriptor pds[] = { p1 ; return pds; catch(exception ex) { ex.printstacktrace(); // end IceCreamBeanInfo public class IceCream2 extends JPanel { private static Hashtable flavourtocolor; public static int VANILLA = 0; public static int CHOCOLATE = 1; public static int STRAWBERRY = 2; public static int PISTACHIO = 3; static { flavourtocolor = new Hashtable(); flavourtocolor.put(new Integer(VANILLA), new Color(255, 255, 25 flavourtocolor.put(new Integer(CHOCOLATE), new Color(119, 66, 8 flavourtocolor.put(new Integer(STRAWBERRY), new Color(236, 112, flavourtocolor.put(new Integer(PISTACHIO), new Color(113, 249, private int flavour; public int getflavour() { return flavour; public void setflavour(int flavour) { this.flavour = flavour; public class FlavourEditor2 extends PropertyEditorSupport { public String getastext() { Integer val = (Integer) getvalue(); switch (val.intvalue()) { case 0: return "Vanilla"; case 1: return "Chocolate"; case 2: return "Strawberry"; case 3: return "Pistachio"; return "Vanilla"; public void setastext(string text) { if (text.equals("vanilla")) { setvalue(new Integer(IceCream2.VANILLA)); else if (text.equals("chocolate")) { setvalue(new Integer(IceCream2.CHOCOLATE)); else if (text.equals("strawberry")) { setvalue(new Integer(IceCream2.STRAWBERRY)); else { setvalue(new Integer(IceCream2.PISTACHIO)); 3
4 public String[] gettags() { String flavours[] = { "Vanilla", "Chocolate", "Strawberry", "Pistachio" ; return flavours; // end FlavourEditor2 Custom property editors Example code: MultiLineLabel - is a Bean that renders a textual label over multiple lines Label property is a String where the characters or \n can be used to delimit lines MultiLineLabel2 - is the same as above but has a custom property editor for the label text LabelEditor - the custom property editor for MultiLineLabel2 Software Design 20 package label; public class MultiLineLabel extends JPanel { private String label = "Your label goes here!"; private int numlines; private String [] lines; private int [] linewidths; private int maxwidth; private boolean measured = false; private int lineheight; private static int MARGIN = 10; public MultiLineLabel() { newlabel(); private synchronized void newlabel() { StringTokenizer st = new StringTokenizer(label, " \n"); numlines = st.counttokens(); lines = new String [numlines]; linewidths = new int [numlines]; for (int i = 0; i < numlines; i++) { lines[i] = st.nexttoken(); public String getlabel() { return label; public void setlabel(string label) { this.label = label; newlabel(); measured = false; getparent().invalidate(); // force container to refresh getparent().dolayout(); public Dimension getpreferredsize() { if (!measured) { measure(); return new Dimension(maxWidth + (2 * MARGIN), (numlines * lineheight) + (2 * MARGIN)); public Dimension getminimumsize() { return getpreferredsize(); private synchronized void measure() { Graphics gx = getgraphics(); FontMetrics fm = gx.getfontmetrics(); lineheight = fm.getheight(); maxwidth = 0; for (int i = 0; i < numlines; i++) { linewidths[i] = fm.stringwidth(lines[i]); if (linewidths[i] > maxwidth) { maxwidth = linewidths[i]; measured = true; public void paintcomponent(graphics gx) { super.paintcomponent(gx); Dimension size = getsize(); if (!measured) { measure(); int x,y; y = MARGIN + (size.height numlines * lineheight)/2; for (int i = 0; i < numlines; i++, y += lineheight ) { x = (size.width linewidths[i])/2; gx.drawstring(lines[i], x, y); // end MultiLineLabel 4
5 package label; import java.awt.event.*; import javax.swing.jtextarea; import javax.swing.jscrollpane; import javax.swing.jbutton; public class LabelEditor extends JPanel implements PropertyEditor { private PropertyChangeSupport support = new PropertyChangeSupport(this); private String labelstring; private JTextArea ta = new JTextArea(5,20); public LabelEditor() { setlayout(new BorderLayout()); JScrollPane js = new JScrollPane(ta); add(js, BorderLayout.CENTER); JButton update = new JButton("Update Label"); add(update, BorderLayout.SOUTH); update.addactionlistener(new ActionListener() { public void actionperformed(actionevent e) { String old = labelstring; labelstring = ta.gettext(); support.firepropertychange("label", old, labelstring); ); public void setvalue(object o) { String old = labelstring; labelstring = ((String)o).replace(' ','\n'); ta.settext(labelstring); support.firepropertychange("label", old, labelstring); public Object getvalue() { return labelstring; public boolean ispaintable() { return true; public void paintvalue(graphics g, Rectangle r) { FontMetrics fm = g.getfontmetrics(); int verticalpad = (r.height fm.getheight()) / 2; g.drawstring("<click to edit>", 2, fm.getheight() + verticalpad); public boolean supportscustomeditor() { return true; public Component getcustomeditor() { return this; public String getjavainitializationstring() { public String getastext() { public void setastext(string s) throws IllegalArgumentException { throw new IllegalArgumentException(s); public String [] gettags() { public void addpropertychangelistener(propertychangelistener pcl) { support.addpropertychangelistener(pcl); public void removepropertychangelistener(propertychangelistener pcl) { support.removepropertychangelistener(pcl); // end LabelEditor package label; public class MultiLineLabel2BeanInfo extends SimpleBeanInfo { public PropertyDescriptor [] getpropertydescriptors() { PropertyDescriptor p1 = new PropertyDescriptor("label", MultiLineLabel2.class); p1.setpropertyeditorclass(labeleditor.class); PropertyDescriptor p2 = new PropertyDescriptor("background", MultiLineLabel2.class); PropertyDescriptor [] pds = {p1, p2; return pds; catch (Exception ex) { 5
6 Customizers Customizers A Bean developer may want to provide some way for the user to customize its properties other than by setting them one at a time Customizers allow the user to read and write several properties It can highlight dependencies between properties Could guide the user step by step (ie wizard style) through the process of configuring a complex Bean The Customizer interface is defined in the java.beans package Defines three methods: void addpropertychangelistener(propertychangelistener pcl) void removepropertychangelistener(propertychangeli pcl) void setobject(object bean) Called by the builder tool to give the customizer a reference to the Bean whose properties are to be modified Software Design 31 Software Design 32 Example code: Customizers Harmonics - a bean that displays a waveform that is calculated by summing together several different sine waves HarmonicsCustomizer - a graphical user interface that allows the user to select which sine waves to add together HarmonicsBeanInfo - associates HarmonicsCustomizer and Harmonics Software Design 33 package harmonics; public class Harmonics extends JPanel { public final static int NFREQUENCIES = 20; private BitSet frequencies; public Harmonics() { frequencies = new BitSet(NFREQUENCIES); Dimension d = new Dimension(301, 150); setminimumsize(d); setpreferredsize(d); setmaximumsize(d); public BitSet getfrequencies() { return frequencies; public void setfrequencies(bitset frequencies) { this.frequencies = frequencies; // see source code for the rest of this class package harmonics; import java.awt.event.*; import javax.swing.jlabel; import javax.swing.jlist; import javax.swing.defaultlistmodel; import javax.swing.listselectionmodel; import javax.swing.event.listdatalistener; import javax.swing.event.listdataevent; public class HarmonicsCustomizer extends JPanel implements Customizer { private PropertyChangeSupport pcsupport = new PropertyChangeSupport(this); private Harmonics harmonics; private JList list; private JPanel p; public HarmonicsCustomizer() { setlayout(new BorderLayout()); JLabel label = new JLabel("Select Harmonics:", JLabel.CENTER); add(label, BorderLayout.NORTH); DefaultListModel dl = new DefaultListModel(); for(int i = 1; i <= Harmonics.NFREQUENCIES; i++) { String s = "(1/" + i + ")(sin" + i + "x)"; dl.addelement(s); list = new JList(dl); list.setselectionmode(listselectionmodel. MULTIPLE_INTERVAL_SELECTION); list.addmouselistener(new MouseAdapter() { public void mouseclicked(mouseevent e) { BitSet frequencies = new BitSet(Harmonics.NFREQUENCIES); for(int i = 0; i < Harmonics.NFREQUENCIES; i++) { if(list.isselectedindex(i)) { frequencies.set(i); harmonics.setfrequencies(frequencies); ); // some code left out see source 6
7 public void setobject(object object) { // Save reference to the Harmonics object harmonics = (Harmonics)object; // Get data from the harmonics object BitSet frequencies = harmonics.getfrequencies(); for(int i = 0; i < Harmonics.NFREQUENCIES; i++) { if(frequencies.get(i)) { list.addselectioninterval(i,i); package harmonics; public class HarmonicsBeanInfo extends SimpleBeanInfo { public BeanDescriptor getbeandescriptor() { return new BeanDescriptor(Harmonics.class, HarmonicsCustomizer.class); // see source for remaining code // end HarmonicsCustomizer 7
Bean Communication. COMP434B Software Design. Bean Communication. Bean Communication. Bean Communication. Bean Communication
COMP434B Software Design JavaBeans: Events and Reflection Events are the primary mechanism by which Java components interact with each other One Bean generates an event and one or more other Beans receive
More informationProctors 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 informationProctors 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 informationIntroduction 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 informationjavax.swing Swing Timer
27 javax.swing Swing SwingUtilities SwingConstants Timer TooltipManager JToolTip 649 650 Swing CellRendererPane Renderer GrayFilter EventListenerList KeyStroke MouseInputAdapter Swing- PropertyChangeSupport
More informationProctors 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 informationQueen s University Faculty of Arts and Science School of Computing CISC 124 Final Examination December 2004 Instructor: M. Lamb
Queen s University Faculty of Arts and Science School of Computing CISC 124 Final Examination December 2004 Instructor: M. Lamb HAND IN Answers recorded on Examination paper This examination is THREE HOURS
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 informationAz első bean példa... StrIntBean forrás
JavaBeans példák Fabók Zsolt Általános Informatikai Tanszék Miskolci Egyetem Az első bean példa... StrIntBean forrás package zib.hu.fabokzs.bean; import java.io.serializable; public class StrIntBean implements
More informationProctors 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 informationGoals. 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 informationDatenbank-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 informationProctors 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 informationFabók Zsolt Általános Informatikai Tanszék Miskolci Egyetem
JavaBeans példák Fabók Zsolt Általános Informatikai Tanszék Miskolci Egyetem Az első bean példa... StrIntBean forrás package zib.hu.fabokzs.bean; import java.io.serializable; public class StrIntBean implements
More informationCourse Structure. COMP434/534B Software Design Component-based software architectures. Components. First term. Components.
COMP434/534B Software Design Component-based software architectures Course Structure Two six week modules First term (me) Introduction to Sun s JavaBeans framework One two hour lecture per week for the
More informationCMP-326 Exam 2 Spring 2018 Solutions Question 1. Version 1. Version 2
Question 1 30 30 60 60 90 20 20 40 40 60 Question 2 a. b. public Song(String title, String artist, int length, String composer) { this.title = title; this.artist = artist; this.length = length; this.composer
More informationInformation Technology for Industrial Engineers 15 November ISE 582: Information Technology for Industrial Engineers
ISE 582: Information Technology for Industrial Engineers University of Southern California Department of Industrial and Systems Engineering Lecture 10 JAVA Cup 9: Images, Interactive Forms Handouts & Announcements
More informationCOMP16121 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 informationExample: 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 informationExample: 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 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 informationJAVA NOTES GRAPHICAL USER INTERFACES
1 JAVA NOTES GRAPHICAL USER INTERFACES Terry Marris 24 June 2001 5 TEXT AREAS 5.1 LEARNING OUTCOMES By the end of this lesson the student should be able to understand how to get multi-line input from the
More 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 informationProctors 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 informationJAVA JavaBeans Java, summer semester
JAVA JavaBeans Components overview component reusable piece of code characterized by services provided and required no exact definition component models JavaBeans Enterprise JavaBeans (EJB) CORBA Component
More informationINTRODUCTION TO (GUIS)
INTRODUCTION TO GRAPHICAL USER INTERFACES (GUIS) Lecture 10 CS2110 Fall 2009 Announcements 2 A3 will be posted shortly, please start early Prelim 1: Thursday October 14, Uris Hall G01 We do NOT have any
More informationDM550 / 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 information6 The MVC model. Main concepts to be covered. Pattern structure. Using design patterns. Design pattern: Observer. Observers
Main concepts to be covered 6 The MVC model Design patterns The design pattern The architecture Using design patterns Inter-class relationships are important, and can be complex. Some relationship recur
More informationDAFTAR 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 informationFirst Name: AITI 2004: Exam 2 July 19, 2004
First Name: AITI 2004: Exam 2 July 19, 2004 Last Name: JSP Track Read Instructions Carefully! This is a 3 hour closed book exam. No calculators are allowed. Please write clearly if we cannot understand
More 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 information1.00/1.001 Introduction to Computers and Engineering Problem Solving Final Examination - December 15, 2003
1.00/1.001 Introduction to Computers and Engineering Problem Solving Final Examination - December 15, 2003 Name: E-mail Address: TA: Section: You have 3 hours to complete this exam. For coding questions,
More information17 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 information1.1 GUI. JFrame. import java.awt.*; import javax.swing.*; public class XXX extends JFrame { public XXX() { // XXX. init() main() public static
18 7 17 1 1.1 GUI ( ) GUI ( ) JFrame public class XXX extends JFrame { public XXX() { // XXX // init()... // ( )... init() main() public static public class XXX extends JFrame { public XXX() { // setsize(,
More informationProctors 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, 2010 FINAL EXAMINATION 2pm to 5pm, 19 APRIL 2010, Dunning Hall Instructor: Alan McLeod
More informationDr. 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 informationAnimatedImage.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 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 informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
QUEEN'S UNIVERSIY SCHOOL O COMPUING CMPE212, ALL ERM, 2011 INAL EXAMINAION 15 December 2011, 2pm, Grant Hall Instructor: Alan McLeod HAND IN Answers Are Recorded on Question Paper SOLUION If the instructor
More informationProctors 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 informationLecture 28. Exceptions and Inner Classes. Goals. We are going to talk in more detail about two advanced Java features:
Lecture 28 Exceptions and Inner Classes Goals We are going to talk in more detail about two advanced Java features: Exceptions supply Java s error handling mechanism. Inner classes ease the overhead of
More informationGraphic 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 informationTopic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more
Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 5: Will be an open-ended Swing project. "Programming Contest"
More informationTopic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!
Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Why are we studying Swing? 1. Useful & fun! 2. Good application of OOP techniques
More informationJava JavaBeans JavaBeans Builder (vitsual) Java JavaBeans JavaBeans http://java.sun.com/j2se/1.3/ja/docs/ja/guide/beans/ http://java.sun.com/products/javabeans/software/bdk_download.html Beans Development
More informationTHE 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 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 informationCalculator 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 informationDM503 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 informationJavaBeans, Properties of Beans, Constrained Properties
Richard G Baldwin (512) 223-4758, baldwin@austin.cc.tx.us, http://www2.austin.cc.tx.us/baldwin/ JavaBeans, Properties of Beans, Constrained Properties Java Programming, Lecture Notes # 512, Revised 02/19/98.
More information1.00/1.001 Introduction to Computers and Engineering Problem Solving Final Examination - December 15, 2003
1.00/1.001 Introduction to Computers and Engineering Problem Solving Final Examination - December 15, 2003 Name: E-mail Address: TA: Section: You have 3 hours to complete this exam. For coding questions,
More informationADF Mobile Code Corner
ADF Mobile Code Corner m03. Abstract: A requirement in software development is to conditionally enable/disable or show/hide UI. Usually, to accomplish this, you dynamically look-up a UI component to change
More informationDr. 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 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 informationJava Swing. Lists Trees Tables Styled Text Components Progress Indicators Component Organizers
Course Name: Advanced Java Lecture 19 Topics to be covered Java Swing Lists Trees Tables Styled Text Components Progress Indicators Component Organizers AWT to Swing AWT: Abstract Windowing Toolkit import
More informationPage 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 informationChapter 13 Lab Advanced GUI Applications
Gaddis_516907_Java 4/10/07 2:10 PM Page 113 Chapter 13 Lab Advanced GUI Applications Objectives Be able to add a menu to the menu bar Be able to use nested menus Be able to add scroll bars, giving the
More informationJavaBeans Component Development
JavaBeans Component Development SL-291 JavaBeans Component Development November 1999 Copyright 1999 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, California 94303, U.S.A. All rights reserved.
More information// 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 informationprotected void printserial() { System.out.println("> NO." + this.serialno); this.serialno++; }
NumberedTicketGenerator.java package j2.exam.ex01; public abstract class NumberedTicketGenerator { protected int serialno; public NumberedTicketGenerator() { super(); this.serialno = 1000; public void
More informationCSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT
CSE 143 Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/
More informationCOMP 401 Recitation 8. Observer Pattern
COMP 401 Recitation 8 Observer Pattern Agenda Quick review of the Observer pattern Worked example Exam review (~30 minutes) Quiz (on your own time) 2 Observer Pattern Problem Statement I have some object
More informationAPPENDIX. public void cekroot() { System.out.println("nilai root : "+root.data); }
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
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 informationI VE GOT A LITTLE LIST
1 I VE GOT A LITTLE LIST James W. Cooper As someday it may happen that a sorted list must be found, Java s got the list. I was thinking about the problem of sorted terms in a list box when I was writing
More informationProctors 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 informationIntroduction 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 informationBirkbeck (University of London) Software and Programming 1 In-class Test Mar 2018
Birkbeck (University of London) Software and Programming 1 In-class Test 2.1 22 Mar 2018 Student Name Student Number Answer ALL Questions 1. What output is produced when the following Java program fragment
More information1 Constructors and Inheritance (4 minutes, 2 points)
CS180 Spring 2010 Final Exam 8 May, 2010 Prof. Chris Clifton Turn Off Your Cell Phone. Use of any electronic device during the test is prohibited. Time will be tight. If you spend more than the recommended
More information1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall (total 7 pages)
1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall 2002 (total 7 pages) Name: TA s Name: Tutorial: For Graders Question 1 Question 2 Question 3 Total Problem 1 (20 points) True or
More informationH212 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 informationComponent Based Software Engineering
Component Based Software Engineering Masato Suzuki School of Information Science Japan Advanced Institute of Science and Technology 1 Schedule Mar. 10 13:30-15:00 : 09. Introduction and basic concepts
More informationCS Exam 3 - Spring 2010
CS 1316 - Exam 3 - Spring 2010 Name: Grading TA: Section: INTEGRITY: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate help during the taking
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 informationProctors 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 CISC124, FALL TERM, 2013 FINAL EXAMINATION 7pm to 10pm, 18 DECEMBER 2013 Instructor: Alan McLeod If the instructor
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 information1.00/1.001 Introduction to Computers and Engineering Problem Solving Spring Quiz 2
1.00/1.001 Introduction to Computers and Engineering Problem Solving Spring 2010 - Quiz 2 Name: MIT Email: TA: Section: You have 80 minutes to complete this exam. For coding questions, you do not need
More informationJavaBeans. JavaBeans. Java. Java JavaBeans. JavaBeans. JavaBeans GUI. JavaBeans Builder (vitsual) Java. JavaBeans. Beans. Builder.
JavaBeans Java JavaBeans JavaBeansBuilder (vitsual) Java JavaBeans JavaBeans Builder Java JavaBeans BeansJava JavaBeans Beans Java GUI JavaJDK(Java Development Kit) Abstract Window Toolkit(AWT)AWT window
More informationRAIK 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 informationBuilding 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 informationGraphical 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 informationLayouts and Components Exam
Layouts and Components Exam Name Period A. Vocabulary: Answer each question specifically, based on what was taught in class. Term Question Answer JScrollBar(a, b, c, d, e) Describe c. ChangeEvent What
More informationState 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 informationJava Help Files. by Peter Lavin. May 22, 2004
Java Help Files by Peter Lavin May 22, 2004 Overview Help screens are a necessity for making any application user-friendly. This article will show how the JEditorPane and JFrame classes, along with HTML
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 Programming Lecture 6
Java Programming Lecture 6 Alice E. Fischer Feb 15, 2013 Java Programming - L6... 1/32 Dialog Boxes Class Derivation The First Swing Programs: Snow and Moving The Second Swing Program: Smile Swing Components
More informationObject-oriented programming in Java (2)
Programming Languages Week 13 Object-oriented programming in Java (2) College of Information Science and Engineering Ritsumeikan University plan last week intro to Java advantages and disadvantages language
More informationName Section. CS 21a Introduction to Computing I 1 st Semester Final Exam
CS a Introduction to Computing I st Semester 00-00 Final Exam Write your name on each sheet. I. Multiple Choice. Encircle the letter of the best answer. ( points each) Answer questions and based on the
More informationThe Islamic University Gaza Department of Electrical & Computer Engineering. Midterm Exam Spring 2012 Computer Programming II (Java) ECOM 2324
The Islamic University Gaza Department of Electrical & Computer Engineering Midterm Exam Spring 2012 Computer Programming II (Java) ECOM 2324 Instructor: Dipl.-Ing. Abdelnasser Abdelhadi Date: 31.03.2013
More informationName: Checked: Learn about listeners, events, and simple animation for interactive graphical user interfaces.
Lab 15 Name: Checked: Objectives: Learn about listeners, events, and simple animation for interactive graphical user interfaces. Files: http://www.csc.villanova.edu/~map/1051/chap04/smilingface.java http://www.csc.villanova.edu/~map/1051/chap04/smilingfacepanel.java
More informationChapter 13 Lab Advanced GUI Applications Lab Objectives. Introduction. Task #1 Creating a Menu with Submenus
Chapter 13 Lab Advanced GUI Applications Lab Objectives Be able to add a menu to the menu bar Be able to use nested menus Be able to add scroll bars, giving the user the option of when they will be seen.
More informationPreviously, 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 informationCS 335 Graphics and Multimedia. Image Manipulation
CS 335 Graphics and Multimedia Image Manipulation Image Manipulation Independent pixels: image subtraction image averaging grey level mapping thresholding Neighborhoods of pixels: filtering, convolution,
More informationCS 3331 Advanced Object-Oriented Programming Final Exam
Fall 2015 (Thursday, December 3) Name: CS 3331 Advanced Object-Oriented Programming Final Exam This test has 5 questions and pages numbered 1 through 10. Reminders This test is closed-notes and closed-book.
More informationDesigning an Interactive Jini Service
Chap04.fm Page 96 Tuesday, May 22, 2001 3:11 PM Designing an Interactive Jini Service Topics in This Chapter Designing distributed services The importance of interfaces in defining services Using utility
More informationFrames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling
Frames, GUI and events Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling Introduction to Swing The Java AWT (Abstract Window Toolkit)
More information1.00/ Introduction to Computers and Engineering Problem Solving. Quiz 2 / November 5, 2004
1.00/1.001 Introduction to Computers and Engineering Problem Solving Quiz 2 / November 5, 2004 Name: Email Address: TA: Section: You have 90 minutes to complete this exam. For coding questions, you do
More informationExample custom-injection can be browsed at https://github.com/apache/tomee/tree/master/examples/custom-injection
Custom Injection Example custom-injection can be browsed at https://github.com/apache/tomee/tree/master/examples/custom-injection Help us document this example! Click the blue pencil icon in the upper
More informationBuilding 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 informationAPPENDIX B: Code Samples from the GUI Supervisor: Graham Kendall
Applying a windows look and feel The program has been developed using a windows look and feel, and the code below, tries to set the look to windows. This is called in the constructor. If the look can t
More information