rendered paste bodyimport javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Frame{
String hisCon=("... \nTest information\n");
JFrame f;
JTextArea ta;
JScrollPane sbrText;
JButton homeBut;
JButton addBut;
JButton stage1But;
JButton stage2But;
JButton stage3But;
JButton stage4But;
JButton stage5But;
JPanel buttons;
public static void main (String[] args) {
Frame gui = new Frame ();
gui.Frame2();
}
public void Frame2(){
f = new JFrame ("Test Frame");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
ta = new JTextArea(hisCon, 12, 10);
ta.setLineWrap(true);
sbrText = new JScrollPane(ta);
sbrText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
panel.add(sbrText);
buttons = new JPanel();
buttons.setLayout(new GridLayout(7,1));
JLabel historyTitle = new JLabel (" History");
homeBut = new JButton ("Home Page");
homeBut.addActionListener(new HomeListener());
buttons.add(homeBut);
addBut = new JButton ("Add Image");
addBut.addActionListener(new AddListener());
buttons.add(addBut);
stage1But = new JButton ("Stage 1");
stage1But.addActionListener(new Stage1Listener());
buttons.add(stage1But);
stage2But = new JButton ("Stage 2");
stage2But.addActionListener(new Stage2Listener());
buttons.add(stage2But);
stage3But = new JButton ("Stage 3");
stage3But.addActionListener(new Stage3Listener());
buttons.add(stage3But);
stage4But = new JButton ("Stage 4");
stage4But.addActionListener(new Stage4Listener());
buttons.add(stage4But);
stage5But = new JButton ("Stage 5");
stage5But.addActionListener(new Stage5Listener());
buttons.add(stage5But);
f.getContentPane().add(BorderLayout.NORTH, historyTitle);
f.getContentPane().add(BorderLayout.CENTER, panel);
f.getContentPane().add(BorderLayout.WEST, buttons);
f.setSize (300, 300);
f.setVisible (true);
}
class HomeListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
Buttonsound.playButton(); //play the sound for button clicks
hisCon=(hisCon + "Home Clicked \n");
f.repaint();
}
}
class AddListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
Buttonsound.playButton(); //play the sound for button clicks
}
}
class Stage1Listener implements ActionListener {
public void actionPerformed(ActionEvent event) {
Buttonsound.playButton(); //play the sound for button clicks
}
}
class Stage2Listener implements ActionListener {
public void actionPerformed(ActionEvent event) {
Buttonsound.playButton(); //play the sound for button clicks
}
}
class Stage3Listener implements ActionListener {
public void actionPerformed(ActionEvent event) {
Buttonsound.playButton(); //play the sound for button clicks
}
}
class Stage4Listener implements ActionListener {
public void actionPerformed(ActionEvent event) {
Buttonsound.playButton(); //play the sound for button clicks
}
}
class Stage5Listener implements ActionListener {
public void actionPerformed(ActionEvent event) {
Buttonsound.playButton(); //play the sound for button clicks
}
}
}