SlideShare a Scribd company logo
1 of 5
Download to read offline
program for JRiddle.java
package riddle;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Riddle implements ActionListener {
private final String LABEL_TEXT = "What is your longterm goal?";
JFrame frame;
JPanel contentPane;
JLabel label, label1;
JButton button;
JButton button1;
private static int i;
public Riddle() {
/* Create and set up the frame */
frame = new JFrame(LABEL_TEXT);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
/* Create a content pane with a GridLayout and empty borders */
contentPane = new JPanel();
contentPane.setLayout(new GridLayout(0, 2, 10, 5));
/* Create and add label that is centered and has empty borders */
label = new JLabel("Why did the chicken cross the road?");
label.setAlignmentX(JButton.LEFT_ALIGNMENT);
label.setBorder(BorderFactory.createEmptyBorder(20, 50, 20, 50));
contentPane.add(label);
label1 = new JLabel(" ");
label1.setAlignmentX(JButton.LEFT_ALIGNMENT);
label1.setBorder(BorderFactory.createEmptyBorder(20, 50, 20, 50));
contentPane.add(label1);
/* Create and add button that is centered */
button = new JButton("Answer");
button.setAlignmentX(JButton.RIGHT_ALIGNMENT);
button.setActionCommand("Show Answer");
button.addActionListener(this);
contentPane.add(button);
/* Add content pane to frame */
frame.setContentPane(contentPane);
/* Size and then display the frame */
frame.pack();
frame.setVisible(true);
}
/** Handle button click action event
* pre:
* post: clicked button shows answer
*/
public void actionPerformed(ActionEvent event) {
String eventName = event.getActionCommand();
if (eventName.equals("Show Answer")) {
label1.setText("To become architect ");
label1.setFont(new Font("Serif",Font.PLAIN,30));
button.setText("Answer");
button.setActionCommand("Answer");
}
}
/**
* Create and show the GUI
*/
private static void runGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);
Riddle greeting = new Riddle();
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
runGUI();
}
});
}
}
output:
what is your longterm goal? architectanswer
Solution
program for JRiddle.java
package riddle;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Riddle implements ActionListener {
private final String LABEL_TEXT = "What is your longterm goal?";
JFrame frame;
JPanel contentPane;
JLabel label, label1;
JButton button;
JButton button1;
private static int i;
public Riddle() {
/* Create and set up the frame */
frame = new JFrame(LABEL_TEXT);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
/* Create a content pane with a GridLayout and empty borders */
contentPane = new JPanel();
contentPane.setLayout(new GridLayout(0, 2, 10, 5));
/* Create and add label that is centered and has empty borders */
label = new JLabel("Why did the chicken cross the road?");
label.setAlignmentX(JButton.LEFT_ALIGNMENT);
label.setBorder(BorderFactory.createEmptyBorder(20, 50, 20, 50));
contentPane.add(label);
label1 = new JLabel(" ");
label1.setAlignmentX(JButton.LEFT_ALIGNMENT);
label1.setBorder(BorderFactory.createEmptyBorder(20, 50, 20, 50));
contentPane.add(label1);
/* Create and add button that is centered */
button = new JButton("Answer");
button.setAlignmentX(JButton.RIGHT_ALIGNMENT);
button.setActionCommand("Show Answer");
button.addActionListener(this);
contentPane.add(button);
/* Add content pane to frame */
frame.setContentPane(contentPane);
/* Size and then display the frame */
frame.pack();
frame.setVisible(true);
}
/** Handle button click action event
* pre:
* post: clicked button shows answer
*/
public void actionPerformed(ActionEvent event) {
String eventName = event.getActionCommand();
if (eventName.equals("Show Answer")) {
label1.setText("To become architect ");
label1.setFont(new Font("Serif",Font.PLAIN,30));
button.setText("Answer");
button.setActionCommand("Answer");
}
}
/**
* Create and show the GUI
*/
private static void runGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);
Riddle greeting = new Riddle();
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
runGUI();
}
});
}
}
output:
what is your longterm goal? architectanswer

More Related Content

Similar to program for JRiddle.javapackage riddle;import javax.swing.; i.pdf

Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3martha leon
 
correct the error import javaxswingJFrame import javaxs.pdf
correct the error import javaxswingJFrame import javaxs.pdfcorrect the error import javaxswingJFrame import javaxs.pdf
correct the error import javaxswingJFrame import javaxs.pdfdevangmittal4
 
Othello.javapackage othello;import core.Game; import userInter.pdf
Othello.javapackage othello;import core.Game; import userInter.pdfOthello.javapackage othello;import core.Game; import userInter.pdf
Othello.javapackage othello;import core.Game; import userInter.pdfarccreation001
 
How do I make my JTable non editableimport java.awt.; import j.pdf
How do I make my JTable non editableimport java.awt.; import j.pdfHow do I make my JTable non editableimport java.awt.; import j.pdf
How do I make my JTable non editableimport java.awt.; import j.pdfforwardcom41
 
Chapter iv(modern gui)
Chapter iv(modern gui)Chapter iv(modern gui)
Chapter iv(modern gui)Chhom Karath
 
codigomenu-1 (1).docx
codigomenu-1 (1).docxcodigomenu-1 (1).docx
codigomenu-1 (1).docxAnaLpez275
 
codigomenu-1.docx
codigomenu-1.docxcodigomenu-1.docx
codigomenu-1.docxAnaLpez275
 
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docxAliHaiderCheema2
 
Nouveau document texte-_-_
Nouveau document texte-_-_Nouveau document texte-_-_
Nouveau document texte-_-_Mohamed Mlika
 
correct the error and add code same in the pic import jav.pdf
correct the error and add code same in the pic   import jav.pdfcorrect the error and add code same in the pic   import jav.pdf
correct the error and add code same in the pic import jav.pdfdevangmittal4
 
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdfpackage net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdfsudhirchourasia86
 
Write a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdfWrite a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdffathimaoptical
 
In Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdfIn Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdfflashfashioncasualwe
 
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai University
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai UniversityT.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai University
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai UniversityNiraj Bharambe
 
Model-Driven Software Development - Context-Sensitive Transformation
Model-Driven Software Development - Context-Sensitive TransformationModel-Driven Software Development - Context-Sensitive Transformation
Model-Driven Software Development - Context-Sensitive TransformationEelco Visser
 
Tugas Praktikum Java 2
Tugas Praktikum Java 2Tugas Praktikum Java 2
Tugas Praktikum Java 2azmi007
 

Similar to program for JRiddle.javapackage riddle;import javax.swing.; i.pdf (20)

Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3
 
correct the error import javaxswingJFrame import javaxs.pdf
correct the error import javaxswingJFrame import javaxs.pdfcorrect the error import javaxswingJFrame import javaxs.pdf
correct the error import javaxswingJFrame import javaxs.pdf
 
Othello.javapackage othello;import core.Game; import userInter.pdf
Othello.javapackage othello;import core.Game; import userInter.pdfOthello.javapackage othello;import core.Game; import userInter.pdf
Othello.javapackage othello;import core.Game; import userInter.pdf
 
How do I make my JTable non editableimport java.awt.; import j.pdf
How do I make my JTable non editableimport java.awt.; import j.pdfHow do I make my JTable non editableimport java.awt.; import j.pdf
How do I make my JTable non editableimport java.awt.; import j.pdf
 
Chapter iv(modern gui)
Chapter iv(modern gui)Chapter iv(modern gui)
Chapter iv(modern gui)
 
java swing
java swingjava swing
java swing
 
codigomenu-1 (1).docx
codigomenu-1 (1).docxcodigomenu-1 (1).docx
codigomenu-1 (1).docx
 
codigomenu-1.docx
codigomenu-1.docxcodigomenu-1.docx
codigomenu-1.docx
 
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
 
Nouveau document texte-_-_
Nouveau document texte-_-_Nouveau document texte-_-_
Nouveau document texte-_-_
 
Swing_Introduction.ppt
Swing_Introduction.pptSwing_Introduction.ppt
Swing_Introduction.ppt
 
correct the error and add code same in the pic import jav.pdf
correct the error and add code same in the pic   import jav.pdfcorrect the error and add code same in the pic   import jav.pdf
correct the error and add code same in the pic import jav.pdf
 
Swing basics
Swing basicsSwing basics
Swing basics
 
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdfpackage net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
 
Write a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdfWrite a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdf
 
In Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdfIn Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdf
 
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai University
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai UniversityT.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai University
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai University
 
Swing
SwingSwing
Swing
 
Model-Driven Software Development - Context-Sensitive Transformation
Model-Driven Software Development - Context-Sensitive TransformationModel-Driven Software Development - Context-Sensitive Transformation
Model-Driven Software Development - Context-Sensitive Transformation
 
Tugas Praktikum Java 2
Tugas Praktikum Java 2Tugas Praktikum Java 2
Tugas Praktikum Java 2
 

More from annapurnnatextailes

Xs mothers fourth child was X. the question its.pdf
                     Xs mothers fourth child was X. the question its.pdf                     Xs mothers fourth child was X. the question its.pdf
Xs mothers fourth child was X. the question its.pdfannapurnnatextailes
 
Types of Fluoride Additives Community water syst.pdf
                     Types of Fluoride Additives  Community water syst.pdf                     Types of Fluoride Additives  Community water syst.pdf
Types of Fluoride Additives Community water syst.pdfannapurnnatextailes
 
This is blue because ion absorbs yellow radiation.pdf
                     This is blue because ion absorbs yellow radiation.pdf                     This is blue because ion absorbs yellow radiation.pdf
This is blue because ion absorbs yellow radiation.pdfannapurnnatextailes
 
The theory, or doctrine, of forms (also called th.pdf
                     The theory, or doctrine, of forms (also called th.pdf                     The theory, or doctrine, of forms (also called th.pdf
The theory, or doctrine, of forms (also called th.pdfannapurnnatextailes
 
The left ring would undergo nitration more easily.pdf
                     The left ring would undergo nitration more easily.pdf                     The left ring would undergo nitration more easily.pdf
The left ring would undergo nitration more easily.pdfannapurnnatextailes
 
sol a. Im guessing that they are used to react .pdf
                     sol a. Im guessing that they are used to react .pdf                     sol a. Im guessing that they are used to react .pdf
sol a. Im guessing that they are used to react .pdfannapurnnatextailes
 
Resonance structures demonstrate one of the weakn.pdf
                     Resonance structures demonstrate one of the weakn.pdf                     Resonance structures demonstrate one of the weakn.pdf
Resonance structures demonstrate one of the weakn.pdfannapurnnatextailes
 
no. of moles = massmolecular weight here no mass.pdf
                     no. of moles = massmolecular weight here no mass.pdf                     no. of moles = massmolecular weight here no mass.pdf
no. of moles = massmolecular weight here no mass.pdfannapurnnatextailes
 
Moles of EDTA added initially to the solution = (.pdf
                     Moles of EDTA added initially to the solution = (.pdf                     Moles of EDTA added initially to the solution = (.pdf
Moles of EDTA added initially to the solution = (.pdfannapurnnatextailes
 
IV Water has a high boiling compared to H2S. .pdf
                     IV Water has a high boiling compared to H2S.    .pdf                     IV Water has a high boiling compared to H2S.    .pdf
IV Water has a high boiling compared to H2S. .pdfannapurnnatextailes
 
it is NO2 addition in meta position giving 1,3 di.pdf
                     it is NO2 addition in meta position giving 1,3 di.pdf                     it is NO2 addition in meta position giving 1,3 di.pdf
it is NO2 addition in meta position giving 1,3 di.pdfannapurnnatextailes
 
in saturn weight is 1.064 times that of the earth.pdf
                     in saturn weight is 1.064 times that of the earth.pdf                     in saturn weight is 1.064 times that of the earth.pdf
in saturn weight is 1.064 times that of the earth.pdfannapurnnatextailes
 
If I am reading the question right, this would be.pdf
                     If I am reading the question right, this would be.pdf                     If I am reading the question right, this would be.pdf
If I am reading the question right, this would be.pdfannapurnnatextailes
 
Which of the following are true statements about serial interfaces.pdf
Which of the following are true statements about serial interfaces.pdfWhich of the following are true statements about serial interfaces.pdf
Which of the following are true statements about serial interfaces.pdfannapurnnatextailes
 
Thermostability                          is the quality of a subst.pdf
Thermostability                          is the quality of a subst.pdfThermostability                          is the quality of a subst.pdf
Thermostability                          is the quality of a subst.pdfannapurnnatextailes
 
VictimizedSolutionVictimized.pdf
VictimizedSolutionVictimized.pdfVictimizedSolutionVictimized.pdf
VictimizedSolutionVictimized.pdfannapurnnatextailes
 
True,Design activities for high risk system interfaces might come up.pdf
True,Design activities for high risk system interfaces might come up.pdfTrue,Design activities for high risk system interfaces might come up.pdf
True,Design activities for high risk system interfaces might come up.pdfannapurnnatextailes
 
WAN is a wide area network in which two or more computer or other de.pdf
WAN is a wide area network in which two or more computer or other de.pdfWAN is a wide area network in which two or more computer or other de.pdf
WAN is a wide area network in which two or more computer or other de.pdfannapurnnatextailes
 
The most important characteristics that comprise the software qualit.pdf
The most important characteristics that comprise the software qualit.pdfThe most important characteristics that comprise the software qualit.pdf
The most important characteristics that comprise the software qualit.pdfannapurnnatextailes
 
The electronic configuration of H is 1s1 It has one valence electr.pdf
The electronic configuration of H is 1s1 It has one valence electr.pdfThe electronic configuration of H is 1s1 It has one valence electr.pdf
The electronic configuration of H is 1s1 It has one valence electr.pdfannapurnnatextailes
 

More from annapurnnatextailes (20)

Xs mothers fourth child was X. the question its.pdf
                     Xs mothers fourth child was X. the question its.pdf                     Xs mothers fourth child was X. the question its.pdf
Xs mothers fourth child was X. the question its.pdf
 
Types of Fluoride Additives Community water syst.pdf
                     Types of Fluoride Additives  Community water syst.pdf                     Types of Fluoride Additives  Community water syst.pdf
Types of Fluoride Additives Community water syst.pdf
 
This is blue because ion absorbs yellow radiation.pdf
                     This is blue because ion absorbs yellow radiation.pdf                     This is blue because ion absorbs yellow radiation.pdf
This is blue because ion absorbs yellow radiation.pdf
 
The theory, or doctrine, of forms (also called th.pdf
                     The theory, or doctrine, of forms (also called th.pdf                     The theory, or doctrine, of forms (also called th.pdf
The theory, or doctrine, of forms (also called th.pdf
 
The left ring would undergo nitration more easily.pdf
                     The left ring would undergo nitration more easily.pdf                     The left ring would undergo nitration more easily.pdf
The left ring would undergo nitration more easily.pdf
 
sol a. Im guessing that they are used to react .pdf
                     sol a. Im guessing that they are used to react .pdf                     sol a. Im guessing that they are used to react .pdf
sol a. Im guessing that they are used to react .pdf
 
Resonance structures demonstrate one of the weakn.pdf
                     Resonance structures demonstrate one of the weakn.pdf                     Resonance structures demonstrate one of the weakn.pdf
Resonance structures demonstrate one of the weakn.pdf
 
no. of moles = massmolecular weight here no mass.pdf
                     no. of moles = massmolecular weight here no mass.pdf                     no. of moles = massmolecular weight here no mass.pdf
no. of moles = massmolecular weight here no mass.pdf
 
Moles of EDTA added initially to the solution = (.pdf
                     Moles of EDTA added initially to the solution = (.pdf                     Moles of EDTA added initially to the solution = (.pdf
Moles of EDTA added initially to the solution = (.pdf
 
IV Water has a high boiling compared to H2S. .pdf
                     IV Water has a high boiling compared to H2S.    .pdf                     IV Water has a high boiling compared to H2S.    .pdf
IV Water has a high boiling compared to H2S. .pdf
 
it is NO2 addition in meta position giving 1,3 di.pdf
                     it is NO2 addition in meta position giving 1,3 di.pdf                     it is NO2 addition in meta position giving 1,3 di.pdf
it is NO2 addition in meta position giving 1,3 di.pdf
 
in saturn weight is 1.064 times that of the earth.pdf
                     in saturn weight is 1.064 times that of the earth.pdf                     in saturn weight is 1.064 times that of the earth.pdf
in saturn weight is 1.064 times that of the earth.pdf
 
If I am reading the question right, this would be.pdf
                     If I am reading the question right, this would be.pdf                     If I am reading the question right, this would be.pdf
If I am reading the question right, this would be.pdf
 
Which of the following are true statements about serial interfaces.pdf
Which of the following are true statements about serial interfaces.pdfWhich of the following are true statements about serial interfaces.pdf
Which of the following are true statements about serial interfaces.pdf
 
Thermostability                          is the quality of a subst.pdf
Thermostability                          is the quality of a subst.pdfThermostability                          is the quality of a subst.pdf
Thermostability                          is the quality of a subst.pdf
 
VictimizedSolutionVictimized.pdf
VictimizedSolutionVictimized.pdfVictimizedSolutionVictimized.pdf
VictimizedSolutionVictimized.pdf
 
True,Design activities for high risk system interfaces might come up.pdf
True,Design activities for high risk system interfaces might come up.pdfTrue,Design activities for high risk system interfaces might come up.pdf
True,Design activities for high risk system interfaces might come up.pdf
 
WAN is a wide area network in which two or more computer or other de.pdf
WAN is a wide area network in which two or more computer or other de.pdfWAN is a wide area network in which two or more computer or other de.pdf
WAN is a wide area network in which two or more computer or other de.pdf
 
The most important characteristics that comprise the software qualit.pdf
The most important characteristics that comprise the software qualit.pdfThe most important characteristics that comprise the software qualit.pdf
The most important characteristics that comprise the software qualit.pdf
 
The electronic configuration of H is 1s1 It has one valence electr.pdf
The electronic configuration of H is 1s1 It has one valence electr.pdfThe electronic configuration of H is 1s1 It has one valence electr.pdf
The electronic configuration of H is 1s1 It has one valence electr.pdf
 

Recently uploaded

An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 

Recently uploaded (20)

An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 

program for JRiddle.javapackage riddle;import javax.swing.; i.pdf

  • 1. program for JRiddle.java package riddle; import javax.swing.*; import java.awt.event.*; import java.awt.*; public class Riddle implements ActionListener { private final String LABEL_TEXT = "What is your longterm goal?"; JFrame frame; JPanel contentPane; JLabel label, label1; JButton button; JButton button1; private static int i; public Riddle() { /* Create and set up the frame */ frame = new JFrame(LABEL_TEXT); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); /* Create a content pane with a GridLayout and empty borders */ contentPane = new JPanel(); contentPane.setLayout(new GridLayout(0, 2, 10, 5)); /* Create and add label that is centered and has empty borders */ label = new JLabel("Why did the chicken cross the road?"); label.setAlignmentX(JButton.LEFT_ALIGNMENT); label.setBorder(BorderFactory.createEmptyBorder(20, 50, 20, 50)); contentPane.add(label); label1 = new JLabel(" "); label1.setAlignmentX(JButton.LEFT_ALIGNMENT); label1.setBorder(BorderFactory.createEmptyBorder(20, 50, 20, 50)); contentPane.add(label1); /* Create and add button that is centered */ button = new JButton("Answer"); button.setAlignmentX(JButton.RIGHT_ALIGNMENT); button.setActionCommand("Show Answer"); button.addActionListener(this);
  • 2. contentPane.add(button); /* Add content pane to frame */ frame.setContentPane(contentPane); /* Size and then display the frame */ frame.pack(); frame.setVisible(true); } /** Handle button click action event * pre: * post: clicked button shows answer */ public void actionPerformed(ActionEvent event) { String eventName = event.getActionCommand(); if (eventName.equals("Show Answer")) { label1.setText("To become architect "); label1.setFont(new Font("Serif",Font.PLAIN,30)); button.setText("Answer"); button.setActionCommand("Answer"); } } /** * Create and show the GUI */ private static void runGUI() { JFrame.setDefaultLookAndFeelDecorated(true); Riddle greeting = new Riddle(); } public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { runGUI(); } }); } } output:
  • 3. what is your longterm goal? architectanswer Solution program for JRiddle.java package riddle; import javax.swing.*; import java.awt.event.*; import java.awt.*; public class Riddle implements ActionListener { private final String LABEL_TEXT = "What is your longterm goal?"; JFrame frame; JPanel contentPane; JLabel label, label1; JButton button; JButton button1; private static int i; public Riddle() { /* Create and set up the frame */ frame = new JFrame(LABEL_TEXT); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); /* Create a content pane with a GridLayout and empty borders */ contentPane = new JPanel(); contentPane.setLayout(new GridLayout(0, 2, 10, 5)); /* Create and add label that is centered and has empty borders */ label = new JLabel("Why did the chicken cross the road?"); label.setAlignmentX(JButton.LEFT_ALIGNMENT); label.setBorder(BorderFactory.createEmptyBorder(20, 50, 20, 50)); contentPane.add(label); label1 = new JLabel(" "); label1.setAlignmentX(JButton.LEFT_ALIGNMENT); label1.setBorder(BorderFactory.createEmptyBorder(20, 50, 20, 50)); contentPane.add(label1); /* Create and add button that is centered */ button = new JButton("Answer");
  • 4. button.setAlignmentX(JButton.RIGHT_ALIGNMENT); button.setActionCommand("Show Answer"); button.addActionListener(this); contentPane.add(button); /* Add content pane to frame */ frame.setContentPane(contentPane); /* Size and then display the frame */ frame.pack(); frame.setVisible(true); } /** Handle button click action event * pre: * post: clicked button shows answer */ public void actionPerformed(ActionEvent event) { String eventName = event.getActionCommand(); if (eventName.equals("Show Answer")) { label1.setText("To become architect "); label1.setFont(new Font("Serif",Font.PLAIN,30)); button.setText("Answer"); button.setActionCommand("Answer"); } } /** * Create and show the GUI */ private static void runGUI() { JFrame.setDefaultLookAndFeelDecorated(true); Riddle greeting = new Riddle(); } public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { runGUI(); } });
  • 5. } } output: what is your longterm goal? architectanswer