SlideShare a Scribd company logo
JAVA
Swing
Prepared by
Miss. Arati A. Gadgil
Difference between AWT and Swing
AWT Swing
platform-dependent. platform-independent
heavyweight. lightweight.
doesn't support pluggable look supports pluggable look and
feel. and feel.
provides less components than provides more powerful
Swing. components such as
tables, lists, scrollpanes,
colorchooser,tabbedpane.
2
Methods
public void add(Component c)
public void setSize(int width,int height)
public void setLayout(LayoutManager m)
public void setVisible(boolean b)
3
JButton class
Constructors:
JButton()
JButton(String s)
JButton(Icon i)
Methods
1) public void setText(String s)
2) public String getText()
3) public void setEnabled(boolean b)
4) public void setIcon(Icon b)
5) public Icon getIcon()
6) public void setMnemonic(int a)
7) public void addActionListener(ActionListener a)
4
JRadioButton class
Constructors
JRadioButton()
JRadioButton(String s)
JRadioButton(String s, boolean selected)
Methods
1) public void setText(String s)
2) public String getText()
3) public void setEnabled(boolean b)
4) public void setIcon(Icon b)
5) public Icon getIcon()
6) public void setMnemonic(int a)
7) public void addActionListener(ActionListener a)
5
JTextArea class
Constructors
JTextArea():
JTextArea(String s)
JTextArea(int row, int column)
JTextArea(String s, int row, int column)
Methods
1) public void setRows(int rows)
2) public void setColumns(int cols)
3) public void setFont(Font f)
4) public void insert(String s, int position)
5) public void append(String s)
6
JTable class
Constructors
JTable()
JTable(Object[][] rows, Object[] columns)
7
Graphics class
Methods
public abstract void drawString(String str, int x, int y)
is used to draw the specified string.
public void drawRect(int x, int y, int width, int height)
draws a rectangle with the specified width and height.
public abstract void fillRect(int x, int y, int width, int height)
is used to fill rectangle with the default color and specified width and
height.
public abstract void drawOval(int x, int y, int width, int height)
is used to draw oval with the specified width and height.
public abstract void setFont(Font font)
is used to set the graphics current font to the specified font
8
Methods
public abstract void fillOval(int x, int y, int width, int height)
is used to fill oval with the default color and specified width and
height.
public abstract void drawLine(int x1, int y1, int x2, int y2)
is used to draw line between the points(x1, y1) and (x2, y2).
public abstract void drawArc(int x, int y, int width, int height,
int startAngle, int arcAngle)
is used draw a circular or elliptical arc.
public abstract void fillArc(int x, int y, int width, int height, int
startAngle, int arcAngle)
is used to fill a circular or elliptical arc.
public abstract void setColor(Color c)
is used to set the graphics current color to the specified color. 9
Methods
The following three methods are involved in displaying graphics.
Default versions of each are provided by class Component.
Methods update() and paint() should be redefined to perform the
desired graphics operations.
repaint()
The repaint() method requests that a component be repainted.
public void repaint()
public void repaint(long tm)
public void repaint(int x, int y, int w, int h)
public void repaint(long tm, int x, int y, int w, int h)
10
update()
public void update(Graphics g)
The update() method is called in response to a repaint() request,
or in response to a portion of the component being uncovered or
displayed for the first time.
paint()
public void paint(Graphics g)
The paint() method is called from an update() method, and is responsible
for actually drawing the graphics.
11
JComboBox class
Constructors
JComboBox()
JComboBox(Object[] items)
methods
1)public void addItem(Object anObject):
is used to add an item to the item list.
2) public void removeItem(Object anObject)
is used to delete an item to the item list.
3) public void removeAllItems()
is used to remove all the items from the list.
4) public void setEditable(boolean b)
is used to determine whether the JComboBox is editable.
5) public void addActionListener(ActionListener a)
is used to add the ActionListener.
6) public void addItemListener(ItemListener i)
is used to add the ItemListener.
12
JColorChooser class
Constructors
JColorChooser()
is used to create a color chooser pane with white color initially.
JColorChooser(Color initialColor)
is used to create a color chooser pane with the specified color initially.
Method
public static Color showDialog(Component c, String title, Color
initialColor)
is used to show the color-chooser dialog box.
13
JProgressBar class
Constructors
JProgressBar()
is used to create a horizontal progress bar but no string text.
JProgressBar(int min, int max)
is used to create a horizontal progress bar with the specified minimum
and maximum value.
JProgressBar(int orient)
is used to create a progress bar with the specified orientation, it can be
either Vertical or Horizontal by using SwingConstants.VERTICAL and
SwingConstants.HORIZONTAL constants.
JProgressBar(int orient, int min, int max)
is used to create a progress bar with the specified orientation, minimum
and maximum value 14
Methods
1)public void setStringPainted(boolean b):
is used to determine whether string should be displayed.
2) public void setString(String s)
is used to set value to the progress string.
3) public void setOrientation(int orientation)
is used to set the orientation, it may be either vertical or horizontal
by using SwingConstants. VERTICAL and
SwingConstants.HORIZONTAL constants..
4) public void setValue(int value)
is used to set the current value on the progress bar
15
JSlider class
Constructors
JSlider()
creates a slider with the initial value of 50 and range of 0 to 100.
JSlider(int orientation)
creates a slider with the specified orientation set by either
JSlider.HORIZONTAL or JSlider.VERTICAL with the range 0 to 100
and initial value 50.
JSlider(int min, int max)
creates a horizontal slider using the given min and max.
JSlider(int min, int max, int value): creates a horizontal slider using the
given min, max and value.
JSlider(int orientation, int min, int max, int value): creates a slider using
the given orientation, min, max and value 16
Methods
1)public void setMinorTickSpacing(int n):
is used to set the minor tick spacing to the slider.
2) public void setMajorTickSpacing(int n)
is used to set the major tick spacing to the slider.
3) public void setPaintTicks(boolean b)
is used to determine whether tick marks are painted
4) public void setPaintLabels(boolean b)
is used to determine whether labels are painted.
5) public void setPaintTracks(boolean b)
is used to determine whether track is painted.
17
18
The Model-View-Controller Design Pattern
19
Roots in MVC Swing architecture is rooted in the model-view-controller
( MVC) design that dates back to SmallTalk. MVC architecture calls for
a visual application to be broken up into three separate parts:
• A model that represents the data for the application.
• The view that is the visual representation of that data.
• A controller that takes user input on the view and translates that to
changes in the model.
20
Menus
A menu provides a space-saving way to let the user choose one of
several options. Other components with which the user can make a one-
of-many choice include combo boxes, lists, radio buttons, spinners,
and tool bars.
Creating menu bars
To create a menu bar:
add a JMenuBar to a JFrame
add JMenus to the JMenuBar and
add JMenuItems to the JMenus
21
22
23
24
25
26
27
Pluggable Look and Feel
The Swing toolkit allows you to decide how to configure the particular
look and feel of your application. If you don't specify a look and feel, the
Swing UI manager figures out which one to use.
Leave it up to the Swing UI manager. If a particular look and feel is not
specified by the program, Swing's UI manager checks whether the user
has specified a preference. If that preference hasn't been specified or isn't
available, the default look and feel is used.
The default look and feel is determined by the supplier of the JRE. For
the JRE that Sun provides, the Java look and feel (called Metal) is used.
The Java look and feel works on all platforms.
28
Use the look and feel of the native platform. If the application is
running on a Microsoft Windows XP machine, the Windows look and
feel is used. On Mac OS platforms, the Aqua look and feel is used. On
UNIX platforms, such as Solaris or Linux, either the GTK+ look and feel
or the CDE/Motif look and feel is used, depending on the user's desktop
choice.
Specify a particular look and feel. Swing ships with four look and
feels: Java (also called Metal), Microsoft Windows, GTK+, and
CDE/Motif. The GTK+ look and feel requires a theme, and there are
many available for free on the Internet.
Create your own look and feel using the Synth package.
Use an externally provided look and feel.
29
30
31
32
33
Thank You
34

More Related Content

What's hot

Dr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWTDr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWT
DrRajeshreeKhande
 
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
suraj pandey
 
Awt
AwtAwt
Awt controls ppt
Awt controls pptAwt controls ppt
Awt controls ppt
soumyaharitha
 
Swing
SwingSwing
Basic using of Swing in Java
Basic using of Swing in JavaBasic using of Swing in Java
Basic using of Swing in Java
suraj pandey
 
java-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of appletjava-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of applet
raksharao
 
java swing
java swingjava swing
java swing
Waheed Warraich
 
Complete java swing
Complete java swingComplete java swing
Complete java swing
jehan1987
 
The AWT and Swing
The AWT and SwingThe AWT and Swing
The AWT and Swing
adil raja
 
Gui
GuiGui
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
yht4ever
 
Java swing
Java swingJava swing
Java swing
Apurbo Datta
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
shanmuga rajan
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
Adil Mehmoood
 
Java swing
Java swingJava swing
Java swing
ssuser3a47cb
 
AWT Packages , Containers and Components
AWT Packages , Containers and ComponentsAWT Packages , Containers and Components
AWT Packages , Containers and Components
Sohanur63
 
Advance Java Programming (CM5I) 2.Swing
Advance Java Programming (CM5I) 2.SwingAdvance Java Programming (CM5I) 2.Swing
Advance Java Programming (CM5I) 2.Swing
Payal Dungarwal
 
Swings in java
Swings in javaSwings in java
Swings in java
Jyoti Totla
 

What's hot (20)

Dr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWTDr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWT
 
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
 
Awt
AwtAwt
Awt
 
Awt controls ppt
Awt controls pptAwt controls ppt
Awt controls ppt
 
Swing
SwingSwing
Swing
 
Basic using of Swing in Java
Basic using of Swing in JavaBasic using of Swing in Java
Basic using of Swing in Java
 
java-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of appletjava-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of applet
 
java swing
java swingjava swing
java swing
 
Complete java swing
Complete java swingComplete java swing
Complete java swing
 
The AWT and Swing
The AWT and SwingThe AWT and Swing
The AWT and Swing
 
Gui
GuiGui
Gui
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
 
Java swing
Java swingJava swing
Java swing
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
 
Java swing
Java swingJava swing
Java swing
 
AWT Packages , Containers and Components
AWT Packages , Containers and ComponentsAWT Packages , Containers and Components
AWT Packages , Containers and Components
 
Advance Java Programming (CM5I) 2.Swing
Advance Java Programming (CM5I) 2.SwingAdvance Java Programming (CM5I) 2.Swing
Advance Java Programming (CM5I) 2.Swing
 
Swings in java
Swings in javaSwings in java
Swings in java
 
Chapter 1 swings
Chapter 1 swingsChapter 1 swings
Chapter 1 swings
 

Viewers also liked

Applet features
Applet featuresApplet features
Applet featuresmyrajendra
 
Swing is not dead
Swing is not deadSwing is not dead
Swing is not dead
Piotr Dziewonski
 
Modul Kelas Programming : Java swing (session 2)
Modul Kelas Programming : Java swing (session 2)Modul Kelas Programming : Java swing (session 2)
Modul Kelas Programming : Java swing (session 2)
FgroupIndonesia
 
Modul Kelas Programming : Java swing 1
Modul Kelas Programming : Java swing 1Modul Kelas Programming : Java swing 1
Modul Kelas Programming : Java swing 1
FgroupIndonesia
 
Applet java
Applet javaApplet java
Applet java
Jorge Luis Tinoco
 
Java applets
Java appletsJava applets
Java applets
Khan Mac-arther
 
Java applets
Java appletsJava applets
Java appletslopjuan
 
Java applets
Java appletsJava applets

Viewers also liked (9)

Applet features
Applet featuresApplet features
Applet features
 
Swing is not dead
Swing is not deadSwing is not dead
Swing is not dead
 
Java Applets
Java AppletsJava Applets
Java Applets
 
Modul Kelas Programming : Java swing (session 2)
Modul Kelas Programming : Java swing (session 2)Modul Kelas Programming : Java swing (session 2)
Modul Kelas Programming : Java swing (session 2)
 
Modul Kelas Programming : Java swing 1
Modul Kelas Programming : Java swing 1Modul Kelas Programming : Java swing 1
Modul Kelas Programming : Java swing 1
 
Applet java
Applet javaApplet java
Applet java
 
Java applets
Java appletsJava applets
Java applets
 
Java applets
Java appletsJava applets
Java applets
 
Java applets
Java appletsJava applets
Java applets
 

Similar to Java swing

U5 JAVA.pptx
U5 JAVA.pptxU5 JAVA.pptx
U5 JAVA.pptx
madan r
 
Advanced java programming
Advanced java programmingAdvanced java programming
Advanced java programming
Kaviya452563
 
13457272.ppt
13457272.ppt13457272.ppt
13457272.ppt
aptechaligarh
 
Client Side Programming with Applet
Client Side Programming with AppletClient Side Programming with Applet
Client Side Programming with Appletbackdoor
 
DSJ_Unit III.pdf
DSJ_Unit III.pdfDSJ_Unit III.pdf
DSJ_Unit III.pdf
Arumugam90
 
PDF ON JAVA - JFC CONCEPT
PDF ON JAVA - JFC CONCEPTPDF ON JAVA - JFC CONCEPT
PDF ON JAVA - JFC CONCEPT
NAVYA RAO
 
Java Graphics
Java GraphicsJava Graphics
Java Graphics
Shraddha
 
Applet in java
Applet in javaApplet in java
Applet in java
Rakesh Mittal
 
Scmad Chapter07
Scmad Chapter07Scmad Chapter07
Scmad Chapter07
Marcel Caraciolo
 
Java applet handouts
Java applet handoutsJava applet handouts
Java applet handoutsiamkim
 
Unit-2 swing and mvc architecture
Unit-2 swing and mvc architectureUnit-2 swing and mvc architecture
Unit-2 swing and mvc architecture
Amol Gaikwad
 
GUI.pdf
GUI.pdfGUI.pdf
GUI.pdf
Poornima E.G.
 
L18 applets
L18 appletsL18 applets
L18 applets
teach4uin
 
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
 
Ajp notes-chapter-02
Ajp notes-chapter-02Ajp notes-chapter-02
Ajp notes-chapter-02
Ankit Dubey
 
JAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdfJAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdf
Prof. Dr. K. Adisesha
 
Computer graphics
Computer graphics Computer graphics
Computer graphics
shafiq sangi
 
Getting started with GUI programming in Java_1
Getting started with GUI programming in Java_1Getting started with GUI programming in Java_1
Getting started with GUI programming in Java_1Muhammad Shebl Farag
 
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYAPYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
Maulik Borsaniya
 

Similar to Java swing (20)

U5 JAVA.pptx
U5 JAVA.pptxU5 JAVA.pptx
U5 JAVA.pptx
 
Advanced java programming
Advanced java programmingAdvanced java programming
Advanced java programming
 
Applets
AppletsApplets
Applets
 
13457272.ppt
13457272.ppt13457272.ppt
13457272.ppt
 
Client Side Programming with Applet
Client Side Programming with AppletClient Side Programming with Applet
Client Side Programming with Applet
 
DSJ_Unit III.pdf
DSJ_Unit III.pdfDSJ_Unit III.pdf
DSJ_Unit III.pdf
 
PDF ON JAVA - JFC CONCEPT
PDF ON JAVA - JFC CONCEPTPDF ON JAVA - JFC CONCEPT
PDF ON JAVA - JFC CONCEPT
 
Java Graphics
Java GraphicsJava Graphics
Java Graphics
 
Applet in java
Applet in javaApplet in java
Applet in java
 
Scmad Chapter07
Scmad Chapter07Scmad Chapter07
Scmad Chapter07
 
Java applet handouts
Java applet handoutsJava applet handouts
Java applet handouts
 
Unit-2 swing and mvc architecture
Unit-2 swing and mvc architectureUnit-2 swing and mvc architecture
Unit-2 swing and mvc architecture
 
GUI.pdf
GUI.pdfGUI.pdf
GUI.pdf
 
L18 applets
L18 appletsL18 applets
L18 applets
 
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)
 
Ajp notes-chapter-02
Ajp notes-chapter-02Ajp notes-chapter-02
Ajp notes-chapter-02
 
JAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdfJAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdf
 
Computer graphics
Computer graphics Computer graphics
Computer graphics
 
Getting started with GUI programming in Java_1
Getting started with GUI programming in Java_1Getting started with GUI programming in Java_1
Getting started with GUI programming in Java_1
 
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYAPYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
 

More from Arati Gadgil

Java adapter
Java adapterJava adapter
Java adapter
Arati Gadgil
 
Java applet
Java appletJava applet
Java applet
Arati Gadgil
 
Java layoutmanager
Java layoutmanagerJava layoutmanager
Java layoutmanager
Arati Gadgil
 
Java stream
Java streamJava stream
Java stream
Arati Gadgil
 
Java thread
Java threadJava thread
Java thread
Arati Gadgil
 
Java networking
Java networkingJava networking
Java networking
Arati Gadgil
 
Java jdbc
Java jdbcJava jdbc
Java jdbc
Arati Gadgil
 
Java package
Java packageJava package
Java package
Arati Gadgil
 
Java interface
Java interfaceJava interface
Java interface
Arati Gadgil
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
Arati Gadgil
 
Java eventhandling
Java eventhandlingJava eventhandling
Java eventhandling
Arati Gadgil
 
Java exception
Java exception Java exception
Java exception
Arati Gadgil
 
Java collection
Java collectionJava collection
Java collection
Arati Gadgil
 
Java class
Java classJava class
Java class
Arati Gadgil
 
Java basic
Java basicJava basic
Java basic
Arati Gadgil
 

More from Arati Gadgil (15)

Java adapter
Java adapterJava adapter
Java adapter
 
Java applet
Java appletJava applet
Java applet
 
Java layoutmanager
Java layoutmanagerJava layoutmanager
Java layoutmanager
 
Java stream
Java streamJava stream
Java stream
 
Java thread
Java threadJava thread
Java thread
 
Java networking
Java networkingJava networking
Java networking
 
Java jdbc
Java jdbcJava jdbc
Java jdbc
 
Java package
Java packageJava package
Java package
 
Java interface
Java interfaceJava interface
Java interface
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 
Java eventhandling
Java eventhandlingJava eventhandling
Java eventhandling
 
Java exception
Java exception Java exception
Java exception
 
Java collection
Java collectionJava collection
Java collection
 
Java class
Java classJava class
Java class
 
Java basic
Java basicJava basic
Java basic
 

Recently uploaded

Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 

Recently uploaded (20)

Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 

Java swing

  • 2. Difference between AWT and Swing AWT Swing platform-dependent. platform-independent heavyweight. lightweight. doesn't support pluggable look supports pluggable look and feel. and feel. provides less components than provides more powerful Swing. components such as tables, lists, scrollpanes, colorchooser,tabbedpane. 2
  • 3. Methods public void add(Component c) public void setSize(int width,int height) public void setLayout(LayoutManager m) public void setVisible(boolean b) 3
  • 4. JButton class Constructors: JButton() JButton(String s) JButton(Icon i) Methods 1) public void setText(String s) 2) public String getText() 3) public void setEnabled(boolean b) 4) public void setIcon(Icon b) 5) public Icon getIcon() 6) public void setMnemonic(int a) 7) public void addActionListener(ActionListener a) 4
  • 5. JRadioButton class Constructors JRadioButton() JRadioButton(String s) JRadioButton(String s, boolean selected) Methods 1) public void setText(String s) 2) public String getText() 3) public void setEnabled(boolean b) 4) public void setIcon(Icon b) 5) public Icon getIcon() 6) public void setMnemonic(int a) 7) public void addActionListener(ActionListener a) 5
  • 6. JTextArea class Constructors JTextArea(): JTextArea(String s) JTextArea(int row, int column) JTextArea(String s, int row, int column) Methods 1) public void setRows(int rows) 2) public void setColumns(int cols) 3) public void setFont(Font f) 4) public void insert(String s, int position) 5) public void append(String s) 6
  • 8. Graphics class Methods public abstract void drawString(String str, int x, int y) is used to draw the specified string. public void drawRect(int x, int y, int width, int height) draws a rectangle with the specified width and height. public abstract void fillRect(int x, int y, int width, int height) is used to fill rectangle with the default color and specified width and height. public abstract void drawOval(int x, int y, int width, int height) is used to draw oval with the specified width and height. public abstract void setFont(Font font) is used to set the graphics current font to the specified font 8
  • 9. Methods public abstract void fillOval(int x, int y, int width, int height) is used to fill oval with the default color and specified width and height. public abstract void drawLine(int x1, int y1, int x2, int y2) is used to draw line between the points(x1, y1) and (x2, y2). public abstract void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) is used draw a circular or elliptical arc. public abstract void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) is used to fill a circular or elliptical arc. public abstract void setColor(Color c) is used to set the graphics current color to the specified color. 9
  • 10. Methods The following three methods are involved in displaying graphics. Default versions of each are provided by class Component. Methods update() and paint() should be redefined to perform the desired graphics operations. repaint() The repaint() method requests that a component be repainted. public void repaint() public void repaint(long tm) public void repaint(int x, int y, int w, int h) public void repaint(long tm, int x, int y, int w, int h) 10
  • 11. update() public void update(Graphics g) The update() method is called in response to a repaint() request, or in response to a portion of the component being uncovered or displayed for the first time. paint() public void paint(Graphics g) The paint() method is called from an update() method, and is responsible for actually drawing the graphics. 11
  • 12. JComboBox class Constructors JComboBox() JComboBox(Object[] items) methods 1)public void addItem(Object anObject): is used to add an item to the item list. 2) public void removeItem(Object anObject) is used to delete an item to the item list. 3) public void removeAllItems() is used to remove all the items from the list. 4) public void setEditable(boolean b) is used to determine whether the JComboBox is editable. 5) public void addActionListener(ActionListener a) is used to add the ActionListener. 6) public void addItemListener(ItemListener i) is used to add the ItemListener. 12
  • 13. JColorChooser class Constructors JColorChooser() is used to create a color chooser pane with white color initially. JColorChooser(Color initialColor) is used to create a color chooser pane with the specified color initially. Method public static Color showDialog(Component c, String title, Color initialColor) is used to show the color-chooser dialog box. 13
  • 14. JProgressBar class Constructors JProgressBar() is used to create a horizontal progress bar but no string text. JProgressBar(int min, int max) is used to create a horizontal progress bar with the specified minimum and maximum value. JProgressBar(int orient) is used to create a progress bar with the specified orientation, it can be either Vertical or Horizontal by using SwingConstants.VERTICAL and SwingConstants.HORIZONTAL constants. JProgressBar(int orient, int min, int max) is used to create a progress bar with the specified orientation, minimum and maximum value 14
  • 15. Methods 1)public void setStringPainted(boolean b): is used to determine whether string should be displayed. 2) public void setString(String s) is used to set value to the progress string. 3) public void setOrientation(int orientation) is used to set the orientation, it may be either vertical or horizontal by using SwingConstants. VERTICAL and SwingConstants.HORIZONTAL constants.. 4) public void setValue(int value) is used to set the current value on the progress bar 15
  • 16. JSlider class Constructors JSlider() creates a slider with the initial value of 50 and range of 0 to 100. JSlider(int orientation) creates a slider with the specified orientation set by either JSlider.HORIZONTAL or JSlider.VERTICAL with the range 0 to 100 and initial value 50. JSlider(int min, int max) creates a horizontal slider using the given min and max. JSlider(int min, int max, int value): creates a horizontal slider using the given min, max and value. JSlider(int orientation, int min, int max, int value): creates a slider using the given orientation, min, max and value 16
  • 17. Methods 1)public void setMinorTickSpacing(int n): is used to set the minor tick spacing to the slider. 2) public void setMajorTickSpacing(int n) is used to set the major tick spacing to the slider. 3) public void setPaintTicks(boolean b) is used to determine whether tick marks are painted 4) public void setPaintLabels(boolean b) is used to determine whether labels are painted. 5) public void setPaintTracks(boolean b) is used to determine whether track is painted. 17
  • 19. 19 Roots in MVC Swing architecture is rooted in the model-view-controller ( MVC) design that dates back to SmallTalk. MVC architecture calls for a visual application to be broken up into three separate parts: • A model that represents the data for the application. • The view that is the visual representation of that data. • A controller that takes user input on the view and translates that to changes in the model.
  • 20. 20 Menus A menu provides a space-saving way to let the user choose one of several options. Other components with which the user can make a one- of-many choice include combo boxes, lists, radio buttons, spinners, and tool bars. Creating menu bars To create a menu bar: add a JMenuBar to a JFrame add JMenus to the JMenuBar and add JMenuItems to the JMenus
  • 21. 21
  • 22. 22
  • 23. 23
  • 24. 24
  • 25. 25
  • 26. 26
  • 27. 27 Pluggable Look and Feel The Swing toolkit allows you to decide how to configure the particular look and feel of your application. If you don't specify a look and feel, the Swing UI manager figures out which one to use. Leave it up to the Swing UI manager. If a particular look and feel is not specified by the program, Swing's UI manager checks whether the user has specified a preference. If that preference hasn't been specified or isn't available, the default look and feel is used. The default look and feel is determined by the supplier of the JRE. For the JRE that Sun provides, the Java look and feel (called Metal) is used. The Java look and feel works on all platforms.
  • 28. 28 Use the look and feel of the native platform. If the application is running on a Microsoft Windows XP machine, the Windows look and feel is used. On Mac OS platforms, the Aqua look and feel is used. On UNIX platforms, such as Solaris or Linux, either the GTK+ look and feel or the CDE/Motif look and feel is used, depending on the user's desktop choice. Specify a particular look and feel. Swing ships with four look and feels: Java (also called Metal), Microsoft Windows, GTK+, and CDE/Motif. The GTK+ look and feel requires a theme, and there are many available for free on the Internet. Create your own look and feel using the Synth package. Use an externally provided look and feel.
  • 29. 29
  • 30. 30
  • 31. 31
  • 32. 32
  • 33. 33