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");
}
}}
write in Java please! CS2 Programming Challenge GUI Assignment 8: The Parrot About this Programming Challenge...
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...