Trusted by Students Everywhere
Why Choose Us?
0% AI Guarantee
Human-written only.
24/7 Support
Anytime, anywhere.
Plagiarism Free
100% Original.
Expert Tutors
Masters & PhDs.
100% Confidential
Your privacy matters.
On-Time Delivery
Never miss a deadline.
9 button frame based application Create a Frame-based application that displays an array of nine buttons on a Panel
9 button frame based application
Create a Frame-based application that displays an array of nine buttons on a Panel. Assign the Panel to the Center of your frame. Each button should display the name of a course in your department. Include a TextField in the South. When the user clicks a button, the course name should display in the TextField. There should be a label in the North telling how to use the program.
Also please provide a screenshot of what the program looks like too please.
Expert Solution
import java.awt.*;
import java.awt.event.*;
public class MF extends Frame {
String course[]={"Course1","Course2","Course3","Course4","Course5","Course6","Course7","Course8","Course9"};
TextField txtField = new TextField();
Button[] but=new Button[9];
Label label1 = new Label("Press the button, the corresponding course name will be shown in the text field!");
MF() {
super("9 button frame based application");
addWindowListener(closer);
Panel pan = new Panel();
pan.setLayout(new GridLayout(3,3));
actionListener l1 = new actionListener();
for (int i=0;i<9;i++){
but[i]=new Button(course[i]);
pan.add(but[i],i);
but[i].addActionListener(l1);
}
this.add(label1,BorderLayout.NORTH);
this.add(pan, BorderLayout.CENTER);
this.add(txtField,BorderLayout.SOUTH);
this.setSize(600,300);
setVisible(true);
}
private class actionListener implements ActionListener{
public void actionPerformed(ActionEvent e){
for( int i=0;i<9; i++)
if (e.getSource().equals(but[i]))
txtField.setText(but[i].getLabel()) ;
}
}
private WindowListener closer = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};
public static void main(String[] args) {
new MF();
}
}
Archived Solution
Unlocked Solution
You have full access to this solution. To save a copy with all formatting and attachments, use the button below.
Already a member? Sign In
Important Note:
This solution is from our archive and has been purchased by others. Submitting it as-is may trigger plagiarism detection. Use it for reference only.
For ready-to-submit work, please order a fresh solution below.
For ready-to-submit work, please order a fresh solution below.
Or get 100% fresh solution
Get Custom Quote





