0% found this document useful (0 votes)
2 views

Advances Java 4

This document is a presentation on using the Netbeans IDE for Java development, specifically focusing on the Swing API components. It covers the basic layout of Netbeans, how to create a new project and JFrame, and the process of adding GUI components and functionality. The document provides step-by-step instructions for setting up a simple application that takes user input and displays it on the interface.

Uploaded by

James Bataller
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Advances Java 4

This document is a presentation on using the Netbeans IDE for Java development, specifically focusing on the Swing API components. It covers the basic layout of Netbeans, how to create a new project and JFrame, and the process of adding GUI components and functionality. The document provides step-by-step instructions for setting up a simple application that takes user input and displays it on the interface.

Uploaded by

James Bataller
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Java

Netbeans
Topic 4

Created by: Mr. Rogie Montoya


Subject: Advance Java
Introduction of Netbeans

In this presentation you will learn how to use components offer by


Swing API in Java Netbeans. You will also be introduced by some basic
things like Palette, Design Area, the Property Editor, and the Inspector
which are very useful to know.
Introduction of Netbeans

What is an IDE?
IDE(Integrated Development Environment) is a programming
environment integrated into a software application that provides a GUI
builder, a text or code editor, a compiler and/or interpreter and a
debugger. Visual Studio,Netbeans and DreamWeaver are all examples of
IDEs.

What is java?
java is a object oriented programming language which enables you to
create applications.
Requirements

• Install JAVA JDK.

• Install Netbeans IDE


Creating a Netbeans
project

 Navigate to File > New Project


Creating a Netbeans
project

 Select java in categories and java


Applications in projects
Creating a Netbeans
project

 Give project name uncheck


create main class and click Finish
Creating a Netbeans
project

• You can finally see your project


in Projects.
• Later on, we will create
JFrame in it after discussing
the environment of Netbeans
Netbeans IDE Layout
Title Bar

• The tittle bar displays the tittle of the application. By default,


Netbeans will give names as DesktopApplication1,
DesktopApplication2 etc. to your project. Notice in following figure, it
has given title DesktopApplication1 to your application.
Menu Bar

• You are familiar with menu bars as you have worked with MS-
Windows operating system.
• A menu bar is displayed directly below the title bar and includes a lot
of options. Each option on the menu bar has a drop down list of item
(known as Pull-down menus) that helps you to perform various tasks.
Toolbar

• A tool bar is a bar that displays icons for commonly used tasks.
• The standard toolbar of Netbeans IDE displays icons for the most
frequency used commands in Netbeans.
Project Window

• The Projects window is the main entry point to your project sources.
It shows a logical view of important project content.
• In addition to the Projects window, the IDE
provides the Files window, so that you can
see all the files that belong to a project,
and the Favorites window, where you can
add folders and files so that they can be
browsed within the IDE.
Navigator

• The GUI Builder's primary window for creating and editing Java GUI
forms. The toolbar's Source button enables you to view a class's source
code, the Design button allows you to view a
graphical view of the GUI components, the
History button allows you to access the local
history of changes of the file.
• The additional toolbar buttons provide
convenient access to common commands
, such as choosing between Selection and
Connection modes, aligning components,
setting component auto-resizing behavior,
and previewing forms.
Palette

• Pallete contains all components which you can use while making a
GUI application. The Pallete provides you components like
jTextField,jLabel etc. You can design Swing GUIs by dragging GUI
components from a palette onto a canvas.
Design Area

• Design area is where you can drag the components from Pallete and
design the GUI application. In Netbeans you are provided with an
option to toggle between source and Design by clicking in button
provided. For Ex- In this I have designed a GUI using swing
components in jFrame object .
Source Code

• Take a quick look at Source Code View where you can add the code
for components.
Properties

• The Properties edits the property of Swing Components. You can edit
properties very easily using this property editor. You can see it in the
screenshot provided.
Working Area

• Well, it’s the main area of NetBeans IDE. Usually looks like and code
edition area, but it’s also an User Interface visual compositor.
• As an code edition area is the real core of NetBeans IDE. This is really
optimized for code management and it has a lot of improvements
version by version.
Output Area

• If the user starts some action like Run file, Run project, Build project
etc. the system shows the output window. This output window
should have toolbar placed in the edge. On this toolbar should be
placed icons. These icons should allow:
– to repeat the last action
– stop application
– to allow the user to filter the outputs shown in the output window
JFrame

• A Jframe forms acts as a container to place other components like


the button, text field and text area etc.

• We can create as many forms we want in


a Netbeans Project.
Creating a JFrame in
Project

• To Create a new jFrame click project name in projects and right


click>New>jframe Form
Creating a JFrame in
Project

• To Create a new jFrame click project name in projects and right


click>New>jframe Form.. And then dialog will open where you have to
give name and click on Finish
Creating a JFrame in
Project

• Now your JFrame is created and now you can add components like
Label, Button, Text Field etc.
• You can see The jFrame is
indicated with red indicator
in Project Folder as well as
in Design view.
Creating a JFrame in
Project

• Now you can add swing components from Palette by draging on to


the design view and arranging according to your idea.
• The Palette is indicated
with red border.
Creating a JFrame in
Project

• Now I have added jlabel,jTextField and Button to the jFrame.


• The jTextField is indicated with Red indicator, jButton with Blue and
jlabel with brown indicator.
Creating a JFrame in
Project

• As we have now added the components we can edit the variable


name, text of the components by just selecting them in the jFrame
and right click.
• As you can see we can edit
the text, change variable
name, properties and so on.
Creating a JFrame in
Project

• Now as a example we can make a application where user will enter


the name in jTextField and will get the name back in jLabel after
clicking on the jButton.
• To achieve it we have already designed the layout but have to add
functionality by adding code in the jButton as all the task will be done
after clicking the button.
Creating a JFrame in
Project

• To add Code double click on button and you will be switched


automatically to Source Code.
Creating a JFrame in
Project

• Adding the Following code written in Red Block.


Creating a JFrame in
Project

• Before you complete, check the component names as it may be


different in your and my case.
• In My Case: jLabel1,jTextField1.
• You can change the component name by going to Design and
selecting component then right click and navigate to change variable
name.
• Now its done, and you can run it by holding Shift key and F6 together.
• Wait and the Application will run like the screenshot below.
Creating a JFrame in
Project

• Just test it by Typing your name and clicking “CLICK ME”. You should
get the text you written in jLabel.

You might also like