2

This is the current version of the problem I have tried but there was no solution to the problem, please let me know how I can initialize JtextFields in this situation

public class Teacher_Profile extends JFrame {

private JTextField textField_5;
private JTextField textField_6;
private JTextField textField_7;
private JTextField textField_8;

private JTextArea textArea;

private JComboBox comboBox;
private JComboBox comboBox_1;

private LoginDAO a;
private Teacher_Profile g = new Teacher_Profile(this);
private Teacher hi = new Teacher();

    public Teacher_Profile() {
    super();
}

public Teacher_Profile(Teacher_Profile aq) {
    super();
    this.g = aq;
}

public Teacher_Profile(Teacher v) {

    a = new LoginDAO();
    textField_5 = new JTextField();
    textField_6 = new JTextField();
    textField_7 = new JTextField();
textField_8 = new JTextField();

    JButton btnClear = new JButton("Get");
    btnClear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if(e.getActionCommand().equals("Get"))
            {
                Marks_Details ss = a.fetchMarksData(comboBox_1.getSelectedItem().toString(),textField_7.getText());

                //JOptionPane.showMessageDialog(null, "Type: " + ss.getType() + "\nMax_Marks: " + Integer.toString(ss.getMax_Marks()) + "\nWeightage: " + Float.toString(ss.getWeightage()) + "\n Course_Code: " + ss.getCourse_Code());

                g.textField_5.setText(ss.getType().toString());
                g.textField_6.setText(Integer.toString(ss.getMax_Marks()));
                g.textField_7.setText(Float.toString(ss.getWeightage()));
                g.comboBox.setSelectedItem(ss.getCourse_Code());
            }
        }
    });
    btnClear.setBounds(236, 269, 89, 23);
    panel_1.add(btnClear);

This is what I have tried but getting stack overflowerror

    Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
    at private Teacher_Profile g = new Teacher_Profile(this);
Danish Ali
  • 137
  • 7
  • 20

0 Answers0