SlideShare a Scribd company logo
1 of 4
EXERCISE 1
Code:
importjava.awt.*; // import abstract window toolkit package
importjava.awt.event.*; // import class event from awt package
importjavax.swing.*;
public class PendaftaranPelajar extends Frame implements ActionListener
{
JButton Bmerah, Bhijau, Bkuning, Bmerahtua, Bkelabu, Boren;
JLabel selamat,nama, program, matrik, notel, jabatan;
JTextField tnama, tprogram, tmatrik, tnotel;
public static void main (String arg [])
{
PendaftaranPelajar f = new PendaftaranPelajar ("SistemPendaftaranPelajar");
f.addWindowListener (new WindowEventHandler());
f.setSize (400,200); // set the frame size
f.setVisible(true); // display the frame
}
publicPendaftaranPelajar (String str)
{
super (str);
setLayout(new FlowLayout());
selamat= new JLabel ("Selamat Datang! Sila Pilih Warna Kegemaran Anda dan Penuhkan Form yang
Disediakan.");
Bmerah=new JButton ("RED");
Bhijau=new JButton ("GREEN");
Bkuning=new JButton ("YELLOW");
Bmerahtua=new JButton ("MAGENTA");
Bkelabu=new JButton ("CYAN");
Boren=new JButton ("ORANGE");
nama= new JLabel ("NamaPenuh :");
TextField tnama= new TextField(20);
program= new JLabel ("Program :");
TextField tprogram= new TextField(20);
matrik= new JLabel ("NomborMatrik :");
TextField tmatrik= new TextField(15);
notel= new JLabel ("NomborTelefon : ");
TextField tnotel= new TextField(15);
jabatan= new JLabel ("Jabatan :");
Choice pilihan=new Choice();
pilihan.add("JabatanKejuteraanMekanikal");
pilihan.add("JabatanTeknologiMaklumat Dan Komunikasi");
pilihan.add ("JabatanMatematikSainsKomputer");
pilihan.add ("JabatanKejuteraanEletrik");
pilihan.add ("JabatanKejuteraanAwam");
pilihan.add ("JabatanPengaturcaraanAwam");
add (selamat);
add(Bmerah);
add(Bhijau);
add(Bkuning);
add(Bmerahtua);
add(Bkelabu);
add(Boren);
add(nama);
add(tnama);
add (program);
add (tprogram);
add (matrik);
add (tmatrik);
add (notel);
add (tnotel);
add (jabatan);
add (pilihan);
Bmerah.addActionListener(this);
Bhijau.addActionListener(this);
Bkuning.addActionListener(this);
Bmerahtua.addActionListener(this);
Bkelabu.addActionListener(this);
Boren.addActionListener(this);
}
public void actionPerformed (ActionEvent e)
{
Object pilihan=e.getSource();
Color warna = getBackground();
if (pilihan==Bmerah)
{
warna=Color.red;
}
else
if(pilihan==Bhijau)
{
warna=Color.green;
}
else
if(pilihan==Bkuning)
{
warna=Color.yellow;
}
else
if(pilihan==Bmerahtua)
{
warna=Color.magenta;
}
else
if(pilihan==Bkelabu)
{
warna=Color.cyan;
}
else
if(pilihan==Boren)
{
warna=Color.orange;
}
setBackground (warna);
repaint();
}
}
classWindowEventHandler extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
Exercise 2
importjava.awt.*; // import abstract window toolkit package
importjava.awt.event.*; // import class event from awt package
importjavax.swing.*;
public class TestingButtons extends Frame implements ActionListener
{
JButtonBplain, Bfancy;
public static void main (String arg [])
{
TestingButtons f = new TestingButtons ("Testing Button");
f.addWindowListener (new WindowEventHandler());
f.setSize (400,200); // set the frame size
f.setVisible(true); // display the frame
}
publicTestingButtons (String str)
{
super (str);
setLayout(new FlowLayout());
Bplain=new JButton ("PLAIN BUTTON");
Bfancy=new JButton ("FANCY BUTTON");
add(Bplain);
add(Bfancy);
Bplain.addActionListener(this);
Bfancy.addActionListener(this);
}
public void actionPerformed (ActionEvent e)
{
Object pilihan=e.getSource();
if (pilihan==Bplain)
{
JOptionPane.showMessageDialog (null, "You pressed: Plain Button");
}
else
if(pilihan==Bfancy)
{
JOptionPane.showMessageDialog (null, "You pressed: Fancy Button");
}
}
}
class WindowEventHandler extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}

More Related Content

Featured

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Featured (20)

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

web programming use jcreator mira

  • 1. EXERCISE 1 Code: importjava.awt.*; // import abstract window toolkit package importjava.awt.event.*; // import class event from awt package importjavax.swing.*; public class PendaftaranPelajar extends Frame implements ActionListener { JButton Bmerah, Bhijau, Bkuning, Bmerahtua, Bkelabu, Boren; JLabel selamat,nama, program, matrik, notel, jabatan; JTextField tnama, tprogram, tmatrik, tnotel; public static void main (String arg []) { PendaftaranPelajar f = new PendaftaranPelajar ("SistemPendaftaranPelajar"); f.addWindowListener (new WindowEventHandler()); f.setSize (400,200); // set the frame size f.setVisible(true); // display the frame } publicPendaftaranPelajar (String str) { super (str); setLayout(new FlowLayout()); selamat= new JLabel ("Selamat Datang! Sila Pilih Warna Kegemaran Anda dan Penuhkan Form yang Disediakan."); Bmerah=new JButton ("RED"); Bhijau=new JButton ("GREEN"); Bkuning=new JButton ("YELLOW"); Bmerahtua=new JButton ("MAGENTA"); Bkelabu=new JButton ("CYAN"); Boren=new JButton ("ORANGE"); nama= new JLabel ("NamaPenuh :"); TextField tnama= new TextField(20); program= new JLabel ("Program :"); TextField tprogram= new TextField(20); matrik= new JLabel ("NomborMatrik :"); TextField tmatrik= new TextField(15); notel= new JLabel ("NomborTelefon : "); TextField tnotel= new TextField(15); jabatan= new JLabel ("Jabatan :"); Choice pilihan=new Choice(); pilihan.add("JabatanKejuteraanMekanikal"); pilihan.add("JabatanTeknologiMaklumat Dan Komunikasi"); pilihan.add ("JabatanMatematikSainsKomputer"); pilihan.add ("JabatanKejuteraanEletrik"); pilihan.add ("JabatanKejuteraanAwam"); pilihan.add ("JabatanPengaturcaraanAwam"); add (selamat); add(Bmerah);
  • 2. add(Bhijau); add(Bkuning); add(Bmerahtua); add(Bkelabu); add(Boren); add(nama); add(tnama); add (program); add (tprogram); add (matrik); add (tmatrik); add (notel); add (tnotel); add (jabatan); add (pilihan); Bmerah.addActionListener(this); Bhijau.addActionListener(this); Bkuning.addActionListener(this); Bmerahtua.addActionListener(this); Bkelabu.addActionListener(this); Boren.addActionListener(this); } public void actionPerformed (ActionEvent e) { Object pilihan=e.getSource(); Color warna = getBackground(); if (pilihan==Bmerah) { warna=Color.red; } else if(pilihan==Bhijau) { warna=Color.green; } else if(pilihan==Bkuning) { warna=Color.yellow; } else if(pilihan==Bmerahtua) { warna=Color.magenta; } else if(pilihan==Bkelabu) { warna=Color.cyan; } else if(pilihan==Boren) { warna=Color.orange;
  • 3. } setBackground (warna); repaint(); } } classWindowEventHandler extends WindowAdapter { public void windowClosing(WindowEvent e) { System.exit(0); } } Exercise 2 importjava.awt.*; // import abstract window toolkit package importjava.awt.event.*; // import class event from awt package importjavax.swing.*; public class TestingButtons extends Frame implements ActionListener { JButtonBplain, Bfancy; public static void main (String arg []) { TestingButtons f = new TestingButtons ("Testing Button"); f.addWindowListener (new WindowEventHandler()); f.setSize (400,200); // set the frame size f.setVisible(true); // display the frame } publicTestingButtons (String str) { super (str); setLayout(new FlowLayout()); Bplain=new JButton ("PLAIN BUTTON"); Bfancy=new JButton ("FANCY BUTTON"); add(Bplain); add(Bfancy); Bplain.addActionListener(this); Bfancy.addActionListener(this); }
  • 4. public void actionPerformed (ActionEvent e) { Object pilihan=e.getSource(); if (pilihan==Bplain) { JOptionPane.showMessageDialog (null, "You pressed: Plain Button"); } else if(pilihan==Bfancy) { JOptionPane.showMessageDialog (null, "You pressed: Fancy Button"); } } } class WindowEventHandler extends WindowAdapter { public void windowClosing(WindowEvent e) { System.exit(0); } }