I am trying to get the text entered from jtf3 and jtf4 to show in the Message Dialog str1 and str2. Error states that the symbol fot str1 and str2 cannot be found. Please advice.

class ChuaWeiheng extends JFrame
{
    private final JLabel  jl, jl1, jl2, jl3, jlimage;
    private final JTextField jtf, jtf1, jtf2, jtf3, jtf4;
    private final Icon ic;

    jtf3 = new JTextField(30);  
    add(jtf3);

    jtf4 = new JTextField(30);  
    add(jtf4);

    Comments c = new Comments();
    jtf3.addActionListener(c);
    jtf4.addActionListener(c);

}

private class Comments implements ActionListener
{
    @Override
    public void actionPerformed (ActionEvent e)
    {

        String str = "Summary of your changes";
        String str1 = jtf3.getText();
        String str2 = jtf4.getText();

        if(e.getSource() == jtf3)
        str1 = str1.setText(jtf3.getText());

        if(e.getSource() == jtf4)
        str2 = str1.setText(jtf4.getText());

        JOptionPane.showMessageDialog (null, str, str1, str2, "My suggestion to the course", JOptionPane.ERROR_MESSAGE);
    }
}
}

It looks like your problem is lines 26/27 where you try to get the text from the text fields.
The variables jtf3 and jtf4 are private to the ChuaWeiheng class, so they are not accessible in the Comments class.
The simplest fix is to make Comments an inner class of ChuaWeiheng so it has access to its variables. (That would also be better design becaise the Comments calss has no use except from ChuaWeiheng.)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.