1 Object-Oriented Software Engineering CS288. 2 GUI building with NetBeans Contents User Interaction JButtons JTextFields JLabels JForms in NetBeans Practical.

Slides:



Advertisements
Similar presentations
Using the SmartPLS Software
Advertisements

Graphic User Interfaces Layout Managers Event Handling.
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Introduction to Java Classes, events, GUI’s. Understand: How to use TextPad How to define a class or object How to create a GUI interface How event-driven.
Introduction to Objective-C and Xcode (Part 1) FA 175 Intro to Mobile App Development.
Event Driven Programming and GUIs Part 3 CS221 – 4/15/09.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Creating Custom Forms. 2 Design and create a custom form You can create a custom form by modifying an existing form or creating a new form. Either way,
1 Event Driven Programming with Graphical User Interfaces (GUIs) A Crash Course © Rick Mercer.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Programming Task: Task 1 Controlled Assessment Practice.
Chapter 6: Graphical User Interface (GUI) and Object-Oriented Design (OOD) J ava P rogramming: Program Design Including Data Structures Program Design.
Visual Basic 2008 Express Edition The IDE. Visual Basic 2008 Express The Start Page Recent Projects Open an existing project Create a New Project.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
1 Object-Oriented Software Engineering CS Multiple Classes Contents Lists of objects Vectors Growing and shrinking Vectors Iteration over Vector.
From BlueJ to NetBeans SWC 2.semester.
The NetBeans IDE CSIS 3701: Advanced Object Oriented Programming.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
1 Event Driven Programming wirh Graphical User Interfaces (GUIs) A Crash Course © Rick Mercer.
1 1 Lab1 Ismail M. Romi – IT Dept, PPU, Visual Basic 2005 Programming Tour.
Introduction to Matlab & Data Analysis
Using the Netbeans GUI Builder. The Netbeans IDE provides a utility called the GUI Builder that assists you with creating Windows applications. The Netbeans.
Java Programming: From Problem Analysis to Program Design, Second Edition1  Learn about basic GUI components.  Explore how the GUI components JFrame,
Chapter 3: Using GUI Objects and the Visual Studio IDE.
MSc/PgDip in ITIntroductory Programming: Week 4 Lecture 21 INTRODUCTORY PROGRAMMING Week 4 Lecture 2 Fonts –Horstmann 4.6 ActionEvents –different events.
Applets and Frames CS 21a: Introduction to Computing I First Semester,
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
Copyright © Curt Hill First Window Builder Program Easy GUIs in Eclipse.
GUIs in Java Swing, Events CS2110, SW Development Methods Readings: MSD, Chapter 12 Lab Exercise.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
MSc Workshop - © S. Kamin, U. ReddyLect 3 - GUI -1 Lecture 3 - Graphical User Interfaces r GUI toolkits in Java API r JFrame r GUI components.
1 CSC 222: Object-Oriented Programming Spring 2012 netBeans & GUIBuilder  netBeans IDE create/edit/run a project  GUIBuilder JFrame, JButton, JTextField,
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Applets and Frames. Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L14: GUI Slide 2 Applets Usually.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
UID – Event Handling and Listeners Boriana Koleva
CS-1020 Dr. Mark L. Hornick 1 Event-Driven Programming.
Topics Introduction Scene Graphs
CSC 157 (Blum)1 Hello World. CSC 157 (Blum)2 Start/Programs/Microsoft Visual Studio.NET 2003/Microsoft Visual Studio.NET 2003.
Java Programming: From Problem Analysis to Program Design, 3e Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Java Programming: From Problem Analysis to Program Design, Second Edition1 Lecture 5 Objectives  Learn about basic GUI components.  Explore how the GUI.
CIS Intro to JAVA Lecture Notes Set 8 9-June-05.
Ajmer Singh PGT(IP) JAVA IDE Programming - I. Ajmer Singh PGT(IP) GUI (Graphical User Interface) It is an interface that uses a graphic entities along.
Chapter 14: Introduction to Swing Components. Objectives Understand Swing components Use the JFrame class Use the JLabel class Use a layout manager Extend.
Computer Science [3] Java Programming II - Laboratory Course Lab 4 -1 : Introduction to Graphical user interface GUI Components Faculty of Engineering.
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
Lecture 33: More Graphical User Interface (GUI) Announcements & Review Read Ch GU1 & GU2 Cohoon & Davidson Ch 14 Reges & Stepp Lab 10 set game due 4/26.
1NetBeans Tutorial Using the “Properties” menu, name the List “List1” and the button “Button1”. NetBeans Tutorial6.
Swing GUI Components So far, we have written GUI applications which can ‘ draw ’. These applications are simple, yet typical of all Java GUI applications.
Event Handling CS 21a: Introduction to Computing I First Semester,
1 Lecture 8: User Interface Components with Swing.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Applets. 9/04/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L12: Applets Slide 2 Applets Usually.
Design Pattern : Builder SPARCS 04 고윤정. Main Concepts One of Creational Patterns. Process to construct Complex object in Abstract type. –Use the same.
5-1 GUIs and Events Rick Mercer. 5-2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces to respond.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
CIS 270—Application Development II Chapter 11—GUI Components: Part I.
Java Programming Fifth Edition Chapter 13 Introduction to Swing Components.
1 Event Driven Programming with Graphical User Interfaces (GUIs) A Crash Course © Rick Mercer.
CompSci 230 S Programming Techniques
CSC 222: Object-Oriented Programming
Java FX: Scene Builder.
Java Programming: From Problem Analysis to Program Design,
Event Handling CS 21a: Introduction to Computing I
Basic Elements of The GUI
First Window Builder Program
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Presentation transcript:

1 Object-Oriented Software Engineering CS288

2 GUI building with NetBeans Contents User Interaction JButtons JTextFields JLabels JForms in NetBeans Practical steps for building GUI in NetBeans

3 GUI, Graphical User Interface 1.For the course assignment you will be creating a Java application with GUI. 2.GUIs are laborious and complex. 3.NetBeans Provides a useful GUI builder tool with drag and drop form creation. 4.This presentation gives a crash course in using the tool. 5.The underlying concepts of GUIs and how they work in Java will be discussed in depth in later lectures.

4 What's in a GUI Any application involving a human needs to allow them to –input data, –ask for methods to be executed –and get meaningful responses.

5 What's in a GUI JTextFields JComboBox JButton JLabel shows the main elements that we will include in our GUI to provide user interaction. This whole GUI will be provided by a new class that we will implement: FormJFrame

6 What's in a GUI Results displayed in separate window using a table format.

7 The Building class again Methods Signatures: –public void addRoom(Room newRoom) –public String[ ][ ] roomsToArrayArray() –public void setRoom(Vector newRooms) Fields –private Vector rooms This lists the methods and fields we want to use for this exercise. The lab sessions so far have been building up an enhanced version of this class.

8 Room Class, with Enum Type For this exercise we will add a new Enum Type internally to the Room Class: public enum Use { HALL, LOUNGE, BEDROOM, KITCHEN, BATHROOM } This will hold the use to which a room will be put.

9 The Room Class again, with Enum Type Methods: –Constructor: Room(Double newArea, int newDoors, int newWindows, String room_type) –String[ ] toStringArray() Fields: –private Double area; –private int doors; –private int windows; –private Use room_type; This lists the methods and fields we want to use for this exercise. The lab sessions so far have been using a different version of this class.

10 Add Room Scenario

11 Where is the Room Class This scenario requires the FormJFrame class to construct a Room object. In early versions of Building we wrote Room as an inner class. If we want a Room object to be constructed by other classes we need to convert it into a stand-alone class in a file Room.java Fortunately the structure of the Building class means we only need remove the Room code and move it to a new file Room.java in the same folder. No other changes are needed to the Building class for it to still work.

12 Creating Java Forms in NetBeans NetBeans allows us to construct GUIs via a drag and drop tool that integrates with existing code.

13 Creating Java Forms in NetBeans From the existing project that contains the Building class, and Room class add a new JFrom:

14 Creating Java Forms in NetBeans Choose some suitable name or other Click Package

15 Creating Java Forms in NetBeans Choose the package where the other source files live. Click Finish

16 Design-time, graphical view Netbeans opens a drag and drop GUI design tool for FormJFrame

17 Design-time, graphical view Note NetBeans has created a whole new class at this point: First task is to add three text boxes to input data.

18 Design-time, graphical view JTextFields are a Java class specifically designed for GUIs as a place holder for strings typed in by users. These will be covered in depth in later lectures. Drag relevant icon onto the blank form. Doing so creates a new Java object of the relevant class. It automatically creates code within that class to cause the object to appear when the code is run.

19 Design-time, graphical view List of available graphical elements for draging onto form

20 Design-time, graphical view Visual representation of object. Java properties of jTexField1 object. Lists fields of that object which we can modify

21 Design-time, graphical view Rename field value with inspector Right click object Change name to something meaningful.

22 Design-time, graphical view Change default value in design view. Double click text in field and type in new value, say 12.

23 Design-time, graphical view Repeat till we have three JTextField objects with suitable names and default values.

24 Design-time, graphical view Follow same process to drag three new JLabel objects onto the form and give them suitable names and default values:

25 Design-time, graphical view Resize one TextField Control click on each TextField Right click and choose same size:

26 Design-time, graphical view Drag over two JButton object Change the fields names as before Change the display text as before

27 Design-time, graphical view Register action listener to JButton objects Action listners will be covered in depth in later lectures

28 Source view of FormJFrame object Large amounts of code have now been included in the FormJFrame source file FormJFrame.java. The only parts of this that we need worry about are the two new methods: private void showRoomsButtonActionPerformed(java.awt.event.ActionEvent evt) {/* TODO add your handling code here: */ } private void addRoomButtonActionPerformed(java.awt.event.ActionEvent evt) {/* TODO add your handling code here: */ }

29 New Code for JButtons private void addRoomButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String areaString = areaTextField.getText(); String doorString = doorsTextField.getText(); String windowString = windowsTextField.getText(); String roomTypeString = (String)roomTypeComboBox.getSelectedItem(); Double rmArea = new Double(areaString); int numDoors = (int)(new Integer(doorString)); int numWin = (int)(new Integer(windowString)); Room newRoom = new Room(rmArea, numDoors, numWin, roomTypeString); frame_building.addRoom(newRoom); frame_building.showRoomsTable(); } private void showRoomsButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: frame_building.showRoomsTable(); }