(Please help me why the program is not rumming it shows error at location 97 / i
ID: 667252 • Letter: #
Question
(Please help me why the program is not rumming it shows error at location 97 / im useing java the code is ....)
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
public class Lab2 extends JFrame
{
private static final int FRAME_WIDTH = 500;
private static final int FRAME_HEIGHT = 200;
private JLabel IblHeader;
private JTextField tfAdd;
private JTextField tfSub;
private JButton btnAdd;
private JButton btnInputAddress;
private JPanel pnl2x2;
private int addClicks = 0;
private int subClicks = 0;
private int fontsize;
private String facename;
private int fontstyle;
public Lab2()
{
IblHeader = new JLabel("LAB 2");
add(IblHeader,BorderLayout.NORTH);
facename="Georgia";
fontsize = 32;
fontstyle = Font.PLAIN;
setLabelFont(IblHeader);
btnAdd = new JButton ("SAVE NAME");
tfAdd = new JTextField ("");
ActionListener my_addListener = new AddButtonListener();
btnAdd.addActionListener (my_addListener);
btnInputAddress = new JButton ("INPUT ADDRESS");
tfSub = new JTextField ("");
ActionListener my_InputListener = new InputAddressButtonListener ();
btnInputAddress.addActionListener (my_InputListener);
pnl2x2 = new JPanel();
pnl2x2.setLayout(new GridLayout(2,2));
pnl2x2.add(btnAdd);
pnl2x2.add(tfAdd);
pnl2x2.add(btnInputAddress);
pnl2x2.add(tfSub);
add(pnl2x2, BorderLayout.CENTER);
setSize(FRAME_WIDTH,FRAME_HEIGHT);
setVisible(true);
}
public void setLabelFont (JLabel mylabel)
{
Font f = new Font(facename,fontstyle,fontsize);
mylabel.setFont(f);
}
class AddButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
try{
String name = tfAdd.getText();
PrintWriter out = new PrintWriter("RahimahAbdulKarim.txt");
out.print(name);
out.close();
tfAdd.setText("");
//save name to a file
}
catch(FileNotFoundException exception)
{
System.out.println("Information not saved");
}
}
}
class InputAddressButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
//Create frame and show input for address
AddressClass myAC = new AddressClass();
myAC.setVisible(true);
dispose();
}
}
}
Explanation / Answer
AddressClass myAC = new AddressClass();
The Implementation of class AddressClass is missing here
Please add the address class as well to work with it.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.