Using the Netbeans GUI Builder. The Netbeans IDE provides a utility called the GUI Builder that assists you with creating Windows applications. The Netbeans.

Slides:



Advertisements
Similar presentations
James A. Rome TGA August 2009 Mapping the TZs. In Java it is quite easy to do maps The only way to tell if we interpolated the data successfully is to.
Advertisements

Java Graphical User Interface (GUI) using Visual Editor in eclipse CSI 1390 – Java Programming Instructor: Saeid Nourian University.
Graphic User Interfaces Layout Managers Event Handling.
1 Chapter 8 Objects and Classes Lecture 2 Prepared by Muhanad Alkhalisy.
CMSC 341 Building Java GUIs. 09/26/2007 CMSC 341 GUI 2 Why Java GUI Development? Course is about Data Structures, not GUIs. We are giving you the opportunity.
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.
Event Driven Programming and GUIs Part 3 CS221 – 4/15/09.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
GUI and Event-Driven Programming Recitation – 3/6/2009 CS 180 Department of Computer Science, Purdue University.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L03 (Chapter 15) Creating.
Design Mode. Learning Objectives Define Design Mode Compare and contrast “Text Integration Utility (TIU)” versus “Vuecentric” Template Review keys required.
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
1 Class 8. 2 Chapter Objectives Use Swing components to build the GUI for a Swing program Implement an ActionListener to handle events Add interface components.
Adobe Forms THE FORM ELEMENT PANEL. Creating a form using the Adobe FormsCentral is a quick and easy way to distribute a variety of forms including surveys.
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.
Java Programming Chapter 10 Graphical User Interfaces.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
JLabel, JTextField, JButton and JOptionPane
Teach Yourself Windows 98 Module 2: Working with Files, Folders, and the Desktop.
Copyright 2007, Information Builders. Slide 1 WebFOCUS Maintain – Enhancing Objects with JavaScript Mark Derwin Information Builders Information Builders.
Chapter 12: Using Controls. Examining the IDE’s Automatically Generated Code A new Windows Forms project has been started and given the name FormWithALabelAndAButton.
CTS130 Spreadsheet Lesson 4 Working with Cells, Columns, Rows, and Sheets.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 13 Creating User.
Java Programming: From Problem Analysis to Program Design, Second Edition1  Learn about basic GUI components.  Explore how the GUI components JFrame,
Applets and Frames CS 21a: Introduction to Computing I First Semester,
Domain 3 Understanding the Adobe Dreamweaver CS5 Interface.
1 Object-Oriented Software Engineering CS GUI building with NetBeans Contents User Interaction JButtons JTextFields JLabels JForms in NetBeans Practical.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Copyright © Curt Hill First Window Builder Program Easy GUIs in Eclipse.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
FEN IntroJava2006 AAU1 GUI: Graphical User Interface AWT/SWING: Components Drag and Drop in NetBeans Events Listeners.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
Microsoft Access 2010 Chapter 8 Advanced Form Techniques.
1 CSC 222: Object-Oriented Programming Spring 2012 netBeans & GUIBuilder  netBeans IDE create/edit/run a project  GUIBuilder JFrame, JButton, JTextField,
ITEC 109 Lecture 27 GUI. GUIs Review Sounds –Arrays hold sample values –Creating a keyboard –Sound effects Homework 3 –The big two –Due after break –Lab.
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.
Graphical User Interfaces (Part 2) 1. View  view  presents the user with a sensory (visual, audio, haptic) representation of the model state  a user.
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.
1 / 67 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 14 Programming Fundamentals using Java 1.
FrontPage Tutorial Part 2 Creating a Course Web Site.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 15 Creating User.
CS-1020 Dr. Mark L. Hornick 1 Event-Driven Programming.
CHAPTER:07 JAVA IDE PROGRAMMING-II Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Creating Applets. What is an applet? What is an applet? A Java program that runs in a web browser. A Java program that runs in a web browser. An applet.
A simple swing example GETTING STARTED WITH WIND CHILL.
Java Programming: From Problem Analysis to Program Design, 3e Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Java Programming: From Problem Analysis to Program Design, Second Edition1 Lecture 5 Objectives  Learn about basic GUI components.  Explore how the GUI.
Review_6 AWT, Swing, ActionListener, and Graphics.
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.
1NetBeans Tutorial Using the “Properties” menu, name the List “List1” and the button “Button1”. NetBeans Tutorial6.
Java With NetBeans First Project. Java Are language for this semester is Java The Development Environment is Netbeans.
Swing GUI Components So far, we have written GUI applications which can ‘ draw ’. These applications are simple, yet typical of all Java GUI applications.
Developing GUIs With the Eclipse Visual Editor, Swing/AWT Edition David Gallardo.
View  view  presents the user with a sensory (visual, audio, haptic) representation of the model state  a user interface element (the user interface.
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.
5-1 GUIs and Events Rick Mercer. 5-2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces to respond.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
CSC 222: Object-Oriented Programming
Microsoft Access 2007 – Level 2
Java GUI.
Graphical User Interface (pronounced "gooey")
Java Programming: From Problem Analysis to Program Design,
Ellen Walker Hiram College
Windows Desktop Applications
PC02 Consolidation %WITTY_QUOTE%. PC02 Consolidation %WITTY_QUOTE%
Constructors, GUI’s(Using Swing) and ActionListner
First Window Builder Program
Presentation transcript:

Using the Netbeans GUI Builder

The Netbeans IDE provides a utility called the GUI Builder that assists you with creating Windows applications. The Netbeans IDE provides a utility called the GUI Builder that assists you with creating Windows applications. The GUI Builder offers similar functionality to Visual Basic. The GUI Builder offers similar functionality to Visual Basic. It automatically creates code for you. You don’t have to manually write code for: It automatically creates code for you. You don’t have to manually write code for: GUI components. GUI components. Event Listeners. Event Listeners.

There are 2 ways to access the GUI builder. There are 2 ways to access the GUI builder. 1. If you are already creating a Java application: 1. If you are already creating a Java application: Right click on the project. Right click on the project. Select “JFrame.” Select “JFrame.” The GUI Builder and the palette will come up. The GUI Builder and the palette will come up. 2. If you are creating a new Java application: 2. If you are creating a new Java application: File  New Project  Under “Projects” select “Java Desktop Application”  Click “Next” File  New Project  Under “Projects” select “Java Desktop Application”  Click “Next”

Name your project and click “Finish.” Name your project and click “Finish.”

Here is what the interface for the GUI Builder looks like:

Let’s take a quick look at the individual components of the GUI Builder…. Let’s take a quick look at the individual components of the GUI Builder…. Project Window Project Window Design Window / Source Code Window Design Window / Source Code Window Palette Palette GUI Components Properties Window GUI Components Properties Window

The Project Window is the same. The Java class that you will be working with is the one that ends with the word “View.”

The Design Window allows you to toggle back and forth between the Design View and the Source View for the code.

The Palette gives you the ability to drag and drop GUI components onto the JFrame.

The Properties Window contains the properties for the GUI components. The Properties Window contains the properties for the GUI components. This is similar to the properties window in Visual Basic. This is similar to the properties window in Visual Basic.

To add a panel: To add a panel: Drag and Drop a panel from the palette onto the JFrame. Drag and Drop a panel from the palette onto the JFrame. Reposition the panel on the JFrame. Reposition the panel on the JFrame.

To add a border and title to the panel: To add a border and title to the panel: Click on the button beside the border property in the Properties Window Click on the button beside the border property in the Properties Window Select “Titled Border” at the bottom, and then type in your title text. Select “Titled Border” at the bottom, and then type in your title text.

Now your panel has a border and a title: Now your panel has a border and a title:

Continue to drag and drop components to the panel: Continue to drag and drop components to the panel: Netbeans will automatically give the GUI components generic names like “jLabel1.” Netbeans will automatically give the GUI components generic names like “jLabel1.”

To edit the display text of the GUI components: To edit the display text of the GUI components: Right click the component and select “Edit Text” Right click the component and select “Edit Text”OR Click the component and wait half a second… Click the component and wait half a second…OR Change the text property in the properties window. Change the text property in the properties window.

To change the border of a label: To change the border of a label: Find the “border” property in the Properties Window Find the “border” property in the Properties Window To change the alignment of a GUI component: To change the alignment of a GUI component: Find the “horizontal alignment” property in the Properties Window Find the “horizontal alignment” property in the Properties Window Hold down Ctrl and click on multiple objects to move more than one at a time. This helps with formatting. Hold down Ctrl and click on multiple objects to move more than one at a time. This helps with formatting.

Here is our updated JFrame: Here is our updated JFrame:

Notice that if you switch to the Source Code view, you can see the section of code that defines your GUI components: Notice that if you switch to the Source Code view, you can see the section of code that defines your GUI components: Netbeans does not allow you to manually change the code they generate. Netbeans does not allow you to manually change the code they generate.

To change the name of a GUI component: To change the name of a GUI component: Click on the GUI component. Click on the GUI component. Go to the Property Window. Go to the Property Window. Select “Code” Select “Code” Change the Variable Name property. Change the Variable Name property.

It is often helpful to rename your GUI components to easily recognizable names. It is often helpful to rename your GUI components to easily recognizable names. In our example I renamed: In our example I renamed: jTextField1 to jTextNum1 jTextField1 to jTextNum1 jTextField2 to jTextNum2 jTextField2 to jTextNum2 jButton1 to jButtonAdd jButton1 to jButtonAdd jButton2 to jButtonSubtract jButton2 to jButtonSubtract Ect…. Ect….

Creating an Event Listener for a GUI component is easy. Creating an Event Listener for a GUI component is easy. Right-click the button (or GUI component). Right-click the button (or GUI component). Choose  Events  Action  actionPerformed. Choose  Events  Action  actionPerformed. Type the code in the space provided. Type the code in the space provided. For example, if we follow these steps for our Exit button, we would then type the following code: For example, if we follow these steps for our Exit button, we would then type the following code:

Here is the code for the Clear Button: Here is the code for the Clear Button: private void jButtonClearActionPerformed(java.awt.event.ActionEvent evt) { // This clears the text fields and labels jLabelResult.setText(" "); jLabelSymbol.setText(" ? "); jTextNum1.setText(" "); jTextNum2.setText(" "); }

Here is the code for the Add Button: Here is the code for the Add Button: private void jButtonAddActionPerformed(java.awt.event.ActionEvent evt) { //Declare variables int intResult; int intNum1; int intNum2; //Get information from text fields intNum1 = Integer.parseInt(jTextNum1.getText()); intNum2 = Integer.parseInt(jTextNum2.getText()); //Perform calculations intResult = intNum1 + intNum2; //Return and display data jLabelResult.setText(String.valueOf(intResult)); //Set symbol jLabelSymbol.setText(" + "); }

To change the Window Title: To change the Window Title: Go to the “.resources” folder in the Project Window. Go to the “.resources” folder in the Project Window. Select the section that ends in “…App.properties” Select the section that ends in “…App.properties” Change the “Application.title” property Change the “Application.title” property

To change the color of a panel (or any other GUI component): To change the color of a panel (or any other GUI component): Select the component. Select the component. In the Property Window, select “background” In the Property Window, select “background” Select your color. Select your color. If you don’t like it, just select “Reset to default.” If you don’t like it, just select “Reset to default.”

Now you can let Netbeans do the hard work! Now you can let Netbeans do the hard work!