SlideShare a Scribd company logo
Introducing Swing(modern Java GUI)
Introduction
• Swing is a set of classes that provides more powerful
and flexible GUI components than does the AWT.
• Swing program, including both applications and applets.
• Swing has:
– Component: derived from the JComponent class
– Container: two types of container:
• The first are top-level containers: JFrame, JApplet, JWindow, and
Jdialog : not inherit JComponent. Do, however, inherit the AWT classes
Component and Container.
• Lightweight containers do inherit Jcomponent: Jpanel,
Component
Layout Manager
• Flow Layout
• Grid Layout
• Border Layout
• Card Layout
DIALOG BOXES
• message dialog box,
• coni rmation dialog box, and
• input dialog box.
import javax.swing.*;
public class TestSwing1{
public static void main(String[] args)
{
int age;
String name;
name=JOptionPane.showInputDialog("Enter your name:");
age=Integer.parseInt(JOptionPane.showInputDialog("Enter your age:"));
JOptionPane.showMessageDialog(null,"Your name is :" + name + "nr Your
age is " + age);
}
}
Your first
import javax.swing.*;
class TestSwing1 {
TestSwing1() {
// Create a new JFrame container.
JFrame jfrm = new JFrame("First Swing step");
// Give the frame an initial size.
jfrm.setSize(275, 100);
// Terminate the program when the user closes the application.
jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Create a text-based label.
JLabel jlab = new JLabel(" Swing means powerful GUIs.");
//Add the label to the content pane.
jfrm.add(jlab);
//Display the frame.
jfrm.setVisible(true);
}
public static void main(String args[]) {
new TestSwing1();
}
}
import javax.swing.*;
import java.awt.*;
class TestSwing1 extends JFrame {
JLabel jlab ;
TestSwing1() {
// Create a new JFrame container.
super ("First Swing step");
// Give the frame an initial size.
setSize(275, 100);
// Terminate the program when the user closes the application.
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Create a text-based label.
jlab=new JLabel();
Font font = new Font("Limon S1", Font.BOLD, 30);
jlab.setFont(font);
jlab.setText("sYsþIBiPBelakd¾QWcab;");
//Add the label to the content pane.
add(jlab);
//Display the frame.
setVisible(true);
}
public static void main(String args[]) {
new TestSwing1();
}
}
import java.awt.*;
import javax.swing.*;
import java.util.*;
public class TestSwing1 extends JFrame
{
public TestSwing1(int width, int height)
{
super("Alphabet + Numeric");
setLayout(new GridLayout(6,5));
setBounds(0, 0, width, height);
for(int i=0;i<26;i++)
{
Character alphabet =(char)(i + 'A');
JButton button =new JButton(alphabet.toString());
add(button);
}
for(int i=0;i<10;i++)
{
JButton buttonNum=new JButton(i + "");
add(buttonNum);
}}
public static void main(String[] args)
{
JFrame frame =new TestSwing1 (300, 300);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}}
import java.awt.GridLayout;
GridLayout fl = new GridLayout(4,2);
windowContent.setLayout(fl);
import javax.swing.*;
import java.awt.*;
public class TestSwing1 extends JPanel
{
public void paintComponent(Graphics g)
{
super.paintComponent(g); // Call the paintComponent method of the parent
g.setColor (Color.BLACK); // Use black for drawing in the panel
Font font = new Font("Limon S1", Font.BOLD, 80);
g.setFont (font); // Uses the Flat Brush font when drawing a String
setBackground(Color.GRAY) ;
g.drawString ("sYsþI kMuBüÚT½r)ak;kaNUt", 50, 50);
}
public static void main(String [ ] args)
{
JFrame frame = new JFrame("<---------->");
frame.setBounds(0, 0, 600, 200);
TestSwing1 ts = new TestSwing1();
frame.add(ts);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Event Handling
Chapter iv(modern gui)
Chapter iv(modern gui)

More Related Content

Viewers also liked

Ch11: File System Interface
Ch11: File System InterfaceCh11: File System Interface
Ch11: File System Interface
Ahmar Hashmi
 
Chapter 1 swings
Chapter 1 swingsChapter 1 swings
Chapter 1 swings
Jafar Nesargi
 
Java swing
Java swingJava swing
Java swing
Nataraj Dg
 
Virtual memory managment
Virtual memory managmentVirtual memory managment
Virtual memory managment
Santu Kumar
 
Operating system notes
Operating system notesOperating system notes
Operating system notes
SANTOSH RATH
 
Os solved question paper
Os solved question paperOs solved question paper
Os solved question paper
Ankit Bhatnagar
 
Operating system concepts (notes)
Operating system concepts (notes)Operating system concepts (notes)
Operating system concepts (notes)
Sohaib Danish
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
yht4ever
 
Chapter 2 - Operating System Structures
Chapter 2 - Operating System StructuresChapter 2 - Operating System Structures
Chapter 2 - Operating System Structures
Wayne Jones Jnr
 
Virtual memory and page replacement algorithm
Virtual memory and page replacement algorithmVirtual memory and page replacement algorithm
Virtual memory and page replacement algorithm
Muhammad Mansoor Ul Haq
 
1. introduction to swing
1. introduction to swing1. introduction to swing
1. introduction to swing
Tuan Ngo
 
Operating Systems - File Management
Operating Systems -  File ManagementOperating Systems -  File Management
Operating Systems - File Management
Damian T. Gordon
 

Viewers also liked (12)

Ch11: File System Interface
Ch11: File System InterfaceCh11: File System Interface
Ch11: File System Interface
 
Chapter 1 swings
Chapter 1 swingsChapter 1 swings
Chapter 1 swings
 
Java swing
Java swingJava swing
Java swing
 
Virtual memory managment
Virtual memory managmentVirtual memory managment
Virtual memory managment
 
Operating system notes
Operating system notesOperating system notes
Operating system notes
 
Os solved question paper
Os solved question paperOs solved question paper
Os solved question paper
 
Operating system concepts (notes)
Operating system concepts (notes)Operating system concepts (notes)
Operating system concepts (notes)
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
 
Chapter 2 - Operating System Structures
Chapter 2 - Operating System StructuresChapter 2 - Operating System Structures
Chapter 2 - Operating System Structures
 
Virtual memory and page replacement algorithm
Virtual memory and page replacement algorithmVirtual memory and page replacement algorithm
Virtual memory and page replacement algorithm
 
1. introduction to swing
1. introduction to swing1. introduction to swing
1. introduction to swing
 
Operating Systems - File Management
Operating Systems -  File ManagementOperating Systems -  File Management
Operating Systems - File Management
 

Similar to Chapter iv(modern gui)

SWING.pptx
SWING.pptxSWING.pptx
SWING.pptx
SamyakJain710491
 
Java Swing Handson Session (1).ppt
Java Swing Handson Session (1).pptJava Swing Handson Session (1).ppt
Java Swing Handson Session (1).ppt
ssuser076380
 
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
 
swings.pptx
swings.pptxswings.pptx
swings.pptx
Parameshwar Maddela
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
PRN USM
 
Swing
SwingSwing
SwingApplet.pptx
SwingApplet.pptxSwingApplet.pptx
SwingApplet.pptx
GEETHAS668001
 
Logic and Coding of Java Interfaces & Swing Applications
Logic and Coding of Java Interfaces & Swing ApplicationsLogic and Coding of Java Interfaces & Swing Applications
Logic and Coding of Java Interfaces & Swing Applications
kjkleindorfer
 
Chap1 1 1
Chap1 1 1Chap1 1 1
Chap1 1 1
Hemo Chella
 
Chap1 1.1
Chap1 1.1Chap1 1.1
Chap1 1.1
Hemo Chella
 
شرح مقرر البرمجة 2 لغة جافا - الوحدة التاسعة
شرح مقرر البرمجة 2   لغة جافا - الوحدة التاسعةشرح مقرر البرمجة 2   لغة جافا - الوحدة التاسعة
شرح مقرر البرمجة 2 لغة جافا - الوحدة التاسعة
جامعة القدس المفتوحة
 
Swings
SwingsSwings
Complete java swing
Complete java swingComplete java swing
Complete java swing
jehan1987
 
02 basic java programming and operators
02 basic java programming and operators02 basic java programming and operators
02 basic java programming and operators
Danairat Thanabodithammachari
 
Swing
SwingSwing
Swing
Fahim Khan
 
Swing
SwingSwing
Swing
Fahim Khan
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
Partnered Health
 
Gui
GuiGui
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1
sotlsoc
 
From Swing to JavaFX
From Swing to JavaFXFrom Swing to JavaFX
From Swing to JavaFX
Yuichi Sakuraba
 

Similar to Chapter iv(modern gui) (20)

SWING.pptx
SWING.pptxSWING.pptx
SWING.pptx
 
Java Swing Handson Session (1).ppt
Java Swing Handson Session (1).pptJava Swing Handson Session (1).ppt
Java Swing Handson Session (1).ppt
 
Z blue introduction to gui (39023299)
Z blue   introduction to gui (39023299)Z blue   introduction to gui (39023299)
Z blue introduction to gui (39023299)
 
swings.pptx
swings.pptxswings.pptx
swings.pptx
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
 
Swing
SwingSwing
Swing
 
SwingApplet.pptx
SwingApplet.pptxSwingApplet.pptx
SwingApplet.pptx
 
Logic and Coding of Java Interfaces & Swing Applications
Logic and Coding of Java Interfaces & Swing ApplicationsLogic and Coding of Java Interfaces & Swing Applications
Logic and Coding of Java Interfaces & Swing Applications
 
Chap1 1 1
Chap1 1 1Chap1 1 1
Chap1 1 1
 
Chap1 1.1
Chap1 1.1Chap1 1.1
Chap1 1.1
 
شرح مقرر البرمجة 2 لغة جافا - الوحدة التاسعة
شرح مقرر البرمجة 2   لغة جافا - الوحدة التاسعةشرح مقرر البرمجة 2   لغة جافا - الوحدة التاسعة
شرح مقرر البرمجة 2 لغة جافا - الوحدة التاسعة
 
Swings
SwingsSwings
Swings
 
Complete java swing
Complete java swingComplete java swing
Complete java swing
 
02 basic java programming and operators
02 basic java programming and operators02 basic java programming and operators
02 basic java programming and operators
 
Swing
SwingSwing
Swing
 
Swing
SwingSwing
Swing
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
 
Gui
GuiGui
Gui
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1
 
From Swing to JavaFX
From Swing to JavaFXFrom Swing to JavaFX
From Swing to JavaFX
 

More from Chhom Karath

set1.pdf
set1.pdfset1.pdf
set1.pdf
Chhom Karath
 
Set1.pptx
Set1.pptxSet1.pptx
Set1.pptx
Chhom Karath
 
orthodontic patient education.pdf
orthodontic patient education.pdforthodontic patient education.pdf
orthodontic patient education.pdf
Chhom Karath
 
New ton 3.pdf
New ton 3.pdfNew ton 3.pdf
New ton 3.pdf
Chhom Karath
 
ច្បាប់ញូតុនទី៣.pptx
ច្បាប់ញូតុនទី៣.pptxច្បាប់ញូតុនទី៣.pptx
ច្បាប់ញូតុនទី៣.pptx
Chhom Karath
 
Control tipping.pptx
Control tipping.pptxControl tipping.pptx
Control tipping.pptx
Chhom Karath
 
Bulbous loop.pptx
Bulbous loop.pptxBulbous loop.pptx
Bulbous loop.pptx
Chhom Karath
 
brush teeth.pptx
brush teeth.pptxbrush teeth.pptx
brush teeth.pptx
Chhom Karath
 
bracket size.pptx
bracket size.pptxbracket size.pptx
bracket size.pptx
Chhom Karath
 
arch form KORI copy.pptx
arch form KORI copy.pptxarch form KORI copy.pptx
arch form KORI copy.pptx
Chhom Karath
 
Bracket size
Bracket sizeBracket size
Bracket size
Chhom Karath
 
Couple
CoupleCouple
Couple
Chhom Karath
 
ច្បាប់ញូតុនទី៣
ច្បាប់ញូតុនទី៣ច្បាប់ញូតុនទី៣
ច្បាប់ញូតុនទី៣
Chhom Karath
 
Game1
Game1Game1
Shoe horn loop
Shoe horn loopShoe horn loop
Shoe horn loop
Chhom Karath
 
Opus loop
Opus loopOpus loop
Opus loop
Chhom Karath
 
V bend
V bendV bend
V bend
Chhom Karath
 
Closing loop
Closing loopClosing loop
Closing loop
Chhom Karath
 
Maxillary arch form
Maxillary arch formMaxillary arch form
Maxillary arch form
Chhom Karath
 
Front face analysis
Front face analysisFront face analysis
Front face analysis
Chhom Karath
 

More from Chhom Karath (20)

set1.pdf
set1.pdfset1.pdf
set1.pdf
 
Set1.pptx
Set1.pptxSet1.pptx
Set1.pptx
 
orthodontic patient education.pdf
orthodontic patient education.pdforthodontic patient education.pdf
orthodontic patient education.pdf
 
New ton 3.pdf
New ton 3.pdfNew ton 3.pdf
New ton 3.pdf
 
ច្បាប់ញូតុនទី៣.pptx
ច្បាប់ញូតុនទី៣.pptxច្បាប់ញូតុនទី៣.pptx
ច្បាប់ញូតុនទី៣.pptx
 
Control tipping.pptx
Control tipping.pptxControl tipping.pptx
Control tipping.pptx
 
Bulbous loop.pptx
Bulbous loop.pptxBulbous loop.pptx
Bulbous loop.pptx
 
brush teeth.pptx
brush teeth.pptxbrush teeth.pptx
brush teeth.pptx
 
bracket size.pptx
bracket size.pptxbracket size.pptx
bracket size.pptx
 
arch form KORI copy.pptx
arch form KORI copy.pptxarch form KORI copy.pptx
arch form KORI copy.pptx
 
Bracket size
Bracket sizeBracket size
Bracket size
 
Couple
CoupleCouple
Couple
 
ច្បាប់ញូតុនទី៣
ច្បាប់ញូតុនទី៣ច្បាប់ញូតុនទី៣
ច្បាប់ញូតុនទី៣
 
Game1
Game1Game1
Game1
 
Shoe horn loop
Shoe horn loopShoe horn loop
Shoe horn loop
 
Opus loop
Opus loopOpus loop
Opus loop
 
V bend
V bendV bend
V bend
 
Closing loop
Closing loopClosing loop
Closing loop
 
Maxillary arch form
Maxillary arch formMaxillary arch form
Maxillary arch form
 
Front face analysis
Front face analysisFront face analysis
Front face analysis
 

Recently uploaded

Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 

Recently uploaded (20)

Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 

Chapter iv(modern gui)

  • 2. Introduction • Swing is a set of classes that provides more powerful and flexible GUI components than does the AWT. • Swing program, including both applications and applets. • Swing has: – Component: derived from the JComponent class – Container: two types of container: • The first are top-level containers: JFrame, JApplet, JWindow, and Jdialog : not inherit JComponent. Do, however, inherit the AWT classes Component and Container. • Lightweight containers do inherit Jcomponent: Jpanel,
  • 4. Layout Manager • Flow Layout • Grid Layout • Border Layout • Card Layout
  • 5. DIALOG BOXES • message dialog box, • coni rmation dialog box, and • input dialog box.
  • 6. import javax.swing.*; public class TestSwing1{ public static void main(String[] args) { int age; String name; name=JOptionPane.showInputDialog("Enter your name:"); age=Integer.parseInt(JOptionPane.showInputDialog("Enter your age:")); JOptionPane.showMessageDialog(null,"Your name is :" + name + "nr Your age is " + age); } }
  • 7. Your first import javax.swing.*; class TestSwing1 { TestSwing1() { // Create a new JFrame container. JFrame jfrm = new JFrame("First Swing step"); // Give the frame an initial size. jfrm.setSize(275, 100); // Terminate the program when the user closes the application. jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create a text-based label. JLabel jlab = new JLabel(" Swing means powerful GUIs."); //Add the label to the content pane. jfrm.add(jlab); //Display the frame. jfrm.setVisible(true); } public static void main(String args[]) { new TestSwing1(); } } import javax.swing.*; import java.awt.*; class TestSwing1 extends JFrame { JLabel jlab ; TestSwing1() { // Create a new JFrame container. super ("First Swing step"); // Give the frame an initial size. setSize(275, 100); // Terminate the program when the user closes the application. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create a text-based label. jlab=new JLabel(); Font font = new Font("Limon S1", Font.BOLD, 30); jlab.setFont(font); jlab.setText("sYsþIBiPBelakd¾QWcab;"); //Add the label to the content pane. add(jlab); //Display the frame. setVisible(true); } public static void main(String args[]) { new TestSwing1(); } }
  • 8. import java.awt.*; import javax.swing.*; import java.util.*; public class TestSwing1 extends JFrame { public TestSwing1(int width, int height) { super("Alphabet + Numeric"); setLayout(new GridLayout(6,5)); setBounds(0, 0, width, height); for(int i=0;i<26;i++) { Character alphabet =(char)(i + 'A'); JButton button =new JButton(alphabet.toString()); add(button); } for(int i=0;i<10;i++) { JButton buttonNum=new JButton(i + ""); add(buttonNum); }} public static void main(String[] args) { JFrame frame =new TestSwing1 (300, 300); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }}
  • 9. import java.awt.GridLayout; GridLayout fl = new GridLayout(4,2); windowContent.setLayout(fl);
  • 10.
  • 11.
  • 12.
  • 13. import javax.swing.*; import java.awt.*; public class TestSwing1 extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); // Call the paintComponent method of the parent g.setColor (Color.BLACK); // Use black for drawing in the panel Font font = new Font("Limon S1", Font.BOLD, 80); g.setFont (font); // Uses the Flat Brush font when drawing a String setBackground(Color.GRAY) ; g.drawString ("sYsþI kMuBüÚT½r)ak;kaNUt", 50, 50); } public static void main(String [ ] args) { JFrame frame = new JFrame("<---------->"); frame.setBounds(0, 0, 600, 200); TestSwing1 ts = new TestSwing1(); frame.add(ts); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }

Editor's Notes

  1. import javax.swing.*; import java.awt.FlowLayout; public class TestSwing1 { public static void main(String[] args) { // Create a panel JPanel windowContent= new JPanel(); // Set a layout manager for this panel FlowLayout fl = new FlowLayout(); windowContent.setLayout(fl); // Create controls in memory JLabel label1 = new JLabel("Value 1:"); windowContent.add(label1); JTextField field1 = new JTextField(10); windowContent.add(field1); JLabel label2 = new JLabel("Value 2:"); windowContent.add(label2); JTextField field2 = new JTextField(10); windowContent.add(field2); JLabel lbResult=new JLabel("Result:");windowContent.add(lbResult); JTextField result = new JTextField(10); windowContent.add(result); JButton go = new JButton("Sum"); windowContent.add(go); // Create the frame and add the panel to it JFrame frame = new JFrame("My First Calculator"); frame.setContentPane(windowContent); // set the size and make the window visible frame.setSize(700,100); frame.setVisible(true); } }
  2. import java.sql.*; import javax.swing.*; import com.sun.java.swing.plaf.windows.resources.windows; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class TestDB extends JFrame { JTextField JtxtPhoneID,JtxtPhoneNum,JtxtDesc,JtxtEmail,JtxtName; JButton JbNew,JbInsert,JbUpdate,JbDelete,JbExit,JbFirst,JbNext,JbPrev,JbLast; static JTextArea JtxtA=null; public TestDB(String title) { super(title); JPanel jp1=new JPanel(); GridLayout gl=new GridLayout(5,2); jp1.setLayout(gl); JLabel JlPhoneID=new JLabel("PhoneID:");jp1.add(JlPhoneID);JtxtPhoneID=new JTextField(20);jp1.add(JtxtPhoneID); JLabel JlName=new JLabel("Name:");jp1.add(JlName);JtxtName=new JTextField(20);jp1.add(JtxtName); JLabel JlPhoneNum=new JLabel("Phone number:");jp1.add(JlPhoneNum);JtxtPhoneNum=new JTextField(20);jp1.add(JtxtPhoneNum); JLabel JlEmail=new JLabel("E-mail:");jp1.add(JlEmail);JtxtEmail=new JTextField(20);jp1.add(JtxtEmail); JLabel JlDesc=new JLabel("Description:");jp1.add(JlDesc);JtxtDesc=new JTextField(20);jp1.add(JtxtDesc); JPanel jp2=new JPanel(); jp2.setLayout(new FlowLayout()); JbNew=new JButton("New");jp2.add(JbNew); JbInsert=new JButton("Insert");jp2.add(JbInsert); JbUpdate=new JButton("Update");jp2.add(JbUpdate); JbDelete=new JButton("Delete");jp2.add(JbDelete); JbExit=new JButton("Exit");jp2.add(JbExit); JtxtA=new JTextArea(10,40); JPanel jp3=new JPanel(); jp3.setLayout(new BorderLayout()); jp3.add(jp1,BorderLayout.NORTH); jp3.add(jp2,BorderLayout.CENTER); JPanel jp4=new JPanel(); jp4.setLayout(new FlowLayout()); JbFirst=new JButton("|<");jp4.add(JbFirst); JbPrev=new JButton("<");jp4.add(JbPrev); JbNext=new JButton(">");jp4.add(JbNext); JbLast=new JButton(">|");jp4.add(JbLast); JPanel jp=new JPanel(); jp.add(jp3,BorderLayout.NORTH); jp.add(JtxtA,BorderLayout.CENTER); jp.add(jp4,BorderLayout.SOUTH); JbNew.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { JtxtPhoneID.setText(""); JtxtName.setText(""); JtxtEmail.setText(""); JtxtDesc.setText(""); JtxtPhoneNum.setText(""); } }); JbExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.exit(0); } }); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); add(jp); setBounds(200,200,500,500); //setSize(400,200); setVisible(true); } public static void main(String[] args) { new TestDB("DBMS"); } }
  3. import javax.swing.*; import java.awt.*; class TestSwing1 { TestSwing1() { // Create a new JFrame container. JFrame jfrm = new JFrame("Guesting number"); JPanel jp1=new JPanel(); jp1.setLayout(new FlowLayout()); JLabel jlNumber=new JLabel("Guest number(1-10):");jp1.add(jlNumber); JTextField jTxtNumber=new JTextField(10);jp1.add(jTxtNumber); JButton jbok=new JButton("Apply");jp1.add(jbok); JPanel jp2=new JPanel(); jp2.setLayout(new GridLayout(2,1)); JLabel lbResult=new JLabel("----------------------------------------Result--------------------------------------------");jp2.add(lbResult); JTextField jTxtResult=new JTextField(10);jp2.add(jTxtResult); JPanel jp=new JPanel(); jp.setLayout(new BorderLayout()); jp.add(jp1,BorderLayout.NORTH); jp.add(jp2,BorderLayout.CENTER); // Give the frame an initial size. jfrm.setSize(400, 150); // Terminate the program when the user closes the application. jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create a text-based label. JLabel jlab = new JLabel(" Swing means powerful GUIs."); //Add the label to the content pane. jfrm.add(jp); //Display the frame. jfrm.setVisible(true); } public static void main(String args[]) { new TestSwing1(); } }
  4. import javax.swing.*; import java.awt.GridLayout; import java.awt.BorderLayout; public class TestSwing1 { // Declaration of all calculator's components. JPanel windowContent; JTextField displayField; JButton button0; JButton button1; JButton button2; JButton button3; JButton button4; JButton button5; JButton button6; JButton button7; JButton button8; JButton button9; JButton buttonPoint; JButton buttonEqual; JPanel p1; // Constructor creates the components in memory // and adds the to the frame using combination of // Borderlayout and Gridlayout TestSwing1(){ windowContent= new JPanel(); // Set the layout manager for this panel BorderLayout bl = new BorderLayout(); windowContent.setLayout(bl); // Create the display field and place it in the // North area of the window displayField = new JTextField(30); windowContent.add("North",displayField); // Create buttons using constructor of the // class JButton that takes the label of the // button as a parameter button0=new JButton("0"); button1=new JButton("1"); button2=new JButton("2"); button3=new JButton("3"); button4=new JButton("4"); button5=new JButton("5"); button6=new JButton("6"); button7=new JButton("7"); button8=new JButton("8"); button9=new JButton("9"); buttonPoint = new JButton("."); buttonEqual=new JButton("="); // Create the panel with the GridLayout // that will contain 12 buttons - 10 numeric // ones, and buttons with the point and the // equal sign p1 = new JPanel(); GridLayout gl =new GridLayout(4,3); p1.setLayout(gl); // Add window controls to the panel p1 p1.add(button1); p1.add(button2); p1.add(button3); p1.add(button4); p1.add(button5); p1.add(button6); p1.add(button7); p1.add(button8); p1.add(button9); p1.add(button0); p1.add(buttonPoint); p1.add(buttonEqual); // Add the panel p1 to the center area // of the window windowContent.add("Center",p1); //Create the frame and set its content pane JFrame frame = new JFrame("Calculator"); frame.setContentPane(windowContent); // set the size of the window to be big enough // to accomodate all controls frame.pack(); // Finally, display the window frame.setVisible(true); } public static void main(String[] args) { TestSwing1 calc = new TestSwing1(); } }
  5. // Handle an event in a Swing program. import java.awt.*; import java.awt.event.*; import javax.swing.*; class TestSwing1 { JLabel jlab; TestSwing1() { JFrame jfrm = new JFrame("An Event Example"); jfrm.setLayout(new FlowLayout()); jfrm.setSize(300, 150); jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton backTouk = new JButton("Bactouk center"); JButton itl = new JButton("IT-L center"); backTouk.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ jlab.setText("You choose: BackTouk Computer center"); } }); itl.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { jlab.setText("You choose IT-L center"); } }); jfrm.add(backTouk); jfrm.add(itl); // Create a text-based label. jlab = new JLabel("Press a button."); // Add the label to the content pane. jfrm.add(jlab); // Display the frame. jfrm.setVisible(true); } public static void main(String args[]) { // Create the frame on the event dispatching thread. new TestSwing1(); } }
  6. import javax.swing.*; import java.awt.*; import java.util.Random; import java.awt.event.*; class TestSwing1 { JButton jbok; JTextField jTxtNumber; JTextField jTxtResult; TestSwing1() { // Create a new JFrame container. JFrame jfrm = new JFrame("Guesting number"); JPanel jp1=new JPanel(); jp1.setLayout(new FlowLayout()); JLabel jlNumber=new JLabel("Guest number(1-10):");jp1.add(jlNumber); jTxtNumber=new JTextField(10);jp1.add(jTxtNumber); jbok=new JButton("Apply");jp1.add(jbok); JPanel jp2=new JPanel(); jp2.setLayout(new GridLayout(2,1)); JLabel lbResult=new JLabel("----------------------------------------Result--------------------------------------------");jp2.add(lbResult); jTxtResult=new JTextField(10);jp2.add(jTxtResult); JPanel jp=new JPanel(); jp.setLayout(new BorderLayout()); jp.add(jp1,BorderLayout.NORTH); jp.add(jp2,BorderLayout.CENTER); jbok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { if(jTxtNumber.getText().equals(null)==true || jTxtNumber.getText().equals("")==true) { jTxtResult.setText("Please insert data."); } else if(Integer.parseInt(jTxtNumber.getText())<0 || Integer.parseInt(jTxtNumber.getText())>10) { jTxtResult.setText(" You insert data over number, insert data from 1 to 10."); } else { Random randomGenerator = new Random(); int randomInt = randomGenerator.nextInt(10)+1; jTxtResult.setText("The result is " + randomInt); if(Integer.parseInt(jTxtNumber.getText())==randomInt) { jTxtResult.setText(jTxtResult.getText()+ "<<You win>>"); } else jTxtResult.setText(jTxtResult.getText()+ "<<You lost>>"); } } }); // Give the frame an initial size. jfrm.setSize(400, 150); // Terminate the program when the user closes the application. jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create a text-based label. JLabel jlab = new JLabel(" Swing means powerful GUIs."); //Add the label to the content pane. jfrm.add(jp); //Display the frame. jfrm.setVisible(true); } public static void main(String args[]) { new TestSwing1(); } }
  7. package lessSwing; import java.awt.EventQueue; import java.text.*; import javax.swing.*; import javax.swing.JFrame; import javax.swing.JLabel; import java.awt.Font; import javax.swing.JTextField; import javax.swing.JButton; import java.awt.Color; import javax.swing.JRadioButton; import javax.swing.JComboBox; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.GridBagLayout; import javax.swing.ButtonGroup; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; public class MoneyExchange { private JFrame frame; private JTextField txtRiel; private JTextField txtBat; private JTextField txtDolar; private JTextField txtRate; private JRadioButton rRielDolar; private JRadioButton rRielBat; private JRadioButton rBatRiel; private JRadioButton rBatDolar; private JRadioButton rDolarRiel; private JRadioButton rDolarBat; private JLabel lbNote; private int sel; public void visibleRadioBox() { txtDolar.setVisible(true); txtRiel.setVisible(true); txtBat.setVisible(true); txtDolar.setEditable(true); txtRiel.setEditable(true); txtBat.setEditable(true); } /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { MoneyExchange window = new MoneyExchange(); window.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the application. */ public MoneyExchange() { sel=-1; initialize(); } /** * Initialize the contents of the frame. */ private void initialize() { frame = new JFrame(); frame.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent arg0) { lbNote.setText("សូមជ្រើសរើសប្រភេទលុយដែលធ្វើការដោះដូរ"); } }); frame.getContentPane().setLocation(0, -235); frame.setBounds(100, 100, 515, 440); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); lbNote = new JLabel("ដូរលុយខ្មែរ ទៅ"); lbNote.setBounds(10, 22, 460, 43); lbNote.setForeground(new Color(255, 0, 0)); lbNote.setFont(new Font("Khmer OS Metal Chrieng", Font.PLAIN, 16)); frame.getContentPane().add(lbNote); JLabel label = new JLabel("\u179B\u17BB\u1799\u179A\u17C0\u179B:"); label.setBounds(10, 75, 96, 43); label.setFont(new Font("Khmer OS", Font.PLAIN, 12)); frame.getContentPane().add(label); txtRiel = new JTextField(); txtRiel.setFont(new Font("Khmer OS", Font.PLAIN, 15)); txtRiel.setBounds(111, 81, 246, 26); frame.getContentPane().add(txtRiel); txtRiel.setColumns(10); txtBat = new JTextField(); txtBat.setFont(new Font("Khmer OS", Font.PLAIN, 15)); txtBat.setBounds(111, 120, 246, 26); txtBat.setColumns(10); frame.getContentPane().add(txtBat); JLabel label_1 = new JLabel("\u179B\u17BB\u1799\u1794\u17B6\u178F:"); label_1.setBounds(10, 114, 96, 43); label_1.setFont(new Font("Khmer OS", Font.PLAIN, 12)); frame.getContentPane().add(label_1); txtDolar = new JTextField(); txtDolar.setFont(new Font("Khmer OS", Font.PLAIN, 15)); txtDolar.setBounds(111, 163, 246, 26); txtDolar.setColumns(10); frame.getContentPane().add(txtDolar); JLabel label_2 = new JLabel("\u179B\u17BB\u1799\u178A\u17BB\u179B\u17D2\u179B\u17B6:"); label_2.setBounds(10, 157, 96, 43); label_2.setFont(new Font("Khmer OS", Font.PLAIN, 12)); frame.getContentPane().add(label_2); txtRate = new JTextField(); txtRate.setFont(new Font("Khmer OS", Font.PLAIN, 15)); txtRate.setBounds(111, 200, 246, 26); txtRate.setColumns(10); frame.getContentPane().add(txtRate); JLabel label_3 = new JLabel("\u17A2\u178F\u17D2\u179A\u17B6\u178A\u17BC\u179A\u1794\u17D2\u179A\u17B6\u1780\u17CB"); label_3.setBounds(10, 194, 96, 43); label_3.setFont(new Font("Khmer OS", Font.PLAIN, 12)); frame.getContentPane().add(label_3); JButton btOK = new JButton("\u1799\u179B\u17CB\u1796\u17D2\u179A\u1798"); btOK.setBounds(381, 81, 89, 32); btOK.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { double bat,dolar,riel; if(txtRate.getText().isEmpty()) { JOptionPane.showMessageDialog(null,"Please, enter rate", "", JOptionPane.INFORMATION_MESSAGE); txtRate.requestFocus(); } else if(sel==-1) { JOptionPane.showMessageDialog(null,"Please, select currency type", "", JOptionPane.INFORMATION_MESSAGE); } else if(sel==0) { if(txtRiel.getText().isEmpty()) { JOptionPane.showMessageDialog(null,"Please, enter riel currency", "", JOptionPane.OK_OPTION); txtRiel.requestFocus(); } else { bat= Double.parseDouble(txtRiel.getText())/Double.parseDouble(txtRate.getText()); DecimalFormat myFormatter = new DecimalFormat("###.## Bat"); String output = myFormatter.format(bat); txtBat.setText(output); } } else if(sel==1) { if(txtRiel.getText().isEmpty()) { JOptionPane.showMessageDialog(null,"Please, enter riel currency", "", JOptionPane.OK_OPTION); txtRiel.requestFocus(); } else { dolar= Double.parseDouble(txtRiel.getText())/Double.parseDouble(txtRate.getText()); DecimalFormat myFormatter = new DecimalFormat("###.## $"); String output = myFormatter.format(dolar); txtDolar.setText(output); txtBat.setText(""); } } else if(sel==2) { if(txtBat.getText().isEmpty()) { JOptionPane.showMessageDialog(null,"Please, enter bat currency", "", JOptionPane.OK_OPTION); txtBat.requestFocus(); } else { riel= Double.parseDouble(txtBat.getText())*Double.parseDouble(txtRate.getText()); txtDolar.setText(""); DecimalFormat myFormatter = new DecimalFormat("###.## Riel"); String output = myFormatter.format(riel); txtRiel.setText(output); } } else if(sel==3) { if(txtBat.getText().isEmpty()) { JOptionPane.showMessageDialog(null,"Please, enter bat currency", "", JOptionPane.OK_OPTION); txtBat.requestFocus(); } else { dolar= Double.parseDouble(txtBat.getText())/Double.parseDouble(txtRate.getText()); DecimalFormat myFormatter = new DecimalFormat("###.## $"); String output = myFormatter.format(dolar); txtDolar.setText(output); txtRiel.setText(""); } } else if(sel==4) { if(txtDolar.getText().isEmpty()) { JOptionPane.showMessageDialog(null,"Please, enter dollar currency", "", JOptionPane.OK_OPTION); txtDolar.requestFocus(); } else { riel= Double.parseDouble(txtDolar.getText())*Double.parseDouble(txtRate.getText()); DecimalFormat myFormatter = new DecimalFormat("###.## Riel"); String output = myFormatter.format(riel); txtRiel.setText(output); txtBat.setText(""); } } else if(sel==5) { if(txtDolar.getText().isEmpty()) { JOptionPane.showMessageDialog(null,"Please, enter dollar currency", "", JOptionPane.OK_OPTION); txtDolar.requestFocus(); } else { bat= Double.parseDouble(txtDolar.getText())*Double.parseDouble(txtRate.getText()); DecimalFormat myFormatter = new DecimalFormat("###.## Bat"); String output = myFormatter.format(bat); txtBat.setText(output); txtRiel.setText(""); } } } }); btOK.setFont(new Font("Khmer OS Content", Font.PLAIN, 14)); frame.getContentPane().add(btOK); JButton btClear = new JButton("\u179F\u17C6\u17A2\u17B6\u178F"); btClear.setBounds(381, 122, 89, 32); btClear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { txtBat.setText(""); txtDolar.setText(""); txtRiel.setText(""); txtRate.setText(""); } }); btClear.setFont(new Font("Khmer OS Content", Font.PLAIN, 14)); frame.getContentPane().add(btClear); JButton btExit = new JButton("\u1785\u17B6\u1780\u1785\u17C1\u1789"); btExit.setBounds(381, 165, 89, 32); btExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.exit(0); } }); btExit.setFont(new Font("Khmer OS Content", Font.PLAIN, 14)); frame.getContentPane().add(btExit); JPanel panel = new JPanel(); panel.setBounds(10, 237, 400, 129); frame.getContentPane().add(panel); panel.setLayout(null); ButtonGroup bg1=new ButtonGroup(); JRadioButton rRielBat = new JRadioButton("លុយរៀលទៅបាត"); rRielBat.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { lbNote.setText("ដូរលុយរៀលទៅបាត"); sel=0; visibleRadioBox(); txtDolar.setVisible(false); txtBat.setEditable(false); } }); rRielBat.setBounds(8, 11, 189, 28); rRielBat.setFont(new Font("Khmer OS", Font.PLAIN, 10)); bg1.add(rRielBat); rRielDolar = new JRadioButton("លុយរៀលទៅដុល្លា"); rRielDolar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { lbNote.setText("ដូរលុយរៀលទៅដុល្លា"); sel=1; visibleRadioBox(); txtDolar.setEditable(false); txtBat.setVisible(false); } }); rRielDolar.setBounds(202, 5, 189, 41); rRielDolar.setFont(new Font("Khmer OS", Font.PLAIN, 10)); bg1.add(rRielDolar); rBatRiel = new JRadioButton("លុយបាតទៅរៀល"); rBatRiel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { lbNote.setText("ដូរលុយបាតទៅរៀល"); sel=2; visibleRadioBox(); txtRiel.setEditable(false); txtDolar.setVisible(false); } }); rBatRiel.setBounds(8, 36, 195, 41); rBatRiel.setFont(new Font("Khmer OS", Font.PLAIN, 10)); bg1.add(rBatRiel); rBatDolar = new JRadioButton("លុយបាតទៅដុល្លា"); rBatDolar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { lbNote.setText("ដូរលុយបាតទៅដុល្លា"); sel=3; visibleRadioBox(); txtDolar.setEditable(false); txtRiel.setVisible(false); } }); rBatDolar.setFont(new Font("Khmer OS", Font.PLAIN, 10)); rBatDolar.setBounds(202, 36, 195, 41); bg1.add(rBatDolar); rDolarRiel = new JRadioButton("លុយដុល្លាទៅរៀល"); rDolarRiel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { lbNote.setText("ដូរលុយដុល្លាទៅរៀល"); sel=4; visibleRadioBox(); txtRiel.setEditable(false); txtBat.setVisible(false); } }); rDolarRiel.setFont(new Font("Khmer OS", Font.PLAIN, 10)); rDolarRiel.setBounds(8, 66, 195, 41); bg1.add(rDolarRiel); rDolarBat = new JRadioButton("លុយដុល្លាទៅបាត"); rDolarBat.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { lbNote.setText("ដូរលុយដុល្លាទៅបាត"); sel=5; visibleRadioBox(); txtBat.setEditable(false); txtRiel.setVisible(false); } }); rDolarBat.setFont(new Font("Khmer OS", Font.PLAIN, 10)); rDolarBat.setBounds(202, 66, 195, 41); bg1.add(rDolarBat); panel.add(rDolarRiel); panel.add(rDolarBat); panel.add(rBatDolar); panel.add(rBatRiel); panel.add(rRielDolar); panel.add(rRielBat); } }