Question
write in Java please!
CS2 Programming Challenge GUI Assignment 8: The Parrot About this Programming Challenge GUIS is like GU17 except that (1) the
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;
public class GUI8 implements ActionListener
{
   JButton button1,button2,button3,button4,button5,button6;
   JTextArea area;
GUI8(){
JFrame f= new JFrame();
  
//creating textarea with requried font
area=new JTextArea();
Font font = new Font("Serif", Font.BOLD, 20);
area.setFont(font);
JPanel panel = new JPanel();
  
//creating buttons
button1= new JButton("Term");
button2= new JButton("Quote");
button3= new JButton("Person");
button4= new JButton("Language");
button5= new JButton("Color");
button6= new JButton("Clear");
  
//adding buttons to panel
panel.add(button1);
panel.add(button2);
panel.add(button3);
panel.add(button4);
panel.add(button5);
panel.add(button6);  
  
//adding action listeners to buttons
button1.addActionListener(this);
button2.addActionListener(this);
button3.addActionListener(this);
button4.addActionListener(this);
button5.addActionListener(this);
button6.addActionListener(this);
  
//setting sizes
panel.setBounds(0,30,600,50);
area.setBounds(0,100, 600,600);
f.add(panel);
f.add(area);
  
f.setSize(600,600);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String args[])
{
new GUI8();
}
@Override
public void actionPerformed(ActionEvent event) {
   //this is main logic as per the actioncommand printing the same thing in text area
   if(event.getActionCommand()=="Term"){
       area.setText("Term");
   }
   else if(event.getActionCommand()=="Quote"){
       area.setText("Quote");
   }
   else if(event.getActionCommand()=="Person"){
       area.setText("Person");
   }
   else if(event.getActionCommand()=="Language"){
       area.setText("Language");
   }
   else if(event.getActionCommand()=="Color"){
       area.setText("Color");
   }
   else if(event.getActionCommand()=="Clear"){
       area.setText("Clear");
   }
}}

Term Quote Person Language Color Clear

Term Quote Person Language Color Clear Term

Term Quote PersonLanguage Color Clear Person

Add a comment
Know the answer?
Add Answer to:
write in Java please! CS2 Programming Challenge GUI Assignment 8: The Parrot About this Programming Challenge...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • could you please help me with this problem, also I need a little text so I...

    could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT