I have 2 JFrame classes:
The ViewPatientLogin JFrame, which is basically just a frame where the user inputs a Patient's name, and is then taken to the second JFrame where the Patient's details are displayed.
The ViewPatient JFrame, which displays all of the relevant Patient info.
What I want to do is to have the text input into the JTextField txtfFullName in the ViewPatientLogin JFrame be set as the text in the ViewPatient frame's corresponding JTextField.
I have set the buttons and jtextfields of both JFrames to static and public.
However, when I enter the button ActionPerformed code, upon creating a new instance of the ViewPatient object, I cannot access any of the attributes in the ViewPatient JFrame.
Anyone, please help? This is a really important project for my final year portfolio, and I'm really stuck.
EDIT: Here is the button ActionPerformed code that's giving me a headache:
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
ViewPatient x = new ViewPatient();
//cannot access the textfield of x from here
//x.txtfFullName does not even register
}
public class ViewPatient extends JFrame
{
public ViewPatient(String n)
{
txtfFullName=n;
}
}
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
ViewPatient x = new ViewPatient(patientName);
x.setVisible(true);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.