SlideShare a Scribd company logo
3
Most read
8
Most read
23
Most read
Java Swing
Introduction
 Java Swing tutorial is a part of Java Foundation
Classes (JFC) that is used to create window-based
applications.
 It is built on the top of AWT (Abstract
Windowing Toolkit) API and entirely written in
java.
 The javax.swing package provides classes for java
swing API such as JButton, JTextField, JTextArea,
JRadioButton, JCheckbox, JMenu, JColorChooser
etc.
Difference between AWT and
Swing
AWT
 AWT components are platform-dependent.
 AWT components are heavyweight.
 AWT doesn't support pluggable look and feel.
 AWT provides less components than Swing.
 AWT doesn't follows MVC(Model View
Controller) where model represents data, view
represents presentation and controller acts as an
interface between model and view.
Contd..
Swing
 Java swing components are platform-
independent.
 Swing components are lightweight.
 Swing supports pluggable look and feel.
 Swing provides more powerful components
such as tables, lists, scrollpanes, colorchooser,
tabbedpane etc.
 Swing follows MVC.
Hierarchy of Java Swing classes
MVC
Java swing
Simple Java Swing Example
import javax.swing.*;
public class FirstSwingExample {
public static void main(String[] args) {
JFrame f=new JFrame();//creating instance of JFrame
JButton b=new JButton("click");//creating instance of JButton
b.setBounds(130,100,100, 40);//x axis, y axis, width, height
f.add(b);//adding button in JFrame
f.setSize(400,500);//400 width and 500 height
f.setLayout(null);//using no layout managers
f.setVisible(true);//making the frame visible
}
}
Java swing
import javax.swing.*;
public class Simple2 extends JFrame{//inheriting JFrame
JFrame f;
Simple2(){
JButton b=new JButton("click");//create button
b.setBounds(130,100,100, 40);
add(b);//adding button on frame
setSize(400,500);
setLayout(null);
setVisible(true);
}
public static void main(String[] args) {
new Simple2();
}}
JButton
 The JButton class is used to create a labeled
button that has platform independent
implementation.
 The application result in some action when the
button is pushed. It inherits AbstractButton class.
 JButton() -- It creates a button with no text and
icon.
JButton(String s)-- It creates a button with the
specified text.
JButton(Icon i) -- It creates a button with the
specified icon object.
import javax.swing.*;
public class ButtonExample{
ButtonExample(){
JFrame f=new JFrame("Button Example");
JButton b=new JButton(new ImageIcon("D:img.png"));
b.setBounds(100,100,100, 40);
f.add(b);
f.setSize(300,400);
f.setLayout(null);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new ButtonExample();
}
}
import java.awt.event.*;
import javax.swing.*;
public class ButtonExample {
public static void main(String[] args) {
JFrame f=new JFrame("Button Example");
final JTextField tf=new JTextField();
tf.setBounds(50,50, 150,20);
JButton b=new JButton("Click Here");
b.setBounds(50,100,95,30);
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
tf.setText("Welcome to Javatpoint.");
}
});
f.add(b);f.add(tf);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
}
}
JOptionPane
 The JOptionPane class is used to provide standard
dialog boxes such as message dialog box, confirm
dialog box and input dialog box.
 These dialog boxes are used to display information or
get input from the user. The JOptionPane class
inherits JComponent class.
 JOptionPane() -It is used to create a JOptionPane
with a test message.
 JOptionPane(Object message) -It is used to create an
instance of JOptionPane to display a message.
 JOptionPane(Object message, int messageType )-It is
used to create an instance of JOptionPane to display
a message with specified message type and default
options.
Java Swing Layouts
 In Java swing, Layout manager is used to position all
its components, with setting properties, such as the
size, the shape, and the arrangement.
The following layout managers are:
 FlowLayout
 BorderLayout
 CardLayout
 BoxLayout
 GridLayout
 GridBagLayout
 GroupLayout
 SpringLayout
FlowLayout
The FlowLayout arranges the components in a
directional flow, either from left to right or from right to
left. Normally all components are set to one row,
according to the order of different components. If all
components can not be fit into one row, it will start a
new row and fit the rest in.
To construct a FlowLayout, three options could be
chosen:
 FlowLayout(): construct a new FlowLayout object with
center alignment and horizontal and vertical gap to
be default size of 5 pixels.
 FlowLayout(int align): construct similar object with
different settings on alignment
 FlowLayout(int align, int hgap, int vgap): construct
similar object with different settings on alignment and
gaps between components.
BorderLayout
A BorderLayout lays out a container, arranging its
components to fit into five regions: NORTH,
SOUTH, EAST, WEST and CENTER. For each
region, it may contain no more than one
component.
For BorderLayout, it can be constructed like below:
 BorderLayout(): construct a border layout with no
gaps between components.
 BorderLayout(int hgap, int vgap): construct a
border layout with specified gaps between
components.
CardLayout
For CardLayout, it treats the components as a stack and
every time, what you can see is only one component.
BoxLayout
BoxLayout with two different axis options: X_AXIS and
Y_AXIS. In X_AXIS, components are laid out horizontally
from left to right, while in Y_AXIS vertically from top to
bottom.
GridLayout
 The GridLayout manager is used to lay out the
components in a rectangle grid, which has been divided
into equal-sized rectangles and one component is placed
in each rectangle. It can constructed with following
methods:
 GridLayout(): construct a grid layout with one column per
component in a single row.
 GridLayout(int row, int col): construct a grid layout with
specified numbers of rows and columns.
 GridLayout(int row, int col, int hgap, int vgap): construct a
grid layout with specified rows, columns and gaps between
components.
Java JTabbedPane
The JTabbedPane class is used to switch between
a group of components by clicking on a tab with a
given title or icon. It inherits JComponent class.
JTabbedPane() Creates an empty TabbedPane
with a default tab placement of
JTabbedPane.Top.
JTabbedPane(int tabPlacement) Creates an
empty TabbedPane with a specified tab
placement.
JTabbedPane(int tabPlacement, int
tabLayoutPolicy) Creates an empty TabbedPane
with a specified tab placement and tab layout
policy.
JTree
JTree class is used to display the tree structured data or
hierarchical data. JTree is a complex component. It has a
'root node' at the top most which is a parent for all
nodes in the tree. It inherits JComponent class.
JTree() Creates a JTree with a sample model.
JTree(Object[] value) Creates a JTree with every
element of the specified array as the child of a new root
node.
JTree(TreeNode root) Creates a JTree with the specified
TreeNode as its root, which displays the root node.
Mnemonics and Accelerators to
Menu Items
 Menus support two kinds of keyboard
alternatives: mnemonics and accelerators.
 Mnemonics offer a way to use the keyboard to
navigate the menu hierarchy, increasing the
accessibility of programs.
 Accelerators, on the other hand, offer keyboard
shortcuts to bypass navigating the menu
hierarchy.
 The menu created in the preceding example is
functional, but it is possible to make it better.
 In real applications, a menu usually includes
support for keyboard shortcuts because they give
an experienced user the ability to select menu
items rapidly.
 Keyboard shortcuts come in two forms:
mnemonics and accelerators. As it applies to
menus, a mnemonic defines a key that lets you
select an item from an active menu by typing the
key.
 Thus, a mnemonic allows you to use the
keyboard to select an item from a menu that is
already being displayed.
 An accelerator is a key that lets you select a
menu item without having to first activate the
 To specify a mnemonic for JMenu, you must call
setMnemonic( ). This method is inherited by both
classes from AbstractButton and is shown next:
 void setMnemonic(int mnem)

More Related Content

What's hot (20)

PPT
Java: GUI
Tareq Hasan
 
PPTX
Control statements in java
Madishetty Prathibha
 
PPTX
Event Handling in java
Google
 
PPTX
Java Queue.pptx
vishal choudhary
 
PDF
Arrays in Java
Naz Abdalla
 
PPTX
Templates in C++
Tech_MX
 
PPTX
Vectors in Java
Abhilash Nair
 
PDF
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Edureka!
 
PPS
Wrapper class
kamal kotecha
 
PDF
Python list
Mohammed Sikander
 
PPTX
Multithreading in java
junnubabu
 
PPTX
Data Types, Variables, and Operators
Marwa Ali Eissa
 
PPTX
Packages in java
Elizabeth alexander
 
PPT
Java And Multithreading
Shraddha
 
PDF
Object Oriented Programming using C++ - Part 4
University College of Engineering Kakinada, JNTUK - Kakinada, India
 
PDF
Function overloading ppt
Prof. Dr. K. Adisesha
 
PPTX
Interface in java
PhD Research Scholar
 
ODP
OOP java
xball977
 
PPTX
JAVA AWT
shanmuga rajan
 
Java: GUI
Tareq Hasan
 
Control statements in java
Madishetty Prathibha
 
Event Handling in java
Google
 
Java Queue.pptx
vishal choudhary
 
Arrays in Java
Naz Abdalla
 
Templates in C++
Tech_MX
 
Vectors in Java
Abhilash Nair
 
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Edureka!
 
Wrapper class
kamal kotecha
 
Python list
Mohammed Sikander
 
Multithreading in java
junnubabu
 
Data Types, Variables, and Operators
Marwa Ali Eissa
 
Packages in java
Elizabeth alexander
 
Java And Multithreading
Shraddha
 
Object Oriented Programming using C++ - Part 4
University College of Engineering Kakinada, JNTUK - Kakinada, India
 
Function overloading ppt
Prof. Dr. K. Adisesha
 
Interface in java
PhD Research Scholar
 
OOP java
xball977
 
JAVA AWT
shanmuga rajan
 

Similar to Java swing (20)

PPTX
Unit 4_1.pptx JDBC AND GUI FOR CLIENT SERVER
Salini P
 
PDF
Z blue introduction to gui (39023299)
Narayana Swamy
 
PDF
Swingpre 150616004959-lva1-app6892
renuka gavli
 
PPT
Swing and AWT in java
Adil Mehmoood
 
PPT
Unit4 AWT, Swings & Layouts power point presentation
SNIGDHAAPPANABHOTLA
 
DOC
java swing notes in easy manner for UG students
RameshPrasadBhatta2
 
PPTX
Awt, Swing, Layout managers
swapnac12
 
PPT
13457272.ppt
aptechaligarh
 
PPTX
Abstract Window Toolkit_Event Handling_python
jasminebeulahg
 
PPTX
SWING USING JAVA WITH VARIOUS COMPONENTS
bharathiv53
 
PPTX
Creating GUI.pptx Gui graphical user interface
pikachu02434
 
PPT
GUI Programming In Java
yht4ever
 
PPT
Advance Java Programming (CM5I) 2.Swing
Payal Dungarwal
 
PPT
Basic of Abstract Window Toolkit(AWT) in Java
suraj pandey
 
PPTX
Java swing
Apurbo Datta
 
PDF
DSJ_Unit III.pdf
Arumugam90
 
PDF
Ingles 2do parcial
Harry Ostaiza
 
PPTX
Jp notes
Sreedhar Chowdam
 
PDF
Swing
Fahim Khan
 
PDF
Swing
Fahim Khan
 
Unit 4_1.pptx JDBC AND GUI FOR CLIENT SERVER
Salini P
 
Z blue introduction to gui (39023299)
Narayana Swamy
 
Swingpre 150616004959-lva1-app6892
renuka gavli
 
Swing and AWT in java
Adil Mehmoood
 
Unit4 AWT, Swings & Layouts power point presentation
SNIGDHAAPPANABHOTLA
 
java swing notes in easy manner for UG students
RameshPrasadBhatta2
 
Awt, Swing, Layout managers
swapnac12
 
13457272.ppt
aptechaligarh
 
Abstract Window Toolkit_Event Handling_python
jasminebeulahg
 
SWING USING JAVA WITH VARIOUS COMPONENTS
bharathiv53
 
Creating GUI.pptx Gui graphical user interface
pikachu02434
 
GUI Programming In Java
yht4ever
 
Advance Java Programming (CM5I) 2.Swing
Payal Dungarwal
 
Basic of Abstract Window Toolkit(AWT) in Java
suraj pandey
 
Java swing
Apurbo Datta
 
DSJ_Unit III.pdf
Arumugam90
 
Ingles 2do parcial
Harry Ostaiza
 
Swing
Fahim Khan
 
Swing
Fahim Khan
 
Ad

More from ssuser3a47cb (10)

PPTX
BCT.pptx
ssuser3a47cb
 
PPTX
Uunit 5-xml&web security
ssuser3a47cb
 
PPTX
Unit 4-SOA governance
ssuser3a47cb
 
PPTX
Unit 3-SOA Technologies
ssuser3a47cb
 
PPTX
Unit 2 -SOA design
ssuser3a47cb
 
PPTX
Soa 1 7.ppsx
ssuser3a47cb
 
PPTX
Java networking
ssuser3a47cb
 
PPTX
I/O port programming in 8051
ssuser3a47cb
 
PPTX
Interfacing external memory in 8051
ssuser3a47cb
 
PPTX
Interrupt in 8051
ssuser3a47cb
 
BCT.pptx
ssuser3a47cb
 
Uunit 5-xml&web security
ssuser3a47cb
 
Unit 4-SOA governance
ssuser3a47cb
 
Unit 3-SOA Technologies
ssuser3a47cb
 
Unit 2 -SOA design
ssuser3a47cb
 
Soa 1 7.ppsx
ssuser3a47cb
 
Java networking
ssuser3a47cb
 
I/O port programming in 8051
ssuser3a47cb
 
Interfacing external memory in 8051
ssuser3a47cb
 
Interrupt in 8051
ssuser3a47cb
 
Ad

Recently uploaded (20)

PPTX
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
PDF
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
PPTX
artificial intelligence applications in Geomatics
NawrasShatnawi1
 
PPTX
Depth First Search Algorithm in 🧠 DFS in Artificial Intelligence (AI)
rafeeqshaik212002
 
PPTX
Introduction to Neural Networks and Perceptron Learning Algorithm.pptx
Kayalvizhi A
 
PDF
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PPT
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
PPTX
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
PPTX
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
PDF
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
PPTX
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
PPTX
GitOps_Repo_Structure for begeinner(Scaffolindg)
DanialHabibi2
 
PPTX
Green Building & Energy Conservation ppt
Sagar Sarangi
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
DOCX
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PPTX
Thermal runway and thermal stability.pptx
godow93766
 
PPTX
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
artificial intelligence applications in Geomatics
NawrasShatnawi1
 
Depth First Search Algorithm in 🧠 DFS in Artificial Intelligence (AI)
rafeeqshaik212002
 
Introduction to Neural Networks and Perceptron Learning Algorithm.pptx
Kayalvizhi A
 
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
Design Thinking basics for Engineers.pdf
CMR University
 
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
GitOps_Repo_Structure for begeinner(Scaffolindg)
DanialHabibi2
 
Green Building & Energy Conservation ppt
Sagar Sarangi
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
Thermal runway and thermal stability.pptx
godow93766
 
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 

Java swing

  • 2. Introduction  Java Swing tutorial is a part of Java Foundation Classes (JFC) that is used to create window-based applications.  It is built on the top of AWT (Abstract Windowing Toolkit) API and entirely written in java.  The javax.swing package provides classes for java swing API such as JButton, JTextField, JTextArea, JRadioButton, JCheckbox, JMenu, JColorChooser etc.
  • 3. Difference between AWT and Swing AWT  AWT components are platform-dependent.  AWT components are heavyweight.  AWT doesn't support pluggable look and feel.  AWT provides less components than Swing.  AWT doesn't follows MVC(Model View Controller) where model represents data, view represents presentation and controller acts as an interface between model and view.
  • 4. Contd.. Swing  Java swing components are platform- independent.  Swing components are lightweight.  Swing supports pluggable look and feel.  Swing provides more powerful components such as tables, lists, scrollpanes, colorchooser, tabbedpane etc.  Swing follows MVC.
  • 5. Hierarchy of Java Swing classes
  • 6. MVC
  • 8. Simple Java Swing Example import javax.swing.*; public class FirstSwingExample { public static void main(String[] args) { JFrame f=new JFrame();//creating instance of JFrame JButton b=new JButton("click");//creating instance of JButton b.setBounds(130,100,100, 40);//x axis, y axis, width, height f.add(b);//adding button in JFrame f.setSize(400,500);//400 width and 500 height f.setLayout(null);//using no layout managers f.setVisible(true);//making the frame visible } }
  • 10. import javax.swing.*; public class Simple2 extends JFrame{//inheriting JFrame JFrame f; Simple2(){ JButton b=new JButton("click");//create button b.setBounds(130,100,100, 40); add(b);//adding button on frame setSize(400,500); setLayout(null); setVisible(true); } public static void main(String[] args) { new Simple2(); }}
  • 11. JButton  The JButton class is used to create a labeled button that has platform independent implementation.  The application result in some action when the button is pushed. It inherits AbstractButton class.  JButton() -- It creates a button with no text and icon. JButton(String s)-- It creates a button with the specified text. JButton(Icon i) -- It creates a button with the specified icon object.
  • 12. import javax.swing.*; public class ButtonExample{ ButtonExample(){ JFrame f=new JFrame("Button Example"); JButton b=new JButton(new ImageIcon("D:img.png")); b.setBounds(100,100,100, 40); f.add(b); f.setSize(300,400); f.setLayout(null); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { new ButtonExample(); } }
  • 13. import java.awt.event.*; import javax.swing.*; public class ButtonExample { public static void main(String[] args) { JFrame f=new JFrame("Button Example"); final JTextField tf=new JTextField(); tf.setBounds(50,50, 150,20); JButton b=new JButton("Click Here"); b.setBounds(50,100,95,30); b.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ tf.setText("Welcome to Javatpoint."); } }); f.add(b);f.add(tf); f.setSize(400,400); f.setLayout(null); f.setVisible(true); } }
  • 14. JOptionPane  The JOptionPane class is used to provide standard dialog boxes such as message dialog box, confirm dialog box and input dialog box.  These dialog boxes are used to display information or get input from the user. The JOptionPane class inherits JComponent class.  JOptionPane() -It is used to create a JOptionPane with a test message.  JOptionPane(Object message) -It is used to create an instance of JOptionPane to display a message.  JOptionPane(Object message, int messageType )-It is used to create an instance of JOptionPane to display a message with specified message type and default options.
  • 15. Java Swing Layouts  In Java swing, Layout manager is used to position all its components, with setting properties, such as the size, the shape, and the arrangement. The following layout managers are:  FlowLayout  BorderLayout  CardLayout  BoxLayout  GridLayout  GridBagLayout  GroupLayout  SpringLayout
  • 16. FlowLayout The FlowLayout arranges the components in a directional flow, either from left to right or from right to left. Normally all components are set to one row, according to the order of different components. If all components can not be fit into one row, it will start a new row and fit the rest in. To construct a FlowLayout, three options could be chosen:  FlowLayout(): construct a new FlowLayout object with center alignment and horizontal and vertical gap to be default size of 5 pixels.  FlowLayout(int align): construct similar object with different settings on alignment  FlowLayout(int align, int hgap, int vgap): construct similar object with different settings on alignment and gaps between components.
  • 17. BorderLayout A BorderLayout lays out a container, arranging its components to fit into five regions: NORTH, SOUTH, EAST, WEST and CENTER. For each region, it may contain no more than one component. For BorderLayout, it can be constructed like below:  BorderLayout(): construct a border layout with no gaps between components.  BorderLayout(int hgap, int vgap): construct a border layout with specified gaps between components.
  • 18. CardLayout For CardLayout, it treats the components as a stack and every time, what you can see is only one component. BoxLayout BoxLayout with two different axis options: X_AXIS and Y_AXIS. In X_AXIS, components are laid out horizontally from left to right, while in Y_AXIS vertically from top to bottom. GridLayout  The GridLayout manager is used to lay out the components in a rectangle grid, which has been divided into equal-sized rectangles and one component is placed in each rectangle. It can constructed with following methods:  GridLayout(): construct a grid layout with one column per component in a single row.  GridLayout(int row, int col): construct a grid layout with specified numbers of rows and columns.  GridLayout(int row, int col, int hgap, int vgap): construct a grid layout with specified rows, columns and gaps between components.
  • 19. Java JTabbedPane The JTabbedPane class is used to switch between a group of components by clicking on a tab with a given title or icon. It inherits JComponent class. JTabbedPane() Creates an empty TabbedPane with a default tab placement of JTabbedPane.Top. JTabbedPane(int tabPlacement) Creates an empty TabbedPane with a specified tab placement. JTabbedPane(int tabPlacement, int tabLayoutPolicy) Creates an empty TabbedPane with a specified tab placement and tab layout policy.
  • 20. JTree JTree class is used to display the tree structured data or hierarchical data. JTree is a complex component. It has a 'root node' at the top most which is a parent for all nodes in the tree. It inherits JComponent class. JTree() Creates a JTree with a sample model. JTree(Object[] value) Creates a JTree with every element of the specified array as the child of a new root node. JTree(TreeNode root) Creates a JTree with the specified TreeNode as its root, which displays the root node.
  • 21. Mnemonics and Accelerators to Menu Items  Menus support two kinds of keyboard alternatives: mnemonics and accelerators.  Mnemonics offer a way to use the keyboard to navigate the menu hierarchy, increasing the accessibility of programs.  Accelerators, on the other hand, offer keyboard shortcuts to bypass navigating the menu hierarchy.
  • 22.  The menu created in the preceding example is functional, but it is possible to make it better.  In real applications, a menu usually includes support for keyboard shortcuts because they give an experienced user the ability to select menu items rapidly.  Keyboard shortcuts come in two forms: mnemonics and accelerators. As it applies to menus, a mnemonic defines a key that lets you select an item from an active menu by typing the key.  Thus, a mnemonic allows you to use the keyboard to select an item from a menu that is already being displayed.  An accelerator is a key that lets you select a menu item without having to first activate the
  • 23.  To specify a mnemonic for JMenu, you must call setMnemonic( ). This method is inherited by both classes from AbstractButton and is shown next:  void setMnemonic(int mnem)