Hi,
Im having a problem here. I have 3 classes/frames. After arriving at the 3rd frame, i want to get values entered in the 1st first frame. All the variables in the 1st class are declared as Private. In order for me to get this value from other class, i added a public method getName() in the 1st class. Im still unable to get the value... below is the code:
public class kwMCQ extends JFrame implements ActionListener
{
public static void main(String [] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame mcq = new kwMCQ();
}
private static final int WIDTH=400;
private static final int HEIGHT=250;
private JPanel pnlLogo, pnlIntro, pnlInput, pnlButton, pnlInstruct;
private JLabel lblLogo,lblWelcome, lblFillIn, lblName, lblRollno, lblInstruction;
private JTextField txtName;
private JFormattedTextField txtRollno;
private JButton btnStart, btnBeginMcq;
private JLabel instructLabel1, instructLabel2, instructLabel3, instructLabel4, instructLabel5;
private JButton startB;
private McqTest secondFrame = new McqTest();
public kwMCQ()
{
ImageIcon logo = new ImageIcon("itbLogo.png");
....some other statements.. then
//accessor
public String getTxtName()
{
return txtName.getText();
}
public String getTxtRollNo()
{
return txtRollno.getText();
}
...class that calls the 1st class (the action of getting value is implemented in the listener..
String stuRollNo,stuName;
// im not sure if this is the right way
// but i get nulll value...
// may be i shouldnt create the object
// but i duno how to access it with
kwMCQ login = new kwMCQ();
stuRollNo = login.getTxtRollNo()+"\n";
stuName = login.getTxtName() + "\n";
help me....