Prototyping a Swing Interface with the Netbeans IDE GUI Editor

Size: px
Start display at page:

Download "Prototyping a Swing Interface with the Netbeans IDE GUI Editor"

Transcription

1 Prototyping a Swing Interface with the Netbeans IDE GUI Editor Netbeans provides an environment for creating Java applications including a module for GUI design. Here we assume that we have some existing code which implements the model portion of the MVC and we wish to prototype an interface for it. See section 5 for a discussion of the MVC and the particular model our example works with. 1. Getting Started 1.1 Make a new directory for this project. Copy the files start.jar and build.xml to your directory Start up Netbeans and make a new project. Within Netbeans make a new project (Project --> Project Manager --> New) and associate your local directory with the project. Select the Filesystems icon in the Explorer window and mount the local directory which contains your files. Click on the little lever to the left of the build file icon as seen in the Explorer (Figure 1). Double-click the unjarstart target. This will uncompress the starting directory for this project. Inside is a src folder which should also be mounted.. Click lever to reveal targets inside. your_project_directory your_project_directory/src Figure 1 Files shown are after decompressing the starting jar file and mounting the src folder as well Create a GUI form. Select the cs484guiex folder in the Explorer. Hold down the right button and select the New option. Pick new JFrame. A dialog box will appear and ask for the class name - use StateImgFrame. The IDE will move to GUI Editing mode and a Form Editor window will appear as well as a Source Editor window with generated Java code which corresponds to the GUI displayed in the Form Editor. Initially all that the GUI consists of is a single JFrame. your_project_directory your_project_directory/src The new class StateImgFrame is created and appears visually in the Form Editor. It has been placed in the src directory. Its Java source code has been generated and is shown in the Source Editor window. Figure 2

2 2. Adding Components to the Form We will start to build the interface by adding labels and buttons. We also need to take into account the fact that the components that we add to a form will be positioned by a layout manager. Components are placed within other components (Containers). Containers use layout managers to position and size the components inside of them. Our goal is something like this: State statelab At the top of the form editor is a tabbed palette. We will be using the Swing components and Layouts. leftcard rightcard Back Next JLabel JButton JPanel a JPanel backbut nextbut Figure Add the buttons. Click on the JButton symbol in the palette and then click within the JFrame. A button is added to the frame but is sized to fill the entire frame. The component hierarchy is shown in the upper right. The lower right displays the properties for the selected item - the JButton just created. Components are automatically named by the system but we should rename them sensibly for future reference. To make components fit where we d like them to, we need to control the layouts. It will be easier in this case to create a JPanel that we can place the buttons within. Component Inspector Properties Figure 4 Move your mouse to the upper right and hold down the right button over the JFrame to get a popup menu. Select Add from Palette --> Swing --> JPanel to get a new JPanel within the frame. Draw the JButton so that it appears nested within the JPanel. Create another JButton and place it in the panel. 2.2 Modify Button Properties. Place the mouse over the leftmost JButton. Using the right button popup menu, select Rename and name the button backbut. Move the mouse to the text field in the properties dialog and change its text to Back. Modify the right JButton so it becomes nextbut and has the text Next. Note that the panel holding the JButtons is using a Flowlayout. That panel is with the JFrame which is using a Border- Layout. You can graphically select the panel and slide it to the bottom of the JFrame as shown in Figure 5.

3 Figure Add a Label. Click on the Swing JLabel component on the palette and click again within the JFrame. Drag the label until it is positioned at the top as shown in Figure 6. Rename the label to be statelabel and modify its properties as shown. Note that you can change the font of a label too. Clicking on the Test Form button, shows the result so far. Note the size is different than might be expected. Test Form Figure Add 2 more labels which will display images. Use the label component to create a label to hold an image card on the left and one on the right. Name the labels leftcard and rightcard respectively. To place an image on a label, select the label s icon property.... Select the class path option, and look for an image in the image subdirectory (such as /images/faner.jpg). Set the text for the label to be empty so only a picture is shown. After associating a picture with both the leftcard and rightcard and running the Test Form button you should get something similar to what is shown in Figure 7. Figure 7

4 3. Adding a MenuBar and its Menus 3.1 Add a MenuBar. The MenuBar is a row of menus that we want to appear at the top of the JFrame. To create it select the JFrame and get the right menu pop-up. Select the Add from Palette --> Swing --> JMenuBar. The MenuBar will be added along with a single menu. See Figure 8. your_project_directory Figure 8 Double-click on the run target to run your interface as an application your_project_directory/src Figure Create the File Menu. Select the JMenu automatically created when the JMenuBar was created. Change its name to filemenu. Change its text to File. 3.3 Add an Item to a Menu. Select the filemenu and use the right menu pop-up to Add --> JMenuItem. Change the name of the new menuitem to quitmenuitem. Change its text to Quit. Try out your menu with Test Form. 4. Running the Interface code as an Application 4.1 Running from ANT. The Netbeans IDE can utilize a new utility which is becoming standard for development with Java. ANT which acts sort of like the Unix make command, organizes dependencies between tasks and can be used to accomplish things like compiling, running, testing and packaging of code. ANT reads an XML file by default called build.xml. You should have a build file in your project directory. See Figure 9. Double-clicking on the run target will execute that target from within the build.xml file to run your interface code as a java application. Note: this won t work if you haven t given the name StateImgFrame to your interface class. Notice the menu works like a menu but when the Quit option is selected, nothing happens. 4.2 Hooking up the Quit menu item. The GUI editor generates java source code as you graphically edit the GUI. Sections of code rendered in blue are considered protected and are not to be edited by hand. If you double-click the quitmenitem it will take you to the source code and its actionperformed method. Add the code System.exit(); to the actionperformed method. Double-click the run target and try out the menu now. The application should now quit in response to the Quit menu item. Add the text System.exit(0); Figure 10

5 5. Hooking up the Interface to an Underlying Model In order to separate the internal logic of an application from its interface, the Model View Controller (MVC) paradigm is often used. Application presents the user with a visualization (View) and the means to issue commands (Controller) to the object of interest (Model). See Figure 11. The model object here is very simple. Its StateModel Model Underlying, application object, business logic, data, etc. Q. What state are you in? A. Model is in state X User wants to move to next state. GUI View Presents the model to the user. Controller Allows user to manipulate/query the model Figure 11 StateImgFrame logic merely represents several states that we can move through. The model organizes those states as a sequence beginning at the Start state and ending at the Finish state. Our model also gets to impose the policies about what are legal source and destination states. For instance, from Start we are only allowed to go to State1. We can only go forward or backward a single state at a time. Once the Finish state is reached, we can only move backwards. All such rules should be in the logic of the model. The interface will call model methods to pass along the user s commands and ask the model for its current configuration so it can be displayed accurately. The separation of the model from the View/Controller is especially important. It separates the internal logic from the GUI. This makes the internal logic easier to test and maintain and keeps it independent of the particular interface. A single application may represent the same model in different ways (as diagrams, numbers etc.). The methods for this model and a diagram of its legal state transitions are shown in Figure 12. public StateModel() constructor public int getstate() returns an integer representing the current state public void backstate() moves the model one state backwards. If there is no such allowable state from the current state then the state will remain unchanged. public void nextstate() moves the model one state forward. If there is no such allowable state from the current state then the state will remain unchanged. public boolean isbackok()......returns true if able to move one state backwards otherwise false is returned. public boolean isnextok()..... returns true if able to move one state forwards otherwise false is returned. next next next Start State1 State2 Finished Figure 12 back back back

6 Our application will visualize the 4 different states by displaying a different image pair for each state and a label giving the name of the state. Make sure you have the StateModel.java file in the same directory as your source file for the interface (StateImgFrame.java). Note the model code will not need to be changed. The interface code will be changed to hook up with the model. There is a file codetopaste.txt that has source code that you can copy and paste into the StateImgFrame.java file. It is numbered with the points below. 5.1 Make the Next button (Controller) pass its command onto the model. Double-click the Next button in the Form Editor. You will automatically generate an event handler for it and be taken to the source code editor. Make the handler call model.nextstate(); 5.2 Have the interface create and maintain an instance of the model. Create a StateModel variable, model, within the StateImgFrame class. Make a new constructor that a model can be passed to and modify the default constructor to make use of it. 5.3 Make a method so the interface (View) can ask the model for its current information. The method updategui() is defined near the end of the StateImgFrame.java file. It will be used to set all the GUI components to their up-to-date values based upon the model. 5.4 Add a helper function that updates the labels. The method setlabels() will set the label components based upon the model information. Add its code to the end of the StateImgFrame class. 5.5 A helper to load in image icons is needed. Since the GUI will use pictures on some of the labels, a utility function is defined to load the images into memory. Add the method loadimgicons() to the end of the StateImg- Frame class. 5.6 Declare the image icon variables within the class. Use an import statement just after the package statement at the top of the file(6.1). Then after the protected variables enter the declarations for the ImageIcons(6.2). 5.7 Revise the handler to update the GUI. Go back to the nextbutactionperformed() method and after the model.nextstate() method has been called, call the updategui() method. Run the application to see what happens. Watch carefully. Hitting the Next button does change the state but you can only tell by watching the text label at the top. None of the images show up! 5.8 Load the images at initialization. Make sure that the images are loaded. In the constructor (the one which takes a model as input) add the statement loadimgicons() after the components are initialized. Run the application again. It almost looks right but the initial conditions aren t right. 5.9 Make the application start out by asking the model for information. Add the following statement just after the line added in the previous step: updategui(); The Next button should work correctly now Hook-up the Back button. Apply steps 5.1 and 5.7 to the Back button. Use the code model.backstate(); updategui(); in its handler. 6. Tidy-up Appearances Most applications have a meaningful title for their main window. If you select the JFrame in the form editor you will see that it has properties that can be set. Set its title to something like CS484 GUI Demo. You also may decide whether or not to allow the window to be resized. You can set that properties from the Other Properties listing Check your understanding: Hook-up the Next and Back entries in the Navigate Menu so that they work as the buttons do. (Also make sure that they are enabled and disabled properly). prepared by Dr. Michael Wainer, Feb

Getting Started with Java Development and Testing: Netbeans IDE, Ant & JUnit

Getting Started with Java Development and Testing: Netbeans IDE, Ant & JUnit Getting Started with Java Development and Testing: Netbeans IDE, Ant & JUnit 1. Introduction These tools are all available free over the internet as is Java itself. A brief description of each follows.

More information

Getting Started with Java Development and Testing: Netbeans IDE, Ant & JUnit

Getting Started with Java Development and Testing: Netbeans IDE, Ant & JUnit Getting Started with Java Development and Testing: Netbeans IDE, Ant & JUnit 1. Introduction These tools are all available free over the internet as is Java itself. A brief description of each follows.

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

Event Driven Programming

Event Driven Programming Event Driven Programming Part 1 Introduction Chapter 12 CS 2334 University of Oklahoma Brian F. Veale 1 Graphical User Interfaces So far, we have only dealt with console-based programs Run from the console

More information

Forte for Java Community Edition 1.0

Forte for Java Community Edition 1.0 Forte for Java Community Edition 1.0 Java Integrated Development Environment Tutorials Tutorials version 0.9.4 Copyright 1997-1999 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, CA 94303, U.S.A.

More information

Widgets. Widgets Widget Toolkits. User Interface Widget

Widgets. Widgets Widget Toolkits. User Interface Widget Widgets Widgets Widget Toolkits 2.3 Widgets 1 User Interface Widget Widget is a generic name for parts of an interface that have their own behavior: buttons, drop-down menus, spinners, file dialog boxes,

More information

Assignment 1. Application Development

Assignment 1. Application Development Application Development Assignment 1 Content Application Development Day 1 Lecture The lecture provides an introduction to programming, the concept of classes and objects in Java and the Eclipse development

More information

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming Objectives: Last revised 1/15/10 1. To introduce the notion of a component and some basic Swing components (JLabel, JTextField, JTextArea,

More information

Core XP Practices with Java and Eclipse: Part 1

Core XP Practices with Java and Eclipse: Part 1 1. Introduction Core XP Practices with Java and Eclipse: Part 1 This tutorial will illustrate some core practices of Extreme Programming(XP) while giving you a chance to get familiar with Java and the

More information

CS 201 Advanced Object-Oriented Programming Lab 6 - Sudoku, Part 2 Due: March 10/11, 11:30 PM

CS 201 Advanced Object-Oriented Programming Lab 6 - Sudoku, Part 2 Due: March 10/11, 11:30 PM CS 201 Advanced Object-Oriented Programming Lab 6 - Sudoku, Part 2 Due: March 10/11, 11:30 PM Introduction to the Assignment In this lab, you will finish the program to allow a user to solve Sudoku puzzles.

More information

Java Programming Lecture 6

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

Lecture (06) Java Forms

Lecture (06) Java Forms Lecture (06) Java Forms Dr. Ahmed ElShafee 1 Dr. Ahmed ElShafee, Fundamentals of Programming I, Introduction You don t have to output everything to a terminal window in Java. In this lecture, you ll be

More information

GUI Components Continued EECS 448

GUI Components Continued EECS 448 GUI Components Continued EECS 448 Lab Assignment In this lab you will create a simple text editor application in order to learn new GUI design concepts This text editor will be able to load and save text

More information

Widgets. Widgets Widget Toolkits. 2.3 Widgets 1

Widgets. Widgets Widget Toolkits. 2.3 Widgets 1 Widgets Widgets Widget Toolkits 2.3 Widgets 1 User Interface Widget Widget is a generic name for parts of an interface that have their own behavior: buttons, drop-down menus, spinners, file dialog boxes,

More information

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM Objectives The objectives of this assignment are: to get your first experience with Java to become familiar with Eclipse Java

More information

CSC 222: Object-Oriented Programming. Fall 2015

CSC 222: Object-Oriented Programming. Fall 2015 CSC 222: Object-Oriented Programming Fall 2015 Object-oriented design OO design review objects, cohesion, loose coupling, polymorphism, Model-View-Controller (MVC) pattern netbeans IDE create/edit/run

More information

Today. cisc3120-fall2012-parsons-lectiii.3 2

Today. cisc3120-fall2012-parsons-lectiii.3 2 MORE GUI COMPONENTS Today Last time we looked at some of the components that the: AWT Swing libraries provide for building GUIs in Java. This time we will look at several more GUI component topics. We

More information

Widgets. Overview. Widget. Widgets Widget toolkits Lightweight vs. heavyweight widgets Swing Widget Demo

Widgets. Overview. Widget. Widgets Widget toolkits Lightweight vs. heavyweight widgets Swing Widget Demo Widgets Overview Widgets Widget toolkits Lightweight vs. heavyweight widgets Swing Widget Demo Widget Widget is a generic name for parts of an interface that have their own behavior: buttons, progress

More information

Window Interfaces Using Swing Objects

Window Interfaces Using Swing Objects Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs

More information

Window Interfaces Using Swing Objects

Window Interfaces Using Swing Objects Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs

More information

2IS45 Programming

2IS45 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 information

I.1 Introduction Matisse GUI designer I.2 GroupLayout Basics Sequential and Parallel Arrangements sequential horizontal orientation

I.1 Introduction Matisse GUI designer I.2 GroupLayout Basics Sequential and Parallel Arrangements sequential horizontal orientation I GroupLayout I.1 Introduction Java SE 6 includes a powerful layout manager called GroupLayout, which is the default layout manager in the NetBeans IDE (www.netbeans.org). In this appendix, we overview

More information

Visit for more.

Visit  for more. Chapter 3: Getting Started with JAVA IDE Programming Informatics Practices Class XI (CBSE Board) Revised as per CBSE Curriculum 2015 Visit www.ip4you.blogspot.com for more. Authored By:- Rajesh Kumar Mishra,

More information

CS 134 Programming Exercise 7:

CS 134 Programming Exercise 7: CS 134 Programming Exercise 7: Scribbler Objective: To gain more experience using recursion and recursive data structures. This week, you will be implementing a program we call Scribbler. You have seen

More information

Page 1 of 7. public class EmployeeAryAppletEx extends JApplet

Page 1 of 7. public class EmployeeAryAppletEx extends JApplet CS 209 Spring, 2006 Lab 9: Applets Instructor: J.G. Neal Objectives: To gain experience with: 1. Programming Java applets and the HTML page within which an applet is embedded. 2. The passing of parameters

More information

Chapter 14. More Swing

Chapter 14. More Swing Chapter 14 More Swing Menus Making GUIs Pretty (and More Functional) Box Containers and Box Layout Managers More on Events and Listeners Another Look at the Swing Class Hierarchy Chapter 14 Java: an Introduction

More information

More Swing. CS180 Recitation 12/(04,05)/08

More Swing. CS180 Recitation 12/(04,05)/08 More Swing CS180 Recitation 12/(04,05)/08 Announcements No lecture/labs next week Recitations and evening consulting hours will be held as usual. Debbie's study group on tuesday and office hours on thursday

More information

Laboratory 5: Collaborative Text Editing

Laboratory 5: Collaborative Text Editing COMP3511/9511 Lab, Week 12-13, S2 2004 Laboratory 5: Collaborative Text Editing Time Allocated: 30 minutes As we discussed in lectures, the opportunities for creating new forms of collaboration using networking

More information

Eclipse Setup. Opening Eclipse. Setting Up Eclipse for CS15

Eclipse Setup. Opening Eclipse. Setting Up Eclipse for CS15 Opening Eclipse Eclipse Setup Type eclipse.photon & into your terminal. (Don t open eclipse through a GUI - it may open a different version.) You will be asked where you want your workspace directory by

More information

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more

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

Topic 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!

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

Graphical User Interface (GUI)

Graphical User Interface (GUI) Graphical User Interface (GUI) Layout Managment 1 Hello World Often have a static method: createandshowgui() Invoked by main calling invokelater private static void createandshowgui() { } JFrame frame

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

VisualPST 2.4. Visual object report editor for PowerSchool. Copyright Park Bench Software, LLC All Rights Reserved

VisualPST 2.4. Visual object report editor for PowerSchool. Copyright Park Bench Software, LLC All Rights Reserved VisualPST 2.4 Visual object report editor for PowerSchool Copyright 2004-2015 Park Bench Software, LLC All Rights Reserved www.parkbenchsoftware.com This software is not free - if you use it, you must

More information

CSE 219 COMPUTER SCIENCE III BEHAVIORAL DESIGN PATTERNS SLIDES COURTESY: RICHARD MCKENNA, STONY BROOK UNIVERSITY

CSE 219 COMPUTER SCIENCE III BEHAVIORAL DESIGN PATTERNS SLIDES COURTESY: RICHARD MCKENNA, STONY BROOK UNIVERSITY CSE 219 COMPUTER SCIENCE III BEHAVIORAL DESIGN PATTERNS SLIDES COURTESY: RICHARD MCKENNA, STONY BROOK UNIVERSITY Behavioral Design Pattern These design patterns are specifically concerned with communication

More information

1 Using the NetBeans IDE

1 Using the NetBeans IDE Chapter 1: Using the NetBeans IDE 5 1 Using the NetBeans IDE In this chapter we will examine how to set up a new application program using the NetBeans Integrated Development Environment with the language

More information

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics

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

Swing from A to Z Some Simple Components. Preface

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

More information

Graphical User Interfaces. Comp 152

Graphical User Interfaces. Comp 152 Graphical User Interfaces Comp 152 Procedural programming Execute line of code at a time Allowing for selection and repetition Call one function and then another. Can trace program execution on paper from

More information

CS 251 Intermediate Programming GUIs: Components and Layout

CS 251 Intermediate Programming GUIs: Components and Layout CS 251 Intermediate Programming GUIs: Components and Layout Brooke Chenoweth University of New Mexico Fall 2017 import javax. swing.*; Hello GUI public class HelloGUI extends JFrame { public HelloGUI ()

More information

Starting Out with Java: From Control Structures Through Objects Sixth Edition

Starting Out with Java: From Control Structures Through Objects Sixth Edition Starting Out with Java: From Control Structures Through Objects Sixth Edition Chapter 12 A First Look at GUI Applications Chapter Topics 12.1 Introduction 12.2 Creating Windows 12.3 Equipping GUI Classes

More information

Educational Fusion. Implementing a Production Quality User Interface With JFC

Educational Fusion. Implementing a Production Quality User Interface With JFC Educational Fusion Implementing a Production Quality User Interface With JFC Kevin Kennedy Prof. Seth Teller 6.199 May 1999 Abstract Educational Fusion is a online algorithmic teaching program implemented

More information

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

Graphics. Lecture 18 COP 3252 Summer June 6, 2017 Graphics Lecture 18 COP 3252 Summer 2017 June 6, 2017 Graphics classes In the original version of Java, graphics components were in the AWT library (Abstract Windows Toolkit) Was okay for developing simple

More information

To gain experience using GUI components and listeners.

To gain experience using GUI components and listeners. Lab 5 Handout 7 CSCI 134: Fall, 2017 TextPlay Objective To gain experience using GUI components and listeners. Note 1: You may work with a partner on this lab. If you do, turn in only one lab with both

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

Class 16: The Swing Event Model

Class 16: The Swing Event Model Introduction to Computation and Problem Solving Class 16: The Swing Event Model Prof. Steven R. Lerman and Dr. V. Judson Harward 1 The Java Event Model Up until now, we have focused on GUI's to present

More information

Programming graphics

Programming graphics Programming graphics Need a window javax.swing.jframe Several essential steps to use (necessary plumbing ): Set the size width and height in pixels Set a title (optional), and a close operation Make it

More information

Unit 6: Graphical User Interface

Unit 6: Graphical User Interface 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 6: Graphical User Interface 1 1. Overview of the

More information

Layout. Dynamic layout, Swing and general layout strategies

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

More information

Electronic Portfolios in the Classroom

Electronic Portfolios in the Classroom Electronic Portfolios in the Classroom What are portfolios? Electronic Portfolios are a creative means of organizing, summarizing, and sharing artifacts, information, and ideas about teaching and/or learning,

More information

Queens College, CUNY Department of Computer Science. CS 212 Object-Oriented Programming in Java Practice Exam 2. CS 212 Exam 2 Study Guide

Queens College, CUNY Department of Computer Science. CS 212 Object-Oriented Programming in Java Practice Exam 2. CS 212 Exam 2 Study Guide Topics for Exam 2: Queens College, CUNY Department of Computer Science CS 212 Object-Oriented Programming in Java Practice Exam 2 CS 212 Exam 2 Study Guide Linked Lists define a list node define a singly-linked

More information

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS Glossary of Terms 2-4 Step by Step Instructions 4-7 HWApp 8 HWFrame 9 Never trust a computer

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

PIC 20A GUI with swing

PIC 20A GUI with swing PIC 20A GUI with swing Ernest Ryu UCLA Mathematics Last edited: November 22, 2017 Hello swing Let s create a JFrame. import javax. swing.*; public class Test { public static void main ( String [] args

More information

Assignment 2. Application Development

Assignment 2. Application Development Application Development Assignment 2 Content Application Development Day 2 Lecture The lecture covers the key language elements of the Java programming language. You are introduced to numerical data and

More information

Summary Chapter 25 GUI Components: Part 2

Summary Chapter 25 GUI Components: Part 2 1040 Chapter 25 GUI Components: Part 2 ponent on the line. TheJTextField is added to the content pane with a call to our utility method addcomponent (declared at lines 79 83). MethodaddComponent takes

More information

Creating Buttons and Pop-up Menus

Creating Buttons and Pop-up Menus Using Fireworks CHAPTER 12 Creating Buttons and Pop-up Menus 12 In Macromedia Fireworks 8 you can create a variety of JavaScript buttons and CSS or JavaScript pop-up menus, even if you know nothing about

More information

Part I: Learn Common Graphics Components

Part I: Learn Common Graphics Components OOP GUI Components and Event Handling Page 1 Objectives 1. Practice creating and using graphical components. 2. Practice adding Event Listeners to handle the events and do something. 3. Learn how to connect

More information

Graphical User Interface (Part-3) Supplementary Material for CPSC 233

Graphical User Interface (Part-3) Supplementary Material for CPSC 233 Graphical User Interface (Part-3) Supplementary Material for CPSC 233 Menu Bars, Menus, and Menu Items A menu is an object of the class JMenu A choice on a menu is called a menu item, and is an object

More information

Part 1: Basics. Page Sorter:

Part 1: Basics. Page Sorter: Part 1: Basics Page Sorter: The Page Sorter displays all the pages in an open file as thumbnails and automatically updates as you add content. The page sorter can do the following. Display Pages Create

More information

Lab 4. D0010E Object-Oriented Programming and Design. Today s lecture. GUI programming in

Lab 4. D0010E Object-Oriented Programming and Design. Today s lecture. GUI programming in Lab 4 D0010E Object-Oriented Programming and Design Lecture 9 Lab 4: You will implement a game that can be played over the Internet. The networking part has already been written. Among other things, the

More information

CS 209 Spring, 2006 Lab 8: GUI Development Instructor: J.G. Neal

CS 209 Spring, 2006 Lab 8: GUI Development Instructor: J.G. Neal CS 209 Spring, 2006 Lab 8: GUI Development Instructor: J.G. Neal Objectives: To gain experience with the programming of: 1. Graphical user interfaces (GUIs), 2. GUI components, and 3. Event handling (required

More information

Lecture 9. Lecture

Lecture 9. Lecture Layout Components MVC Design PaCern GUI Programming Observer Design PaCern D0010E Lecture 8 - Håkan Jonsson 1 Lecture 8 - Håkan Jonsson 2 Lecture 8 - Håkan Jonsson 3 1 1. GUI programming In the beginning,

More information

Java CAPS Creating a Simple Web Service from a JCD

Java CAPS Creating a Simple Web Service from a JCD Java CAPS 5.1.3 Creating a Simple Web Service from a JCD Introduction Holger Paffrath, August 2008 This tutorial shows you how to create an XML Schema definition to define the layout of your web service

More information

Dataflow Editor User Guide

Dataflow Editor User Guide - Cisco EFF, Release 1.0.1 Cisco (EFF) 1.0.1 Revised: August 25, 2017 Conventions This document uses the following conventions. Convention bold font italic font string courier font Indication Menu options,

More information

CS 4300 Computer Graphics

CS 4300 Computer Graphics CS 4300 Computer Graphics Prof. Harriet Fell Fall 2011 Lecture 8 September 22, 2011 GUIs GUIs in modern operating systems cross-platform GUI frameworks common GUI widgets event-driven programming Model-View-Controller

More information

Inheritance (cont) Abstract Classes

Inheritance (cont) Abstract Classes Inheritance (cont) Abstract Classes 1 Polymorphism inheritance allows you to define a base class that has fields and methods classes derived from the base class can use the public and protected base class

More information

Attaching Codesoft 6 to an ODBC Database

Attaching Codesoft 6 to an ODBC Database Attaching Codesoft 6 to an ODBC Database 1. From your Main Menu Options, go into Merge then Create ODBC query. The following Dialog Box will appear. 2. Select the button with 3 dots ( ) on it. 3. The Data

More information

CS193P: HelloPoly Walkthrough

CS193P: HelloPoly Walkthrough CS193P: HelloPoly Walkthrough Overview The goal of this walkthrough is to give you a fairly step by step path through building a simple Cocoa Touch application. You are encouraged to follow the walkthrough,

More information

You Can Make a Difference! Due April 11/12 (Implementation plans due in class on 4/9)

You Can Make a Difference! Due April 11/12 (Implementation plans due in class on 4/9) You Can Make a Difference! Due April 11/12 (Implementation plans due in class on 4/9) In last week s lab, we introduced some of the basic mechanisms used to manipulate images in Java programs. Now, we

More information

More Swing. Chapter 14. Chapter 14 1

More Swing. Chapter 14. Chapter 14 1 More Swing Chapter 14 Chapter 14 1 Objectives learn to add menus, icons, borders, and scroll bars to GUIs learn to use the BoxLayout manager and the Box class learn about inner classes learn about the

More information

Introduction to Graphical Interface Programming in Java. Introduction to AWT and Swing

Introduction to Graphical Interface Programming in Java. Introduction to AWT and Swing Introduction to Graphical Interface Programming in Java Introduction to AWT and Swing GUI versus Graphics Programming Graphical User Interface (GUI) Graphics Programming Purpose is to display info and

More information

Using Windows Explorer and Libraries in Windows 7

Using Windows Explorer and Libraries in Windows 7 Using Windows Explorer and Libraries in Windows 7 Windows Explorer is a program that is used like a folder to navigate through the different parts of your computer. Using Windows Explorer, you can view

More information

REPAST SIMPHONY SYSTEM DYNAMICS GETTING STARTED

REPAST SIMPHONY SYSTEM DYNAMICS GETTING STARTED REPAST SIMPHONY SYSTEM DYNAMICS GETTING STARTED MARK BRAGEN 1. System Dynamics in Repast Simphony New to this release of Repast Simphony is support for developing System Dynamics models from scratch. This

More information

Display Systems International Software Demo Instructions

Display Systems International Software Demo Instructions Display Systems International Software Demo Instructions This demo guide has been re-written to better reflect the common features that people learning to use the DSI software are concerned with. This

More information

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

Part 3: Graphical User Interface (GUI) & Java Applets 1,QWURGXFWLRQWR-DYD3URJUDPPLQJ (( Part 3: Graphical User Interface (GUI) & Java Applets EE905-GUI 7RSLFV Creating a Window Panels Event Handling Swing GUI Components ƒ Layout Management ƒ Text Field ƒ

More information

PowerPoint Slide Basics. Introduction

PowerPoint Slide Basics. Introduction PowerPoint 2016 Slide Basics Introduction Every PowerPoint presentation is composed of a series of slides. To begin creating a slide show, you'll need to know the basics of working with slides. You'll

More information

1. Open NetBeans and click File... New Project... Select Java as the Category and Java Desktop Application as the Project Click Next.

1. Open NetBeans and click File... New Project... Select Java as the Category and Java Desktop Application as the Project Click Next. Advanced User Interfaces 1. Open NetBeans and click File... New Project... Select Java as the Category and Java Desktop Application as the Project Click Next. 2. Enter YourLastNameU1A4Prog1 as the project

More information

Here are the steps to get the files for this project after logging in on acad/bill.

Here are the steps to get the files for this project after logging in on acad/bill. CSC 243, Java Programming, Spring 2013, Dr. Dale Parson Assignment 5, handling events in a working GUI ASSIGNMENT due by 11:59 PM on Thursday May 9 via gmake turnitin Here are the steps to get the files

More information

The NetBeans IDE is a big file --- a minimum of around 30 MB. After you have downloaded the file, simply execute the file to install the software.

The NetBeans IDE is a big file --- a minimum of around 30 MB. After you have downloaded the file, simply execute the file to install the software. Introduction to Netbeans This document is a brief introduction to writing and compiling a program using the NetBeans Integrated Development Environment (IDE). An IDE is a program that automates and makes

More information

All the Swing components start with J. The hierarchy diagram is shown below. JComponent is the base class.

All the Swing components start with J. The hierarchy diagram is shown below. JComponent is the base class. Q1. If you add a component to the CENTER of a border layout, which directions will the component stretch? A1. The component will stretch both horizontally and vertically. It will occupy the whole space

More information

CSE115 Lab 9 Fall 2016

CSE115 Lab 9 Fall 2016 DUE DATES: Monday recitations: 8:00 PM on 11/13 Wednesday recitations: 8:00 PM on 11/15 Thursday recitations: 8:00 PM on 11/16 Friday recitations: 8:00 PM on 11/17 Saturday recitations: 8:00 PM on 11/18

More information

ICOM 4015 Advanced Programming Laboratory. Chapter 1 Introduction to Eclipse, Java and JUnit

ICOM 4015 Advanced Programming Laboratory. Chapter 1 Introduction to Eclipse, Java and JUnit ICOM 4015 Advanced Programming Laboratory Chapter 1 Introduction to Eclipse, Java and JUnit University of Puerto Rico Electrical and Computer Engineering Department by Juan E. Surís 1 Introduction This

More information

To gain experience using recursion and recursive data structures.

To gain experience using recursion and recursive data structures. Lab 6 Handout 8 CSCI 134: Fall, 2017 Scribbler Objective To gain experience using recursion and recursive data structures. Note 1: You may work with a partner on this lab. If you do, please turn in only

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

Chapter 13. Applets and HTML. HTML Applets. Chapter 13 Java: an Introduction to Computer Science & Programming - Walter Savitch 1

Chapter 13. Applets and HTML. HTML Applets. Chapter 13 Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 13 Applets and HTML HTML Applets Chapter 13 Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Overview Applets: Java programs designed to run from a document on the Internet

More information

Lesson 1: Creating and formatting an Answers analysis

Lesson 1: Creating and formatting an Answers analysis Lesson 1: Creating and formatting an Answers analysis Answers is the ad-hoc query environment in the OBIEE suite. It is in Answers that you create and format analyses to help analyze business results.

More information

No previous knowledge of Java is required for this workshop.

No previous knowledge of Java is required for this workshop. SAS webaf for Java Application Development, a First Sip Mickey Waxman University of Kansas, Lawrence, Kansas Larry Hoyle University of Kansas, Lawrence, Kansas ABSTRACT SAS webaf is an integrated development

More information

Smooks Developer Tools Reference Guide. Version: GA

Smooks Developer Tools Reference Guide. Version: GA Smooks Developer Tools Reference Guide Version: 3.2.1.GA 1. Introduction... 1 1.1. Key Features of Smooks Tools... 1 1.2. 1.3. 1.4. 2. Tasks 2.1. 2.2. 2.3. What is Smooks?... 1 What is Smooks Tools?...

More information

S A M P L E C H A P T E R

S A M P L E C H A P T E R SAMPLE CHAPTER Anyone Can Create an App by Wendy L. Wise Chapter 5 Copyright 2017 Manning Publications brief contents PART 1 YOUR VERY FIRST APP...1 1 Getting started 3 2 Building your first app 14 3 Your

More information

Dialog XML Importer. Index. User s Guide

Dialog XML Importer. Index. User s Guide Dialog XML Importer User s Guide Index 1. What is the Dialog XML Importer? 2. Setup Instructions 3. Creating Your Own Dialogs Using articy:draft a. Conditions b. Effects c. Text Tokens 4. Importing Your

More information

CS 201 Advanced Object-Oriented Programming Lab 1 - Improving Your Image Due: Feb. 3/4, 11:30 PM

CS 201 Advanced Object-Oriented Programming Lab 1 - Improving Your Image Due: Feb. 3/4, 11:30 PM CS 201 Advanced Object-Oriented Programming Lab 1 - Improving Your Image Due: Feb. 3/4, 11:30 PM Objectives The objectives of this assignment are: to refresh your Java programming to become familiar with

More information

CSE 1325 Project Description

CSE 1325 Project Description CSE 1325 Summer 2016 Object-Oriented and Event-driven Programming (Using Java) Instructor: Soumyava Das Graphical User Interface (GUI), Event Listeners and Handlers Project IV Assigned On: 07/28/2016 Due

More information

Building Graphical User Interfaces. GUI Principles

Building Graphical User Interfaces. GUI Principles Building Graphical User Interfaces 4.1 GUI Principles Components: GUI building blocks Buttons, menus, sliders, etc. Layout: arranging components to form a usable GUI Using layout managers. Events: reacting

More information

25. DECUS Symposium THE Application Development Environment for OpenVMS

25. DECUS Symposium THE Application Development Environment for OpenVMS NetBeans THE Application Development Environment for OpenVMS Sunil Kumaran, Thomas Siebold Agenda What is NetBeans some history Major Features / Demonstrations NetBeans on OpenVMS Questions 5/2/2002 DECUS

More information

JavaFX. Getting Started with JavaFX Scene Builder Release 1.1 E

JavaFX. Getting Started with JavaFX Scene Builder Release 1.1 E JavaFX Getting Started with JavaFX Scene Builder Release 1.1 E25448-03 October 2013 JavaFX Getting Started with JavaFX Scene Builder, Release 1.1 E25448-03 Copyright 2012, 2013 Oracle and/or its affiliates.

More information

Graphical User Interface (GUI)

Graphical User Interface (GUI) Graphical User Interface (GUI) An example of Inheritance and Sub-Typing 1 Java GUI Portability Problem Java loves the idea that your code produces the same results on any machine The underlying hardware

More information

Prerequisites for Eclipse

Prerequisites for Eclipse Prerequisites for Eclipse 1 To use Eclipse you must have an installed version of the Java Runtime Environment (JRE). The latest version is available from java.com/en/download/manual.jsp Since Eclipse includes

More information

PowerPoint Tips and Tricks

PowerPoint Tips and Tricks PowerPoint Tips and Tricks Viewing Your Presentation PowerPoint provides multiple ways to view your slide show presentation. You can access these options either through a toolbar on your screen or by pulling

More information