SlideShare una empresa de Scribd logo
1 de 31
GUI PROGRAMMING
A REVIEW
NET BEANS IDE
 It is used to create java applications using the efficient GUI builder.
 IDE is an acronym for Integrated Development Environment which is a work
environment that integrates all tools necessary forApplication
Development and makes them available as part of one environment.
 GUI is an acronym forGraphical User Interface which is an interface that
allows us to interact with the various components through visual elements
including pictures, graphical icons, symbols and visual indicators
COMPONENTS OF NET BEANS
COMPONENTS
TITLE BAR MENU BAR TOOL BAR GUI BUILDER PALATTE
INSPECTOR
WINDOW
PROPERTIES
WINDOW
CODE EDITOR
WINDOW
It is an area
to place
components
on the form
visually.
There are
two views of
the GUI
builder- the
DesignView
and the
SourceView.
It
contains
controls
or
compone
nts used
to create
GUI
applicatio
ns.
It is used to
display
hierarchical
relationship
among all
the
controls
placed on
the current
form.
It is used
to
view/edit
properties
of
currently
selected
control on
the form.
It is the
area
where
we write
code.
PROJECT
WINDOW
INSPECTOR
WINDOW
PALATTE
PROPERTIE
SWINDOWDESIGNAREA
NET BEANS GUI INTERFACE
PROJECT, FORM AND
COMPONENTS
 Each application is treated as
a Project in NetBeans.
 Each project can have one or
multiple forms.
 Each form can have one or
more components.
PROJECT
FORM1
COMPONENTS
FORM3
COMPONENTS
FORM4
COMPONENTS
FORM2
COMPONENTS
COMPONENTS/CONTROLS
CONTROLS
PARENT/CONTAINER
CONTROL
CHILD CONTROL
They act as background for other
controls. For eg. Frame. When we
delete/move a parent control, all its
child controls get deleted/moved.
Controls placed inside a
container control are called
child control. For eg. Button,
text field, label etc.
Some of these
components may be
visible and some
invisible.The visible
components are all
shown under the
FrameComponent
and the non-visible
components are part
of Other components
in the Inspectors
window.
DESIGNING AN APPLICATION
1. Create a new project.
2. Add a new jFrame form.
3. Add the components on this jFrame
.
4. Associate the code with the
component by double clicking the
component.
5. Add the source code.
6. Test the form by pressing shift+F6.
STEP 1
STEP 2
DESIGNING AN APPLICATION Contd…
OBJECTS
PROPERTIES METHODS
GETTERS SETTERS
EVENTS
Properties specify
the appearance of
an object on the
form. For eg. Font,
background etc.
These methods extract some
information from the object
and return it to the program.
They start with the word get.
For eg. getText(), isEditable()
etc.
These methods set some
properties of the object so
that the object's appearance
changes.They start with the
word set. For eg. setText(),
setForground(), etc.
These are the actions
performed on controls. For
eg.mouseClick, keyPressed
etc.When the user performs
any action on a control, an
event happens and that event
invokes the corresponding part
of the code and the application
behaves accordingly.
All the components including jFrame are
considered as objects in java.
Each object has some properties, methods,
and events associated with it.
CREATING A PROJECT
To create a new application project called “Students":
1. Choose File > New Project. Alternately, click the New
Project icon in the toolbar.
2. From the Categories pane select Java and in the Projects
pane, choose Java Application. Click Next.
3. Enter a name (in this case students) in the Project Name
field and specify the project location by clicking on the
Browse button. By default the project is saved in the
NetBeans Projects folder in My Documents.
4. Ensure that the Set as Main Project checkbox is selected
and clear the Create Main Class field.
5. Click Finish.
JFRAME FORM
Forms are used to accept data (input) from users and
respond to actions like clicking on a button.
ADDING FRAME:To create a JFrame Form container:
1. In the Projects window, right-click the Book node and
choose New > Jframe Form.
2. Enter Form Example 1 as the Class Name.This will be
the name of your form.
3. Enter Book as the package.This should be the name
given while creating the Project.
4. Click Finish
OPTION PANE
Option Pane is used when we want to request information from the user, display information
to the user or a combination of both. It requires the following import statement at the top of
the program.
import javax.swing.JOptionPane;
OR
import javax.swing.*;
METHOD DESCRIPTION EXAMPLE
showMessageDialog() Shows a one-button, modal dialog box that
gives the user some information.
JOptionPane.showMessageDialog(t
his,“Lets learn Java”);
showConfirmDialog() Shows a three-button modal dialog that asks
the user a question. User can respond by
pressing any of the suitable buttons.
Confirm=
JOptionPane.showConfirmDialog(nu
ll,"quit?")
showInputDialog() Shows a modal dialog that prompts the user for
input. It prompts the user with a text box in
which the user can enter the relevant input.
name=
JOptionPane.showInputDialog(this,“
ENTER ROLL NUMBER:");
Steps for developing a Simple application
Step 1: Create a new Project
Step 2: Add a JFrame form
Step 3: Add the desired component from the Palette window using drag
and drop feature
Step 4: Associate code with the component by double clicking the
component.
Step 5: Add the source code.
Step 6:Test the form by pressing Shift+F6.
DEVELOPING A SIMPLE APPLICATION
BUTTON CONTROL
A button is a component that the user presses or pushes to trigger a specific
action.When the user clicks on the button at runtime, the code associated
with the click action gets executed.
PROPERTY DESCRIPTION
BACKGROUND Sets background color
FOREGROUND Sets foreground color
FONT Sets font of text on button
TEXT Sets the text displayed on
button
METHODS DESCRIPTION EXAMPLE
setEnabled() Enables/disables the button JButton1.setEnabled(false); jbutton1.setEnabled(true);
setVisible() Visible/invisible the button JButton1.setVisible(false); jbutton1.setVisible(true);
BUTTON CONTROL AND JOPTION PANE
EXAMPLE
LABEL CONTROL
Label provides text instructions or information. It displays a single line of
read-only text, an image or both text and image.
PROPERTY DESCRIPTION
BACKGROUND Sets background color
FOREGROUND Sets foreground color
FONT Sets font of text on button
TEXT Sets the text displayed on
button
METHODS DESCRIPTION EXAMPLE
isEnabled() Returns true if label is enabled else false Boolean b= jLabel1.isEnabled();
setVisible() Visible/invisible the button jLabel1.setVisible(false); jLabel1.setVisible(true);
setText() Sets the text on label at run time JLable1.setText(“Enter name”);
LABEL AND BUTTON CONTROL EXAMPLE
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
jLabel1.setForeground(Color.red);
}
private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
jLabel1.setForeground(Color.green);
}
private void
jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
jLabel1.setForeground(Color.blue);
}
Q. WAP to create a form having a label and three buttons. If the red button is pressed the
text in the label should change to red colour and so on.
TEXT FIELD CONTROL
Text Field allows editing/displaying of a single line of text. For eg. Name, Phone
number etc.
PROPERTY DESCRIPTION
BACKGROUND Sets background color
FOREGROUND Sets foreground color
FONT Sets font of text on button
TEXT Sets the text displayed on button
METHODS DESCRIPTION EXAMPLE
isEnabled() Returns true if text field is enabled else false boolean b= jTextfield1.isEnabled();
setVisible() Visible/invisible the button jTextfield1.setVisible(false);
setText() Sets the text on text field at run time jTextfield1.setText(“WELCOME”);
getText() Gets the text from the text field string str = jTextfield1.getText();
isEditable() Returns true if the component is editable else false. boolean b= jTextfield1.isEditable();
setEditable() true if text in the text field is editable else false. JTextfield1.setEditable(true);
LABEL ANDTEXT FIELD CONTROL
EXAMPLE
PASSWORD CONTROL
It is used to enter confidential input like passwords which are single line. It suppress the display
of input and each character entered can be replaced by an echo character. By default, the echo
character is the asterisk, *.
PROPERTY DESCRIPTION
BACKGROUND Sets background color
FOREGROUND Sets foreground color
FONT Sets font of text on button
TEXT Sets the text displayed on button
echoChar Sets the character that will be
displayed instead of text.
PASSWORD CONTROL EXAMPLE
RADIO BUTTON CONTROL
Radio button is used when user has to select one option out of many mutually
exclusive options given. For eg. Gender(male or female),
PROPERTY DESCRIPTION
buttonGroup Specifies the name of the group of button to which
the jRadioButton belongs.
Selected Sets the button as selected, if set to true, default is
false.
METHODS DESCRIPTION EXAMPLE
isSelected() Returns true if radio button is checked else false boolean b= jRadiobutton1.isSelected();
setSelected() Checks(true) or unchecks the radio button. jRadiobutton1.setSelected(false);
setText() Sets the text on radio button at run time jRadiobutton1.setText(“WELCOME”);
RADIO BUTTON CONTROL EXAMPLE
TEXT AREA CONTROL
Text area allows editing/displaying of a multi line text. It automatically adds
vertical or horizontal scroll bars as and when required during run time. For eg.
Comments, address etc.
PROPERTY DESCRIPTION
lineWrap Indicates whether line of text should wrap in case it exceeds allocated
width.(Default is false)
wrapStyleWord Sends word to next line in case lineWrap is true else it results in
breaking of a word, when lines are wrapped.
rows/columns Sets number of rows/columns preferred for display.
text Sets the text displayed on button
METHODS DESCRIPTION EXAMPLE
isEnabled() Returns true if text field is enabled else false boolean b= jTextarea1.isEnabled();
setText() Sets the text on text field at run time jTextarea1.setText(“WELCOME”);
getText() Gets the text from the text field string str = jTextarea1.getText();
isEditable() Returns true if the component is editable else false. boolean b= jTextarea1.isEditable();
append() Adds text at the end JTextarea1.append(“we are studying JAVA”);
CHECK BOX CONTROL
Check box is used when multiple options are given to the user and the user
can select zero or more out of the given options.
PROPERTY DESCRIPTION
buttonGroup Specifies the name of the group of button to which
the check box belongs.
Selected Sets the check box as selected, if set to true, default
is false.
METHODS DESCRIPTION EXAMPLE
isSelected() Returns true if check box is checked else false boolean b= jCheckbox1.isSelected();
setSelected() Checks(true) or unchecks the check box. jCheckbox1.setSelected(false);
setText() Sets the text on check box at run time jCheckbox1.setText(“WELCOME”);
CHECK BOX ANDTEXT AREA CONTROL
EXAMPLE
LIST CONTROL
 A list is a scrollable set of items, used
to get one or more options out of
several given options which may or
may not be mutually exclusive.
 Lists are preferred over checkboxes
when there are large number of
options.
 In such case using Check Boxes may
take up a lot of space on the form and
it may also be inconvenient for the
user to select the desired options.
LIST CONTROL Contd…….
PROPERTY DESCRIPTION
model Contains the values to be displayed in the list.
selectedIndex Contains the index value of selected option of the control.
SelectionMode Describes the mode for selecting values.
- SINGLE (List box allows single selection only)
- SINGLE_INTERVAL (List box allows single continuous
selection of options using shift key of keyboard)
- MULTIPLE_INTERVAL (List box allows multiple
selections of options using ctrl key of keyboard)
METHODS DESCRIPTION EXAMPLE
getSelectedV
alue()
Returns the selected value when only a single
item is selected, if multiple items are selected
then returns first selected value. Returns null in
case no item selected.
jList1.getSelectedValue();
isSelectedInd
ex()
Returns true if specified index is selected. Boolean b= jList1.isSelectedindex();
LIST CONTROL EXAMPLE
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
jTextField1.setText(" "+jList1.getSelectedValue());
jTextField2.setText(" "+jList1.getSelectedIndex());
}
QWAP to create the following form. On click of the button the index number
and river name selected from the list should be displayed in the respective
text fields.
NOTE:The index numbers start from zero.
COMBO BOX CONTROL
 A combo box is a drop down box of
items, used to get one option out of
several given mutually exclusive
options.
 Combo box are preferred over radio
button when there are large number of
options.
 In such case using radio buttons may
take up a lot of space on the form and it
may also be inconvenient for the user to
select the desired options.
COMBO BOX CONTROL
Contd…….
PROPERTY DESCRIPTION
model Contains the values to be displayed.
selectedIndex/selectedItem Contains the index value/selected item of selected option of the control.
METHODS DESCRIPTION EXAMPLE
getSelectedItem() Returns the selected value. jCombobox1.getSelectedItem();
getSelectedIndex() Returns the selected index Boolean b= jCombobox1.getSelectedindex();
setModel() Sets the data model that the combo box
uses to get its list of elements.
jCombobox1.setModel(ComboBoxModel
aModel);
COMBO BOX CONTROL EXAMPLE
private void
jButton1ActionPerformed(java.awt.event.ActionEvent
evt) {
jTextField1.setText(""+jComboBox1.getSelectedItem());
}
QWAP to create the following form. On click of the button river selected from
the combo box should be displayed in the text field.
CODE OUTPUT SCREEN

Más contenido relacionado

La actualidad más candente (20)

Android User Interface
Android User InterfaceAndroid User Interface
Android User Interface
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
Java awt
Java awtJava awt
Java awt
 
Vb.net class notes
Vb.net class notesVb.net class notes
Vb.net class notes
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
Js ppt
Js pptJs ppt
Js ppt
 
Android intents
Android intentsAndroid intents
Android intents
 
JavaScript - Chapter 6 - Basic Functions
 JavaScript - Chapter 6 - Basic Functions JavaScript - Chapter 6 - Basic Functions
JavaScript - Chapter 6 - Basic Functions
 
Vectors in Java
Vectors in JavaVectors in Java
Vectors in Java
 
Built in function
Built in functionBuilt in function
Built in function
 
Java swing
Java swingJava swing
Java swing
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
 
Class and object
Class and objectClass and object
Class and object
 
Android Location and Maps
Android Location and MapsAndroid Location and Maps
Android Location and Maps
 
Android SDK Tutorial | Edureka
Android SDK Tutorial | EdurekaAndroid SDK Tutorial | Edureka
Android SDK Tutorial | Edureka
 
Java keywords
Java keywordsJava keywords
Java keywords
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 

Destacado

GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Javayht4ever
 
CBSE XII Communication And Network Concepts
CBSE XII Communication And Network ConceptsCBSE XII Communication And Network Concepts
CBSE XII Communication And Network ConceptsGuru Ji
 
BASIC CONCEPTS OF COMPUTER NETWORKS
BASIC CONCEPTS OF COMPUTER NETWORKS BASIC CONCEPTS OF COMPUTER NETWORKS
BASIC CONCEPTS OF COMPUTER NETWORKS Kak Yong
 
Introduction to java netbeans
Introduction to java netbeansIntroduction to java netbeans
Introduction to java netbeansShrey Goswami
 
Basic of Java Netbeans
Basic of Java NetbeansBasic of Java Netbeans
Basic of Java NetbeansShrey Goswami
 
Introduction to computer network
Introduction to computer networkIntroduction to computer network
Introduction to computer networkAshita Agrawal
 

Destacado (10)

GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
 
CBSE XII Communication And Network Concepts
CBSE XII Communication And Network ConceptsCBSE XII Communication And Network Concepts
CBSE XII Communication And Network Concepts
 
BASIC CONCEPTS OF COMPUTER NETWORKS
BASIC CONCEPTS OF COMPUTER NETWORKS BASIC CONCEPTS OF COMPUTER NETWORKS
BASIC CONCEPTS OF COMPUTER NETWORKS
 
Net Beans
Net BeansNet Beans
Net Beans
 
Chapter8 my sql revision tour
Chapter8 my sql revision tourChapter8 my sql revision tour
Chapter8 my sql revision tour
 
C++ revision tour
C++ revision tourC++ revision tour
C++ revision tour
 
Introduction to java netbeans
Introduction to java netbeansIntroduction to java netbeans
Introduction to java netbeans
 
Basic of Java Netbeans
Basic of Java NetbeansBasic of Java Netbeans
Basic of Java Netbeans
 
Networking ppt
Networking ppt Networking ppt
Networking ppt
 
Introduction to computer network
Introduction to computer networkIntroduction to computer network
Introduction to computer network
 

Similar a GUI programming

Gui programming a review - mixed content
Gui programming   a review - mixed contentGui programming   a review - mixed content
Gui programming a review - mixed contentYogesh Kumar
 
Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892renuka gavli
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in javaAdil Mehmoood
 
Gui builder
Gui builderGui builder
Gui builderlearnt
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Javasuraj pandey
 
ITS-16163-Module 8-Graphic User Interface (GUI)
ITS-16163-Module 8-Graphic User Interface (GUI)ITS-16163-Module 8-Graphic User Interface (GUI)
ITS-16163-Module 8-Graphic User Interface (GUI)oudesign
 
Chap 1 - Introduction GUI.pptx
Chap 1 - Introduction GUI.pptxChap 1 - Introduction GUI.pptx
Chap 1 - Introduction GUI.pptxTadeseBeyene
 
Computer homework
Computer homeworkComputer homework
Computer homeworkadarsh-kaul
 
Computer homework
Computer homeworkComputer homework
Computer homeworkadarsh-kaul
 
toolbox and its properties in the visual basic
toolbox and its properties in the visual basictoolbox and its properties in the visual basic
toolbox and its properties in the visual basicadarsh-kaul
 
Z blue introduction to gui (39023299)
Z blue   introduction to gui (39023299)Z blue   introduction to gui (39023299)
Z blue introduction to gui (39023299)Narayana Swamy
 
SWING USING JAVA WITH VARIOUS COMPONENTS
SWING USING  JAVA WITH VARIOUS COMPONENTSSWING USING  JAVA WITH VARIOUS COMPONENTS
SWING USING JAVA WITH VARIOUS COMPONENTSbharathiv53
 
1) Write a shortsnippetofcodethatcreates a J Panel objectcalled p1, .pdf
1) Write a shortsnippetofcodethatcreates a J Panel objectcalled p1, .pdf1) Write a shortsnippetofcodethatcreates a J Panel objectcalled p1, .pdf
1) Write a shortsnippetofcodethatcreates a J Panel objectcalled p1, .pdfoptokunal1
 

Similar a GUI programming (20)

Gui programming a review - mixed content
Gui programming   a review - mixed contentGui programming   a review - mixed content
Gui programming a review - mixed content
 
Ingles 2do parcial
Ingles   2do parcialIngles   2do parcial
Ingles 2do parcial
 
Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
 
GUI components in Java
GUI components in JavaGUI components in Java
GUI components in Java
 
Gui builder
Gui builderGui builder
Gui builder
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Java
 
ITS-16163-Module 8-Graphic User Interface (GUI)
ITS-16163-Module 8-Graphic User Interface (GUI)ITS-16163-Module 8-Graphic User Interface (GUI)
ITS-16163-Module 8-Graphic User Interface (GUI)
 
Notes netbeans
Notes netbeansNotes netbeans
Notes netbeans
 
Chap 1 - Introduction GUI.pptx
Chap 1 - Introduction GUI.pptxChap 1 - Introduction GUI.pptx
Chap 1 - Introduction GUI.pptx
 
Java swing
Java swingJava swing
Java swing
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
 
Computer homework
Computer homeworkComputer homework
Computer homework
 
Computer homework
Computer homeworkComputer homework
Computer homework
 
toolbox and its properties in the visual basic
toolbox and its properties in the visual basictoolbox and its properties in the visual basic
toolbox and its properties in the visual basic
 
Z blue introduction to gui (39023299)
Z blue   introduction to gui (39023299)Z blue   introduction to gui (39023299)
Z blue introduction to gui (39023299)
 
SWING USING JAVA WITH VARIOUS COMPONENTS
SWING USING  JAVA WITH VARIOUS COMPONENTSSWING USING  JAVA WITH VARIOUS COMPONENTS
SWING USING JAVA WITH VARIOUS COMPONENTS
 
ch20.pptx
ch20.pptxch20.pptx
ch20.pptx
 
Java Swing
Java SwingJava Swing
Java Swing
 
1) Write a shortsnippetofcodethatcreates a J Panel objectcalled p1, .pdf
1) Write a shortsnippetofcodethatcreates a J Panel objectcalled p1, .pdf1) Write a shortsnippetofcodethatcreates a J Panel objectcalled p1, .pdf
1) Write a shortsnippetofcodethatcreates a J Panel objectcalled p1, .pdf
 

Más de Vineeta Garg

Classes and objects1
Classes and objects1Classes and objects1
Classes and objects1Vineeta Garg
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructorsVineeta Garg
 
Structured query language functions
Structured query language functionsStructured query language functions
Structured query language functionsVineeta Garg
 
Structured query language constraints
Structured query language constraintsStructured query language constraints
Structured query language constraintsVineeta Garg
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++Vineeta Garg
 
Data file handling in c++
Data file handling in c++Data file handling in c++
Data file handling in c++Vineeta Garg
 

Más de Vineeta Garg (9)

Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Queues in C++
Queues in C++Queues in C++
Queues in C++
 
Classes and objects1
Classes and objects1Classes and objects1
Classes and objects1
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Structured query language functions
Structured query language functionsStructured query language functions
Structured query language functions
 
Structured query language constraints
Structured query language constraintsStructured query language constraints
Structured query language constraints
 
SQL
SQLSQL
SQL
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Data file handling in c++
Data file handling in c++Data file handling in c++
Data file handling in c++
 

Último

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 

Último (20)

Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 

GUI programming

  • 2. NET BEANS IDE  It is used to create java applications using the efficient GUI builder.  IDE is an acronym for Integrated Development Environment which is a work environment that integrates all tools necessary forApplication Development and makes them available as part of one environment.  GUI is an acronym forGraphical User Interface which is an interface that allows us to interact with the various components through visual elements including pictures, graphical icons, symbols and visual indicators
  • 3. COMPONENTS OF NET BEANS COMPONENTS TITLE BAR MENU BAR TOOL BAR GUI BUILDER PALATTE INSPECTOR WINDOW PROPERTIES WINDOW CODE EDITOR WINDOW It is an area to place components on the form visually. There are two views of the GUI builder- the DesignView and the SourceView. It contains controls or compone nts used to create GUI applicatio ns. It is used to display hierarchical relationship among all the controls placed on the current form. It is used to view/edit properties of currently selected control on the form. It is the area where we write code.
  • 5. PROJECT, FORM AND COMPONENTS  Each application is treated as a Project in NetBeans.  Each project can have one or multiple forms.  Each form can have one or more components. PROJECT FORM1 COMPONENTS FORM3 COMPONENTS FORM4 COMPONENTS FORM2 COMPONENTS
  • 6. COMPONENTS/CONTROLS CONTROLS PARENT/CONTAINER CONTROL CHILD CONTROL They act as background for other controls. For eg. Frame. When we delete/move a parent control, all its child controls get deleted/moved. Controls placed inside a container control are called child control. For eg. Button, text field, label etc. Some of these components may be visible and some invisible.The visible components are all shown under the FrameComponent and the non-visible components are part of Other components in the Inspectors window.
  • 7. DESIGNING AN APPLICATION 1. Create a new project. 2. Add a new jFrame form. 3. Add the components on this jFrame . 4. Associate the code with the component by double clicking the component. 5. Add the source code. 6. Test the form by pressing shift+F6. STEP 1 STEP 2
  • 8. DESIGNING AN APPLICATION Contd… OBJECTS PROPERTIES METHODS GETTERS SETTERS EVENTS Properties specify the appearance of an object on the form. For eg. Font, background etc. These methods extract some information from the object and return it to the program. They start with the word get. For eg. getText(), isEditable() etc. These methods set some properties of the object so that the object's appearance changes.They start with the word set. For eg. setText(), setForground(), etc. These are the actions performed on controls. For eg.mouseClick, keyPressed etc.When the user performs any action on a control, an event happens and that event invokes the corresponding part of the code and the application behaves accordingly. All the components including jFrame are considered as objects in java. Each object has some properties, methods, and events associated with it.
  • 9. CREATING A PROJECT To create a new application project called “Students": 1. Choose File > New Project. Alternately, click the New Project icon in the toolbar. 2. From the Categories pane select Java and in the Projects pane, choose Java Application. Click Next. 3. Enter a name (in this case students) in the Project Name field and specify the project location by clicking on the Browse button. By default the project is saved in the NetBeans Projects folder in My Documents. 4. Ensure that the Set as Main Project checkbox is selected and clear the Create Main Class field. 5. Click Finish.
  • 10. JFRAME FORM Forms are used to accept data (input) from users and respond to actions like clicking on a button. ADDING FRAME:To create a JFrame Form container: 1. In the Projects window, right-click the Book node and choose New > Jframe Form. 2. Enter Form Example 1 as the Class Name.This will be the name of your form. 3. Enter Book as the package.This should be the name given while creating the Project. 4. Click Finish
  • 11. OPTION PANE Option Pane is used when we want to request information from the user, display information to the user or a combination of both. It requires the following import statement at the top of the program. import javax.swing.JOptionPane; OR import javax.swing.*; METHOD DESCRIPTION EXAMPLE showMessageDialog() Shows a one-button, modal dialog box that gives the user some information. JOptionPane.showMessageDialog(t his,“Lets learn Java”); showConfirmDialog() Shows a three-button modal dialog that asks the user a question. User can respond by pressing any of the suitable buttons. Confirm= JOptionPane.showConfirmDialog(nu ll,"quit?") showInputDialog() Shows a modal dialog that prompts the user for input. It prompts the user with a text box in which the user can enter the relevant input. name= JOptionPane.showInputDialog(this,“ ENTER ROLL NUMBER:");
  • 12. Steps for developing a Simple application Step 1: Create a new Project Step 2: Add a JFrame form Step 3: Add the desired component from the Palette window using drag and drop feature Step 4: Associate code with the component by double clicking the component. Step 5: Add the source code. Step 6:Test the form by pressing Shift+F6. DEVELOPING A SIMPLE APPLICATION
  • 13. BUTTON CONTROL A button is a component that the user presses or pushes to trigger a specific action.When the user clicks on the button at runtime, the code associated with the click action gets executed. PROPERTY DESCRIPTION BACKGROUND Sets background color FOREGROUND Sets foreground color FONT Sets font of text on button TEXT Sets the text displayed on button METHODS DESCRIPTION EXAMPLE setEnabled() Enables/disables the button JButton1.setEnabled(false); jbutton1.setEnabled(true); setVisible() Visible/invisible the button JButton1.setVisible(false); jbutton1.setVisible(true);
  • 14. BUTTON CONTROL AND JOPTION PANE EXAMPLE
  • 15. LABEL CONTROL Label provides text instructions or information. It displays a single line of read-only text, an image or both text and image. PROPERTY DESCRIPTION BACKGROUND Sets background color FOREGROUND Sets foreground color FONT Sets font of text on button TEXT Sets the text displayed on button METHODS DESCRIPTION EXAMPLE isEnabled() Returns true if label is enabled else false Boolean b= jLabel1.isEnabled(); setVisible() Visible/invisible the button jLabel1.setVisible(false); jLabel1.setVisible(true); setText() Sets the text on label at run time JLable1.setText(“Enter name”);
  • 16. LABEL AND BUTTON CONTROL EXAMPLE private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { jLabel1.setForeground(Color.red); } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { jLabel1.setForeground(Color.green); } private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { jLabel1.setForeground(Color.blue); } Q. WAP to create a form having a label and three buttons. If the red button is pressed the text in the label should change to red colour and so on.
  • 17. TEXT FIELD CONTROL Text Field allows editing/displaying of a single line of text. For eg. Name, Phone number etc. PROPERTY DESCRIPTION BACKGROUND Sets background color FOREGROUND Sets foreground color FONT Sets font of text on button TEXT Sets the text displayed on button METHODS DESCRIPTION EXAMPLE isEnabled() Returns true if text field is enabled else false boolean b= jTextfield1.isEnabled(); setVisible() Visible/invisible the button jTextfield1.setVisible(false); setText() Sets the text on text field at run time jTextfield1.setText(“WELCOME”); getText() Gets the text from the text field string str = jTextfield1.getText(); isEditable() Returns true if the component is editable else false. boolean b= jTextfield1.isEditable(); setEditable() true if text in the text field is editable else false. JTextfield1.setEditable(true);
  • 18. LABEL ANDTEXT FIELD CONTROL EXAMPLE
  • 19. PASSWORD CONTROL It is used to enter confidential input like passwords which are single line. It suppress the display of input and each character entered can be replaced by an echo character. By default, the echo character is the asterisk, *. PROPERTY DESCRIPTION BACKGROUND Sets background color FOREGROUND Sets foreground color FONT Sets font of text on button TEXT Sets the text displayed on button echoChar Sets the character that will be displayed instead of text.
  • 21. RADIO BUTTON CONTROL Radio button is used when user has to select one option out of many mutually exclusive options given. For eg. Gender(male or female), PROPERTY DESCRIPTION buttonGroup Specifies the name of the group of button to which the jRadioButton belongs. Selected Sets the button as selected, if set to true, default is false. METHODS DESCRIPTION EXAMPLE isSelected() Returns true if radio button is checked else false boolean b= jRadiobutton1.isSelected(); setSelected() Checks(true) or unchecks the radio button. jRadiobutton1.setSelected(false); setText() Sets the text on radio button at run time jRadiobutton1.setText(“WELCOME”);
  • 23. TEXT AREA CONTROL Text area allows editing/displaying of a multi line text. It automatically adds vertical or horizontal scroll bars as and when required during run time. For eg. Comments, address etc. PROPERTY DESCRIPTION lineWrap Indicates whether line of text should wrap in case it exceeds allocated width.(Default is false) wrapStyleWord Sends word to next line in case lineWrap is true else it results in breaking of a word, when lines are wrapped. rows/columns Sets number of rows/columns preferred for display. text Sets the text displayed on button METHODS DESCRIPTION EXAMPLE isEnabled() Returns true if text field is enabled else false boolean b= jTextarea1.isEnabled(); setText() Sets the text on text field at run time jTextarea1.setText(“WELCOME”); getText() Gets the text from the text field string str = jTextarea1.getText(); isEditable() Returns true if the component is editable else false. boolean b= jTextarea1.isEditable(); append() Adds text at the end JTextarea1.append(“we are studying JAVA”);
  • 24. CHECK BOX CONTROL Check box is used when multiple options are given to the user and the user can select zero or more out of the given options. PROPERTY DESCRIPTION buttonGroup Specifies the name of the group of button to which the check box belongs. Selected Sets the check box as selected, if set to true, default is false. METHODS DESCRIPTION EXAMPLE isSelected() Returns true if check box is checked else false boolean b= jCheckbox1.isSelected(); setSelected() Checks(true) or unchecks the check box. jCheckbox1.setSelected(false); setText() Sets the text on check box at run time jCheckbox1.setText(“WELCOME”);
  • 25. CHECK BOX ANDTEXT AREA CONTROL EXAMPLE
  • 26. LIST CONTROL  A list is a scrollable set of items, used to get one or more options out of several given options which may or may not be mutually exclusive.  Lists are preferred over checkboxes when there are large number of options.  In such case using Check Boxes may take up a lot of space on the form and it may also be inconvenient for the user to select the desired options.
  • 27. LIST CONTROL Contd……. PROPERTY DESCRIPTION model Contains the values to be displayed in the list. selectedIndex Contains the index value of selected option of the control. SelectionMode Describes the mode for selecting values. - SINGLE (List box allows single selection only) - SINGLE_INTERVAL (List box allows single continuous selection of options using shift key of keyboard) - MULTIPLE_INTERVAL (List box allows multiple selections of options using ctrl key of keyboard) METHODS DESCRIPTION EXAMPLE getSelectedV alue() Returns the selected value when only a single item is selected, if multiple items are selected then returns first selected value. Returns null in case no item selected. jList1.getSelectedValue(); isSelectedInd ex() Returns true if specified index is selected. Boolean b= jList1.isSelectedindex();
  • 28. LIST CONTROL EXAMPLE private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { jTextField1.setText(" "+jList1.getSelectedValue()); jTextField2.setText(" "+jList1.getSelectedIndex()); } QWAP to create the following form. On click of the button the index number and river name selected from the list should be displayed in the respective text fields. NOTE:The index numbers start from zero.
  • 29. COMBO BOX CONTROL  A combo box is a drop down box of items, used to get one option out of several given mutually exclusive options.  Combo box are preferred over radio button when there are large number of options.  In such case using radio buttons may take up a lot of space on the form and it may also be inconvenient for the user to select the desired options.
  • 30. COMBO BOX CONTROL Contd……. PROPERTY DESCRIPTION model Contains the values to be displayed. selectedIndex/selectedItem Contains the index value/selected item of selected option of the control. METHODS DESCRIPTION EXAMPLE getSelectedItem() Returns the selected value. jCombobox1.getSelectedItem(); getSelectedIndex() Returns the selected index Boolean b= jCombobox1.getSelectedindex(); setModel() Sets the data model that the combo box uses to get its list of elements. jCombobox1.setModel(ComboBoxModel aModel);
  • 31. COMBO BOX CONTROL EXAMPLE private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { jTextField1.setText(""+jComboBox1.getSelectedItem()); } QWAP to create the following form. On click of the button river selected from the combo box should be displayed in the text field. CODE OUTPUT SCREEN