SlideShare a Scribd company logo
Throughout the semester, we have been working on command line applications. While the
command line can be a powerful form of interacting with the computer, most modern
applications have a graphical user interface, or GUI. This program will give you some initial
experience making GUI applications with Swing.
1. Write an original GUI application in Java using Swing. The program can be a simple game, or
an application that demonstrates some of the capabilities of Swing, for example.
2. The application must do something non-trivial that is controlled by GUI components such as
buttons, text boxes, drop-down boxes, etc. For example, it might draw different things, or change
colors, based on button presses.
3. The GUI elements should be layed out reasonably using layout managers.
4. At least one element in your GUI program besides the title bar must include your name.
Suggestions
Get the skeleton of your GUI working first. First get the buttons drawing properly, then go on to
listen to and respond to events.
Initially, hook up the event listeners so that they print something to the console when a button is
pressed. That way you can know that your code is getting events.
If your program will draw shapes, make a subclass of JPanel called "DrawPanel" or something
like that to draw the objects and your name. Override the "paintComponent" method of this
class.
Solution
import javax.swing.*; import java.awt.*; class gui{ public static void main(String args[]){
//Creating the Frame JFrame frame = new JFrame("Chat Frame");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400,400);
//Creating the MenuBar and adding components JMenuBar mb = new JMenuBar(); JMenu m1 =
new JMenu("FILE"); JMenu m2 = new JMenu("Help"); mb.add(m1); mb.add(m2);
JMenuItem m11 = new JMenuItem("Open"); JMenuItem m22 =new JMenuItem("Save as");
m1.add(m11); m1.add(m22); //Creating the panel at bottom and adding components JPanel panel
= new JPanel(); // the panel is not visible in output JLabel label = new JLabel("Enter Text");
JTextField tf = new JTextField(10);// accepts upto 10 characters JButton send = new
JButton("Send"); JButton reset = new JButton("Reset"); panel.add(label);// Components
Added using Flow Layout panel.add(tf); panel.add(send); panel.add(reset); // Text Area at the
Center JTextArea ta = new JTextArea(); //Adding Components to the frame.
frame.getContentPane().add(BorderLayout.SOUTH,panel);
frame.getContentPane().add(BorderLayout.NORTH,mb);
frame.getContentPane().add(BorderLayout.CENTER,ta); frame.setVisible(true); } }

More Related Content

Similar to Throughout the semester, we have been working on command line applic.pdf

01. introduction to swing
01. introduction to swing01. introduction to swing
01. introduction to swingPrashant Mehta
 
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
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
gebrsh
 
L11cs2110sp13
L11cs2110sp13L11cs2110sp13
L11cs2110sp13
karan saini
 
GUI_part_1.pptx
GUI_part_1.pptxGUI_part_1.pptx
GUI_part_1.pptx
Parasuraman43
 
Advance Java Programming (CM5I) 2.Swing
Advance Java Programming (CM5I) 2.SwingAdvance Java Programming (CM5I) 2.Swing
Advance Java Programming (CM5I) 2.Swing
Payal Dungarwal
 
Introducing small basic
Introducing small basicIntroducing small basic
Introducing small basicAn I
 
Software engineering modeling lab lectures
Software engineering modeling lab lecturesSoftware engineering modeling lab lectures
Software engineering modeling lab lectures
marwaeng
 
Introducing Small Basic.pdf
Introducing Small Basic.pdfIntroducing Small Basic.pdf
Introducing Small Basic.pdf
Snehlata Parashar
 
Slot04 creating gui
Slot04 creating guiSlot04 creating gui
Slot04 creating gui
Viên Mai
 
Introducing small basic
Introducing small basicIntroducing small basic
Introducing small basic
Sara Samol
 
Programming 2: Java Midterm Week Twelve.
Programming 2: Java Midterm Week Twelve.Programming 2: Java Midterm Week Twelve.
Programming 2: Java Midterm Week Twelve.
HyunJeiThaddeus
 
Hack2the future Microsoft .NET Gadgeteer
Hack2the future Microsoft .NET GadgeteerHack2the future Microsoft .NET Gadgeteer
Hack2the future Microsoft .NET Gadgeteer
Lee Stott
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Java
suraj pandey
 
java presentation on Swings chapter java presentation on Swings
java presentation on Swings chapter java presentation on Swingsjava presentation on Swings chapter java presentation on Swings
java presentation on Swings chapter java presentation on Swings
MohanYedatkar
 
GUI components in Java
GUI components in JavaGUI components in Java
GUI components in Java
kirupasuchi1996
 
Moreno Xec
Moreno XecMoreno Xec
Moreno Xec
ebermoreno22
 
Oopp Lab Work
Oopp Lab WorkOopp Lab Work
Oopp Lab Work
Heather Dionne
 
10.USING THE ECLIPSE DEBUGGERupdated 8618This t.docx
10.USING THE ECLIPSE DEBUGGERupdated 8618This t.docx10.USING THE ECLIPSE DEBUGGERupdated 8618This t.docx
10.USING THE ECLIPSE DEBUGGERupdated 8618This t.docx
paynetawnya
 

Similar to Throughout the semester, we have been working on command line applic.pdf (20)

01. introduction to swing
01. introduction to swing01. introduction to swing
01. introduction to swing
 
Chap1 1 1
Chap1 1 1Chap1 1 1
Chap1 1 1
 
Chap1 1.1
Chap1 1.1Chap1 1.1
Chap1 1.1
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
L11cs2110sp13
L11cs2110sp13L11cs2110sp13
L11cs2110sp13
 
GUI_part_1.pptx
GUI_part_1.pptxGUI_part_1.pptx
GUI_part_1.pptx
 
Advance Java Programming (CM5I) 2.Swing
Advance Java Programming (CM5I) 2.SwingAdvance Java Programming (CM5I) 2.Swing
Advance Java Programming (CM5I) 2.Swing
 
Introducing small basic
Introducing small basicIntroducing small basic
Introducing small basic
 
Software engineering modeling lab lectures
Software engineering modeling lab lecturesSoftware engineering modeling lab lectures
Software engineering modeling lab lectures
 
Introducing Small Basic.pdf
Introducing Small Basic.pdfIntroducing Small Basic.pdf
Introducing Small Basic.pdf
 
Slot04 creating gui
Slot04 creating guiSlot04 creating gui
Slot04 creating gui
 
Introducing small basic
Introducing small basicIntroducing small basic
Introducing small basic
 
Programming 2: Java Midterm Week Twelve.
Programming 2: Java Midterm Week Twelve.Programming 2: Java Midterm Week Twelve.
Programming 2: Java Midterm Week Twelve.
 
Hack2the future Microsoft .NET Gadgeteer
Hack2the future Microsoft .NET GadgeteerHack2the future Microsoft .NET Gadgeteer
Hack2the future Microsoft .NET Gadgeteer
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Java
 
java presentation on Swings chapter java presentation on Swings
java presentation on Swings chapter java presentation on Swingsjava presentation on Swings chapter java presentation on Swings
java presentation on Swings chapter java presentation on Swings
 
GUI components in Java
GUI components in JavaGUI components in Java
GUI components in Java
 
Moreno Xec
Moreno XecMoreno Xec
Moreno Xec
 
Oopp Lab Work
Oopp Lab WorkOopp Lab Work
Oopp Lab Work
 
10.USING THE ECLIPSE DEBUGGERupdated 8618This t.docx
10.USING THE ECLIPSE DEBUGGERupdated 8618This t.docx10.USING THE ECLIPSE DEBUGGERupdated 8618This t.docx
10.USING THE ECLIPSE DEBUGGERupdated 8618This t.docx
 

More from birajdar2

public static ArrayListInteger doArrayListSearchSmallest(int nu.pdf
public static ArrayListInteger doArrayListSearchSmallest(int nu.pdfpublic static ArrayListInteger doArrayListSearchSmallest(int nu.pdf
public static ArrayListInteger doArrayListSearchSmallest(int nu.pdf
birajdar2
 
Project selection methods and the project portfolio play an importan.pdf
Project selection methods and the project portfolio play an importan.pdfProject selection methods and the project portfolio play an importan.pdf
Project selection methods and the project portfolio play an importan.pdf
birajdar2
 
javaFix in the program belowhandle incomplete data for text fil.pdf
javaFix in the program belowhandle incomplete data for text fil.pdfjavaFix in the program belowhandle incomplete data for text fil.pdf
javaFix in the program belowhandle incomplete data for text fil.pdf
birajdar2
 
James can row 14 km downstream in a river in 2 hours. He takes 7 hou.pdf
James can row 14 km downstream in a river in 2 hours. He takes 7 hou.pdfJames can row 14 km downstream in a river in 2 hours. He takes 7 hou.pdf
James can row 14 km downstream in a river in 2 hours. He takes 7 hou.pdf
birajdar2
 
In the class we extensively discussed a generic singly linked list i.pdf
In the class we extensively discussed a generic singly linked list i.pdfIn the class we extensively discussed a generic singly linked list i.pdf
In the class we extensively discussed a generic singly linked list i.pdf
birajdar2
 
How do hydrophobic and hydrophilic hormones differ in their speeds a.pdf
How do hydrophobic and hydrophilic hormones differ in their speeds a.pdfHow do hydrophobic and hydrophilic hormones differ in their speeds a.pdf
How do hydrophobic and hydrophilic hormones differ in their speeds a.pdf
birajdar2
 
Given below is an issue that you have identified as an issue in a ret.pdf
Given below is an issue that you have identified as an issue in a ret.pdfGiven below is an issue that you have identified as an issue in a ret.pdf
Given below is an issue that you have identified as an issue in a ret.pdf
birajdar2
 
Explain Aquinas 5 proofs of God, being sure to identify the Aris.pdf
Explain Aquinas 5 proofs of God, being sure to identify the Aris.pdfExplain Aquinas 5 proofs of God, being sure to identify the Aris.pdf
Explain Aquinas 5 proofs of God, being sure to identify the Aris.pdf
birajdar2
 
Exercise 7. Show that if C(0) (the punctured plane) and U C are conf.pdf
Exercise 7. Show that if C(0) (the punctured plane) and U C are conf.pdfExercise 7. Show that if C(0) (the punctured plane) and U C are conf.pdf
Exercise 7. Show that if C(0) (the punctured plane) and U C are conf.pdf
birajdar2
 
Consider the following segment table What are the physical addresse.pdf
Consider the following segment table  What are the physical addresse.pdfConsider the following segment table  What are the physical addresse.pdf
Consider the following segment table What are the physical addresse.pdf
birajdar2
 
Can you explain the movement of ions and ion channel activity during.pdf
Can you explain the movement of ions and ion channel activity during.pdfCan you explain the movement of ions and ion channel activity during.pdf
Can you explain the movement of ions and ion channel activity during.pdf
birajdar2
 
Calculate the implied stock price assuming an EBITDA multiple of 11..pdf
Calculate the implied stock price assuming an EBITDA multiple of 11..pdfCalculate the implied stock price assuming an EBITDA multiple of 11..pdf
Calculate the implied stock price assuming an EBITDA multiple of 11..pdf
birajdar2
 
Below is the graph of a polynomial function f with real coefficients.pdf
Below is the graph of a polynomial function f with real coefficients.pdfBelow is the graph of a polynomial function f with real coefficients.pdf
Below is the graph of a polynomial function f with real coefficients.pdf
birajdar2
 
Are higher than average sea surface temperatures associated with a g.pdf
Are higher than average sea surface temperatures associated with a g.pdfAre higher than average sea surface temperatures associated with a g.pdf
Are higher than average sea surface temperatures associated with a g.pdf
birajdar2
 
A table of values of an increasing function F is shown. Use the table.pdf
A table of values of an increasing function F is shown. Use the table.pdfA table of values of an increasing function F is shown. Use the table.pdf
A table of values of an increasing function F is shown. Use the table.pdf
birajdar2
 
A polygenic trait is determined by a single gene with many different.pdf
A polygenic trait is determined by a single gene with many different.pdfA polygenic trait is determined by a single gene with many different.pdf
A polygenic trait is determined by a single gene with many different.pdf
birajdar2
 
4. Phil is conducting a seed germination experiment. He places 3 gro.pdf
4. Phil is conducting a seed germination experiment. He places 3 gro.pdf4. Phil is conducting a seed germination experiment. He places 3 gro.pdf
4. Phil is conducting a seed germination experiment. He places 3 gro.pdf
birajdar2
 
21. What is the relationship between the maximum size of aggregates a.pdf
21. What is the relationship between the maximum size of aggregates a.pdf21. What is the relationship between the maximum size of aggregates a.pdf
21. What is the relationship between the maximum size of aggregates a.pdf
birajdar2
 
Which of the following are organizer molecules in the avian PMZ is a.pdf
Which of the following are organizer molecules in the avian PMZ is a.pdfWhich of the following are organizer molecules in the avian PMZ is a.pdf
Which of the following are organizer molecules in the avian PMZ is a.pdf
birajdar2
 
What are the five stages of team development Describe each stage an.pdf
What are the five stages of team development Describe each stage an.pdfWhat are the five stages of team development Describe each stage an.pdf
What are the five stages of team development Describe each stage an.pdf
birajdar2
 

More from birajdar2 (20)

public static ArrayListInteger doArrayListSearchSmallest(int nu.pdf
public static ArrayListInteger doArrayListSearchSmallest(int nu.pdfpublic static ArrayListInteger doArrayListSearchSmallest(int nu.pdf
public static ArrayListInteger doArrayListSearchSmallest(int nu.pdf
 
Project selection methods and the project portfolio play an importan.pdf
Project selection methods and the project portfolio play an importan.pdfProject selection methods and the project portfolio play an importan.pdf
Project selection methods and the project portfolio play an importan.pdf
 
javaFix in the program belowhandle incomplete data for text fil.pdf
javaFix in the program belowhandle incomplete data for text fil.pdfjavaFix in the program belowhandle incomplete data for text fil.pdf
javaFix in the program belowhandle incomplete data for text fil.pdf
 
James can row 14 km downstream in a river in 2 hours. He takes 7 hou.pdf
James can row 14 km downstream in a river in 2 hours. He takes 7 hou.pdfJames can row 14 km downstream in a river in 2 hours. He takes 7 hou.pdf
James can row 14 km downstream in a river in 2 hours. He takes 7 hou.pdf
 
In the class we extensively discussed a generic singly linked list i.pdf
In the class we extensively discussed a generic singly linked list i.pdfIn the class we extensively discussed a generic singly linked list i.pdf
In the class we extensively discussed a generic singly linked list i.pdf
 
How do hydrophobic and hydrophilic hormones differ in their speeds a.pdf
How do hydrophobic and hydrophilic hormones differ in their speeds a.pdfHow do hydrophobic and hydrophilic hormones differ in their speeds a.pdf
How do hydrophobic and hydrophilic hormones differ in their speeds a.pdf
 
Given below is an issue that you have identified as an issue in a ret.pdf
Given below is an issue that you have identified as an issue in a ret.pdfGiven below is an issue that you have identified as an issue in a ret.pdf
Given below is an issue that you have identified as an issue in a ret.pdf
 
Explain Aquinas 5 proofs of God, being sure to identify the Aris.pdf
Explain Aquinas 5 proofs of God, being sure to identify the Aris.pdfExplain Aquinas 5 proofs of God, being sure to identify the Aris.pdf
Explain Aquinas 5 proofs of God, being sure to identify the Aris.pdf
 
Exercise 7. Show that if C(0) (the punctured plane) and U C are conf.pdf
Exercise 7. Show that if C(0) (the punctured plane) and U C are conf.pdfExercise 7. Show that if C(0) (the punctured plane) and U C are conf.pdf
Exercise 7. Show that if C(0) (the punctured plane) and U C are conf.pdf
 
Consider the following segment table What are the physical addresse.pdf
Consider the following segment table  What are the physical addresse.pdfConsider the following segment table  What are the physical addresse.pdf
Consider the following segment table What are the physical addresse.pdf
 
Can you explain the movement of ions and ion channel activity during.pdf
Can you explain the movement of ions and ion channel activity during.pdfCan you explain the movement of ions and ion channel activity during.pdf
Can you explain the movement of ions and ion channel activity during.pdf
 
Calculate the implied stock price assuming an EBITDA multiple of 11..pdf
Calculate the implied stock price assuming an EBITDA multiple of 11..pdfCalculate the implied stock price assuming an EBITDA multiple of 11..pdf
Calculate the implied stock price assuming an EBITDA multiple of 11..pdf
 
Below is the graph of a polynomial function f with real coefficients.pdf
Below is the graph of a polynomial function f with real coefficients.pdfBelow is the graph of a polynomial function f with real coefficients.pdf
Below is the graph of a polynomial function f with real coefficients.pdf
 
Are higher than average sea surface temperatures associated with a g.pdf
Are higher than average sea surface temperatures associated with a g.pdfAre higher than average sea surface temperatures associated with a g.pdf
Are higher than average sea surface temperatures associated with a g.pdf
 
A table of values of an increasing function F is shown. Use the table.pdf
A table of values of an increasing function F is shown. Use the table.pdfA table of values of an increasing function F is shown. Use the table.pdf
A table of values of an increasing function F is shown. Use the table.pdf
 
A polygenic trait is determined by a single gene with many different.pdf
A polygenic trait is determined by a single gene with many different.pdfA polygenic trait is determined by a single gene with many different.pdf
A polygenic trait is determined by a single gene with many different.pdf
 
4. Phil is conducting a seed germination experiment. He places 3 gro.pdf
4. Phil is conducting a seed germination experiment. He places 3 gro.pdf4. Phil is conducting a seed germination experiment. He places 3 gro.pdf
4. Phil is conducting a seed germination experiment. He places 3 gro.pdf
 
21. What is the relationship between the maximum size of aggregates a.pdf
21. What is the relationship between the maximum size of aggregates a.pdf21. What is the relationship between the maximum size of aggregates a.pdf
21. What is the relationship between the maximum size of aggregates a.pdf
 
Which of the following are organizer molecules in the avian PMZ is a.pdf
Which of the following are organizer molecules in the avian PMZ is a.pdfWhich of the following are organizer molecules in the avian PMZ is a.pdf
Which of the following are organizer molecules in the avian PMZ is a.pdf
 
What are the five stages of team development Describe each stage an.pdf
What are the five stages of team development Describe each stage an.pdfWhat are the five stages of team development Describe each stage an.pdf
What are the five stages of team development Describe each stage an.pdf
 

Recently uploaded

How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 

Recently uploaded (20)

How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 

Throughout the semester, we have been working on command line applic.pdf

  • 1. Throughout the semester, we have been working on command line applications. While the command line can be a powerful form of interacting with the computer, most modern applications have a graphical user interface, or GUI. This program will give you some initial experience making GUI applications with Swing. 1. Write an original GUI application in Java using Swing. The program can be a simple game, or an application that demonstrates some of the capabilities of Swing, for example. 2. The application must do something non-trivial that is controlled by GUI components such as buttons, text boxes, drop-down boxes, etc. For example, it might draw different things, or change colors, based on button presses. 3. The GUI elements should be layed out reasonably using layout managers. 4. At least one element in your GUI program besides the title bar must include your name. Suggestions Get the skeleton of your GUI working first. First get the buttons drawing properly, then go on to listen to and respond to events. Initially, hook up the event listeners so that they print something to the console when a button is pressed. That way you can know that your code is getting events. If your program will draw shapes, make a subclass of JPanel called "DrawPanel" or something like that to draw the objects and your name. Override the "paintComponent" method of this class. Solution import javax.swing.*; import java.awt.*; class gui{ public static void main(String args[]){ //Creating the Frame JFrame frame = new JFrame("Chat Frame"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400,400); //Creating the MenuBar and adding components JMenuBar mb = new JMenuBar(); JMenu m1 = new JMenu("FILE"); JMenu m2 = new JMenu("Help"); mb.add(m1); mb.add(m2); JMenuItem m11 = new JMenuItem("Open"); JMenuItem m22 =new JMenuItem("Save as"); m1.add(m11); m1.add(m22); //Creating the panel at bottom and adding components JPanel panel = new JPanel(); // the panel is not visible in output JLabel label = new JLabel("Enter Text"); JTextField tf = new JTextField(10);// accepts upto 10 characters JButton send = new JButton("Send"); JButton reset = new JButton("Reset"); panel.add(label);// Components Added using Flow Layout panel.add(tf); panel.add(send); panel.add(reset); // Text Area at the Center JTextArea ta = new JTextArea(); //Adding Components to the frame. frame.getContentPane().add(BorderLayout.SOUTH,panel); frame.getContentPane().add(BorderLayout.NORTH,mb);