Unable to update JTextField using RMI











up vote
0
down vote

favorite












hoping someone can help with this as it's frying my brain now. I am new to RMI so this could be a basic amateurish mistake .



So I have a layered system where a userinterface creates an interface for an application layer and calls a getRecord function using RMI. This in turn creates an interface to a datalayer which retrieves the information from a database returning it to the appLayer which returns it to the userinterface. This works fine and the JTextFields are updated perfectly.



The problem is when i then try to send this information back through the applayer to another interface. When it gets to the new interface i can output the information to the console but it WILL NOT update the JTextFields on this interface and i cannot for the life of me understand why not.



My Main Interface:



IPatientRecord testRecord;
IAppLayer appLayer;

public class MainOffice extends JFrame {

private JPanel MainPanel;
private JPanel Background;
private JPanel TopPanel;
private JPanel LeftPanel;
private JPanel RightPanel;
private JTextField searchTextBox;
private JButton searchButton;
private JTextField NHSRegistrationNoTextField;
private JTextField patientNameTextField;
private JTextField addressTextField;
private JTextField postCodeTextField;
private JTextField conditionTextField;
private JButton confirmAndSendButton;

public MainOffice() {
add(MainPanel);
setSize(400, 400);

try {
Registry patientRegistry = LocateRegistry.getRegistry(1096);
Registry registry = LocateRegistry.getRegistry(1099);

testRecord = (IPatientRecord) patientRegistry.lookup("patientRecord");
appLayer = (IAppLayer) registry.lookup("appLayer");

System.out.println("Patient Record Interface Ready");

}
catch (Exception ex) {
System.out.println("Exception Creating Patient Record Interface: " + ex.getMessage());
}


searchButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {

testRecord = appLayer.getPatientRecord(Integer.parseInt(searchTextBox.getText()));
System.out.println("Test Record " + testRecord.getName());

updateForm();

System.out.println("Patient returned to Main Office " + testRecord.getName());

}
catch (Exception ex) {
System.out.println("Exception in Search Button: " + ex.getMessage());

}
}
});

confirmAndSendButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {

System.out.println("Patient: " + testRecord.getName());

System.out.println("Confirm and send pressed/nDetails sent: " + testRecord.getName());
appLayer.sendToAmbulance(testRecord);


}
catch (Exception ex) {
System.out.println("confirm and Send Exception: " + ex.getMessage());
}



}
});
}

public void updateForm() {

try{

NHSRegistrationNoTextField.setText(String.valueOf(testRecord.getNhsRegistrationNo()));
patientNameTextField.setText(testRecord.getName());
addressTextField.setText(testRecord.getAddress());
postCodeTextField.setText(testRecord.getPostCode());
conditionTextField.setText(testRecord.getCondition());
}
catch (RemoteException rex) {
System.out.println("Update form exception: " + rex.getMessage());
}
}


public static void main (String args ) {
MainOffice mainOffice = new MainOffice();
mainOffice.setVisible(true);
}


My App LAyer:



public class AppLayer implements IAppLayer {

List ambulances;
List hospitals;

Dictionary ambulanceDictionary;

IPatientRecord patientRecord;

public AppLayer() throws RemoteException{
ambulances = new ArrayList();
hospitals = new ArrayList();

ambulanceDictionary = new Hashtable();

}

@Override
public IPatientRecord getPatientRecord(int nhsNo) throws RemoteException {
try {
Registry registry = LocateRegistry.getRegistry(null,1098);

IDataLayer dataLayer = (IDataLayer) registry.lookup("dataLayer");

patientRecord = dataLayer.getPatientRecord(nhsNo);

System.out.println("Patient returned: " + patientRecord.getName());

//sendToAmbulance(patientRecord);

return patientRecord;

}
catch (Exception ex) {
System.out.println("Error in AppLayer: " + ex.getMessage() + " /n/nSee getPatientRecord in AppLayer");
return null;
}
}


The Function i Used to send to the other UI: The UI registers with the applayer first using another function. This uses that information to send the record to the right client essentially. The Main office UI calls this on through the applayer interface



public void sendToAmbulance(IPatientRecord patientRecord) {

Enumeration keys = ambulanceDictionary.keys();
Enumeration elements = ambulanceDictionary.elements();

int port = Integer.parseInt(keys.nextElement().toString());
String callSign = ambulanceDictionary.get(port).toString();

try {

System.out.println("Searching on port: " + port);
Registry registry2 = LocateRegistry.getRegistry(port);

System.out.println("Looking up callSign: " + callSign);
System.out.println("made it here");
IAmbulance ambulance = (IAmbulance) registry2.lookup(callSign);

System.out.println("and here");
ambulance.Update(patientRecord);

System.out.println("maybe here");

if (ambulance.Update(patientRecord)){
ambulanceDictionary.remove(port);
System.out.println(callSign + "removed from list");
System.out.println("");
}
else{
System.out.println("Failed to update ambulance " + callSign);
}

}
catch (Exception ex) {

System.out.println("Exception in sendToAmbulance: " + ex.getMessage());
}
}


The above function the calls Update on the Ambulance



public Boolean Update(IPatientRecord patientRecord) {

try {
NHSRegistrationNoTextField.setText(String.valueOf(patientRecord.getNhsRegistrationNo()));
patientNameTextField.setText(patientRecord.getName());
addressTextField.setText(patientRecord.getAddress());
postCodeTextField.setText(patientRecord.getPostCode());
conditionTextField.setText(patientRecord.getCondition());

ReadyStatusTxt.setText("ON CALL");

return true;
}
catch (Exception ex) {
System.out.println("Exception in Update: " + ex.getMessage());
return false;
}
}


It doesn't even update the ReadyStatusTxt.setText("On Call") yet returns true!



I've tried so many things. Originally i wasnt using the Patient record interface between the layers, I was being lazy but I've updated it so each different layer has to go through the Patient Interface and it still works the same way as before.



I added a seperate function to ambulance that would then call the database again pull the details for itself and then update it with this and it still will not update.



Is It as simple as I cant drive the update from an external class



Oh and another thing is if i put System.out.Println(patientRecord.getName()); in the above function it prints out the ******* name that i want to update the above aforementioned JtextField. I've tried saving that into Strings first and then adding it to the JtextField but that doesn't work either










share|improve this question
























  • I guess your update method is not being called in Swing EDT. Call update using SwingUtilities.invokeLater.
    – Dakshinamurthy Karra
    Nov 22 at 15:06










  • Not sure i did i right but i Made AmbulanceClass implement Runnable and changed the Update function to public Runnable Update() and it's simply trying to update one Jtextlabel ReadyStatusTxt.setText("ON CALL"); when this runs through SwingUtilities.invokeLater i get Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException"
    – sfa20
    Nov 22 at 15:51










  • For better help sooner, edit to add a Minimal, Complete, and Verifiable example or Short, Self Contained, Correct Example.
    – Andrew Thompson
    Nov 22 at 22:47















up vote
0
down vote

favorite












hoping someone can help with this as it's frying my brain now. I am new to RMI so this could be a basic amateurish mistake .



So I have a layered system where a userinterface creates an interface for an application layer and calls a getRecord function using RMI. This in turn creates an interface to a datalayer which retrieves the information from a database returning it to the appLayer which returns it to the userinterface. This works fine and the JTextFields are updated perfectly.



The problem is when i then try to send this information back through the applayer to another interface. When it gets to the new interface i can output the information to the console but it WILL NOT update the JTextFields on this interface and i cannot for the life of me understand why not.



My Main Interface:



IPatientRecord testRecord;
IAppLayer appLayer;

public class MainOffice extends JFrame {

private JPanel MainPanel;
private JPanel Background;
private JPanel TopPanel;
private JPanel LeftPanel;
private JPanel RightPanel;
private JTextField searchTextBox;
private JButton searchButton;
private JTextField NHSRegistrationNoTextField;
private JTextField patientNameTextField;
private JTextField addressTextField;
private JTextField postCodeTextField;
private JTextField conditionTextField;
private JButton confirmAndSendButton;

public MainOffice() {
add(MainPanel);
setSize(400, 400);

try {
Registry patientRegistry = LocateRegistry.getRegistry(1096);
Registry registry = LocateRegistry.getRegistry(1099);

testRecord = (IPatientRecord) patientRegistry.lookup("patientRecord");
appLayer = (IAppLayer) registry.lookup("appLayer");

System.out.println("Patient Record Interface Ready");

}
catch (Exception ex) {
System.out.println("Exception Creating Patient Record Interface: " + ex.getMessage());
}


searchButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {

testRecord = appLayer.getPatientRecord(Integer.parseInt(searchTextBox.getText()));
System.out.println("Test Record " + testRecord.getName());

updateForm();

System.out.println("Patient returned to Main Office " + testRecord.getName());

}
catch (Exception ex) {
System.out.println("Exception in Search Button: " + ex.getMessage());

}
}
});

confirmAndSendButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {

System.out.println("Patient: " + testRecord.getName());

System.out.println("Confirm and send pressed/nDetails sent: " + testRecord.getName());
appLayer.sendToAmbulance(testRecord);


}
catch (Exception ex) {
System.out.println("confirm and Send Exception: " + ex.getMessage());
}



}
});
}

public void updateForm() {

try{

NHSRegistrationNoTextField.setText(String.valueOf(testRecord.getNhsRegistrationNo()));
patientNameTextField.setText(testRecord.getName());
addressTextField.setText(testRecord.getAddress());
postCodeTextField.setText(testRecord.getPostCode());
conditionTextField.setText(testRecord.getCondition());
}
catch (RemoteException rex) {
System.out.println("Update form exception: " + rex.getMessage());
}
}


public static void main (String args ) {
MainOffice mainOffice = new MainOffice();
mainOffice.setVisible(true);
}


My App LAyer:



public class AppLayer implements IAppLayer {

List ambulances;
List hospitals;

Dictionary ambulanceDictionary;

IPatientRecord patientRecord;

public AppLayer() throws RemoteException{
ambulances = new ArrayList();
hospitals = new ArrayList();

ambulanceDictionary = new Hashtable();

}

@Override
public IPatientRecord getPatientRecord(int nhsNo) throws RemoteException {
try {
Registry registry = LocateRegistry.getRegistry(null,1098);

IDataLayer dataLayer = (IDataLayer) registry.lookup("dataLayer");

patientRecord = dataLayer.getPatientRecord(nhsNo);

System.out.println("Patient returned: " + patientRecord.getName());

//sendToAmbulance(patientRecord);

return patientRecord;

}
catch (Exception ex) {
System.out.println("Error in AppLayer: " + ex.getMessage() + " /n/nSee getPatientRecord in AppLayer");
return null;
}
}


The Function i Used to send to the other UI: The UI registers with the applayer first using another function. This uses that information to send the record to the right client essentially. The Main office UI calls this on through the applayer interface



public void sendToAmbulance(IPatientRecord patientRecord) {

Enumeration keys = ambulanceDictionary.keys();
Enumeration elements = ambulanceDictionary.elements();

int port = Integer.parseInt(keys.nextElement().toString());
String callSign = ambulanceDictionary.get(port).toString();

try {

System.out.println("Searching on port: " + port);
Registry registry2 = LocateRegistry.getRegistry(port);

System.out.println("Looking up callSign: " + callSign);
System.out.println("made it here");
IAmbulance ambulance = (IAmbulance) registry2.lookup(callSign);

System.out.println("and here");
ambulance.Update(patientRecord);

System.out.println("maybe here");

if (ambulance.Update(patientRecord)){
ambulanceDictionary.remove(port);
System.out.println(callSign + "removed from list");
System.out.println("");
}
else{
System.out.println("Failed to update ambulance " + callSign);
}

}
catch (Exception ex) {

System.out.println("Exception in sendToAmbulance: " + ex.getMessage());
}
}


The above function the calls Update on the Ambulance



public Boolean Update(IPatientRecord patientRecord) {

try {
NHSRegistrationNoTextField.setText(String.valueOf(patientRecord.getNhsRegistrationNo()));
patientNameTextField.setText(patientRecord.getName());
addressTextField.setText(patientRecord.getAddress());
postCodeTextField.setText(patientRecord.getPostCode());
conditionTextField.setText(patientRecord.getCondition());

ReadyStatusTxt.setText("ON CALL");

return true;
}
catch (Exception ex) {
System.out.println("Exception in Update: " + ex.getMessage());
return false;
}
}


It doesn't even update the ReadyStatusTxt.setText("On Call") yet returns true!



I've tried so many things. Originally i wasnt using the Patient record interface between the layers, I was being lazy but I've updated it so each different layer has to go through the Patient Interface and it still works the same way as before.



I added a seperate function to ambulance that would then call the database again pull the details for itself and then update it with this and it still will not update.



Is It as simple as I cant drive the update from an external class



Oh and another thing is if i put System.out.Println(patientRecord.getName()); in the above function it prints out the ******* name that i want to update the above aforementioned JtextField. I've tried saving that into Strings first and then adding it to the JtextField but that doesn't work either










share|improve this question
























  • I guess your update method is not being called in Swing EDT. Call update using SwingUtilities.invokeLater.
    – Dakshinamurthy Karra
    Nov 22 at 15:06










  • Not sure i did i right but i Made AmbulanceClass implement Runnable and changed the Update function to public Runnable Update() and it's simply trying to update one Jtextlabel ReadyStatusTxt.setText("ON CALL"); when this runs through SwingUtilities.invokeLater i get Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException"
    – sfa20
    Nov 22 at 15:51










  • For better help sooner, edit to add a Minimal, Complete, and Verifiable example or Short, Self Contained, Correct Example.
    – Andrew Thompson
    Nov 22 at 22:47













up vote
0
down vote

favorite









up vote
0
down vote

favorite











hoping someone can help with this as it's frying my brain now. I am new to RMI so this could be a basic amateurish mistake .



So I have a layered system where a userinterface creates an interface for an application layer and calls a getRecord function using RMI. This in turn creates an interface to a datalayer which retrieves the information from a database returning it to the appLayer which returns it to the userinterface. This works fine and the JTextFields are updated perfectly.



The problem is when i then try to send this information back through the applayer to another interface. When it gets to the new interface i can output the information to the console but it WILL NOT update the JTextFields on this interface and i cannot for the life of me understand why not.



My Main Interface:



IPatientRecord testRecord;
IAppLayer appLayer;

public class MainOffice extends JFrame {

private JPanel MainPanel;
private JPanel Background;
private JPanel TopPanel;
private JPanel LeftPanel;
private JPanel RightPanel;
private JTextField searchTextBox;
private JButton searchButton;
private JTextField NHSRegistrationNoTextField;
private JTextField patientNameTextField;
private JTextField addressTextField;
private JTextField postCodeTextField;
private JTextField conditionTextField;
private JButton confirmAndSendButton;

public MainOffice() {
add(MainPanel);
setSize(400, 400);

try {
Registry patientRegistry = LocateRegistry.getRegistry(1096);
Registry registry = LocateRegistry.getRegistry(1099);

testRecord = (IPatientRecord) patientRegistry.lookup("patientRecord");
appLayer = (IAppLayer) registry.lookup("appLayer");

System.out.println("Patient Record Interface Ready");

}
catch (Exception ex) {
System.out.println("Exception Creating Patient Record Interface: " + ex.getMessage());
}


searchButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {

testRecord = appLayer.getPatientRecord(Integer.parseInt(searchTextBox.getText()));
System.out.println("Test Record " + testRecord.getName());

updateForm();

System.out.println("Patient returned to Main Office " + testRecord.getName());

}
catch (Exception ex) {
System.out.println("Exception in Search Button: " + ex.getMessage());

}
}
});

confirmAndSendButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {

System.out.println("Patient: " + testRecord.getName());

System.out.println("Confirm and send pressed/nDetails sent: " + testRecord.getName());
appLayer.sendToAmbulance(testRecord);


}
catch (Exception ex) {
System.out.println("confirm and Send Exception: " + ex.getMessage());
}



}
});
}

public void updateForm() {

try{

NHSRegistrationNoTextField.setText(String.valueOf(testRecord.getNhsRegistrationNo()));
patientNameTextField.setText(testRecord.getName());
addressTextField.setText(testRecord.getAddress());
postCodeTextField.setText(testRecord.getPostCode());
conditionTextField.setText(testRecord.getCondition());
}
catch (RemoteException rex) {
System.out.println("Update form exception: " + rex.getMessage());
}
}


public static void main (String args ) {
MainOffice mainOffice = new MainOffice();
mainOffice.setVisible(true);
}


My App LAyer:



public class AppLayer implements IAppLayer {

List ambulances;
List hospitals;

Dictionary ambulanceDictionary;

IPatientRecord patientRecord;

public AppLayer() throws RemoteException{
ambulances = new ArrayList();
hospitals = new ArrayList();

ambulanceDictionary = new Hashtable();

}

@Override
public IPatientRecord getPatientRecord(int nhsNo) throws RemoteException {
try {
Registry registry = LocateRegistry.getRegistry(null,1098);

IDataLayer dataLayer = (IDataLayer) registry.lookup("dataLayer");

patientRecord = dataLayer.getPatientRecord(nhsNo);

System.out.println("Patient returned: " + patientRecord.getName());

//sendToAmbulance(patientRecord);

return patientRecord;

}
catch (Exception ex) {
System.out.println("Error in AppLayer: " + ex.getMessage() + " /n/nSee getPatientRecord in AppLayer");
return null;
}
}


The Function i Used to send to the other UI: The UI registers with the applayer first using another function. This uses that information to send the record to the right client essentially. The Main office UI calls this on through the applayer interface



public void sendToAmbulance(IPatientRecord patientRecord) {

Enumeration keys = ambulanceDictionary.keys();
Enumeration elements = ambulanceDictionary.elements();

int port = Integer.parseInt(keys.nextElement().toString());
String callSign = ambulanceDictionary.get(port).toString();

try {

System.out.println("Searching on port: " + port);
Registry registry2 = LocateRegistry.getRegistry(port);

System.out.println("Looking up callSign: " + callSign);
System.out.println("made it here");
IAmbulance ambulance = (IAmbulance) registry2.lookup(callSign);

System.out.println("and here");
ambulance.Update(patientRecord);

System.out.println("maybe here");

if (ambulance.Update(patientRecord)){
ambulanceDictionary.remove(port);
System.out.println(callSign + "removed from list");
System.out.println("");
}
else{
System.out.println("Failed to update ambulance " + callSign);
}

}
catch (Exception ex) {

System.out.println("Exception in sendToAmbulance: " + ex.getMessage());
}
}


The above function the calls Update on the Ambulance



public Boolean Update(IPatientRecord patientRecord) {

try {
NHSRegistrationNoTextField.setText(String.valueOf(patientRecord.getNhsRegistrationNo()));
patientNameTextField.setText(patientRecord.getName());
addressTextField.setText(patientRecord.getAddress());
postCodeTextField.setText(patientRecord.getPostCode());
conditionTextField.setText(patientRecord.getCondition());

ReadyStatusTxt.setText("ON CALL");

return true;
}
catch (Exception ex) {
System.out.println("Exception in Update: " + ex.getMessage());
return false;
}
}


It doesn't even update the ReadyStatusTxt.setText("On Call") yet returns true!



I've tried so many things. Originally i wasnt using the Patient record interface between the layers, I was being lazy but I've updated it so each different layer has to go through the Patient Interface and it still works the same way as before.



I added a seperate function to ambulance that would then call the database again pull the details for itself and then update it with this and it still will not update.



Is It as simple as I cant drive the update from an external class



Oh and another thing is if i put System.out.Println(patientRecord.getName()); in the above function it prints out the ******* name that i want to update the above aforementioned JtextField. I've tried saving that into Strings first and then adding it to the JtextField but that doesn't work either










share|improve this question















hoping someone can help with this as it's frying my brain now. I am new to RMI so this could be a basic amateurish mistake .



So I have a layered system where a userinterface creates an interface for an application layer and calls a getRecord function using RMI. This in turn creates an interface to a datalayer which retrieves the information from a database returning it to the appLayer which returns it to the userinterface. This works fine and the JTextFields are updated perfectly.



The problem is when i then try to send this information back through the applayer to another interface. When it gets to the new interface i can output the information to the console but it WILL NOT update the JTextFields on this interface and i cannot for the life of me understand why not.



My Main Interface:



IPatientRecord testRecord;
IAppLayer appLayer;

public class MainOffice extends JFrame {

private JPanel MainPanel;
private JPanel Background;
private JPanel TopPanel;
private JPanel LeftPanel;
private JPanel RightPanel;
private JTextField searchTextBox;
private JButton searchButton;
private JTextField NHSRegistrationNoTextField;
private JTextField patientNameTextField;
private JTextField addressTextField;
private JTextField postCodeTextField;
private JTextField conditionTextField;
private JButton confirmAndSendButton;

public MainOffice() {
add(MainPanel);
setSize(400, 400);

try {
Registry patientRegistry = LocateRegistry.getRegistry(1096);
Registry registry = LocateRegistry.getRegistry(1099);

testRecord = (IPatientRecord) patientRegistry.lookup("patientRecord");
appLayer = (IAppLayer) registry.lookup("appLayer");

System.out.println("Patient Record Interface Ready");

}
catch (Exception ex) {
System.out.println("Exception Creating Patient Record Interface: " + ex.getMessage());
}


searchButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {

testRecord = appLayer.getPatientRecord(Integer.parseInt(searchTextBox.getText()));
System.out.println("Test Record " + testRecord.getName());

updateForm();

System.out.println("Patient returned to Main Office " + testRecord.getName());

}
catch (Exception ex) {
System.out.println("Exception in Search Button: " + ex.getMessage());

}
}
});

confirmAndSendButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {

System.out.println("Patient: " + testRecord.getName());

System.out.println("Confirm and send pressed/nDetails sent: " + testRecord.getName());
appLayer.sendToAmbulance(testRecord);


}
catch (Exception ex) {
System.out.println("confirm and Send Exception: " + ex.getMessage());
}



}
});
}

public void updateForm() {

try{

NHSRegistrationNoTextField.setText(String.valueOf(testRecord.getNhsRegistrationNo()));
patientNameTextField.setText(testRecord.getName());
addressTextField.setText(testRecord.getAddress());
postCodeTextField.setText(testRecord.getPostCode());
conditionTextField.setText(testRecord.getCondition());
}
catch (RemoteException rex) {
System.out.println("Update form exception: " + rex.getMessage());
}
}


public static void main (String args ) {
MainOffice mainOffice = new MainOffice();
mainOffice.setVisible(true);
}


My App LAyer:



public class AppLayer implements IAppLayer {

List ambulances;
List hospitals;

Dictionary ambulanceDictionary;

IPatientRecord patientRecord;

public AppLayer() throws RemoteException{
ambulances = new ArrayList();
hospitals = new ArrayList();

ambulanceDictionary = new Hashtable();

}

@Override
public IPatientRecord getPatientRecord(int nhsNo) throws RemoteException {
try {
Registry registry = LocateRegistry.getRegistry(null,1098);

IDataLayer dataLayer = (IDataLayer) registry.lookup("dataLayer");

patientRecord = dataLayer.getPatientRecord(nhsNo);

System.out.println("Patient returned: " + patientRecord.getName());

//sendToAmbulance(patientRecord);

return patientRecord;

}
catch (Exception ex) {
System.out.println("Error in AppLayer: " + ex.getMessage() + " /n/nSee getPatientRecord in AppLayer");
return null;
}
}


The Function i Used to send to the other UI: The UI registers with the applayer first using another function. This uses that information to send the record to the right client essentially. The Main office UI calls this on through the applayer interface



public void sendToAmbulance(IPatientRecord patientRecord) {

Enumeration keys = ambulanceDictionary.keys();
Enumeration elements = ambulanceDictionary.elements();

int port = Integer.parseInt(keys.nextElement().toString());
String callSign = ambulanceDictionary.get(port).toString();

try {

System.out.println("Searching on port: " + port);
Registry registry2 = LocateRegistry.getRegistry(port);

System.out.println("Looking up callSign: " + callSign);
System.out.println("made it here");
IAmbulance ambulance = (IAmbulance) registry2.lookup(callSign);

System.out.println("and here");
ambulance.Update(patientRecord);

System.out.println("maybe here");

if (ambulance.Update(patientRecord)){
ambulanceDictionary.remove(port);
System.out.println(callSign + "removed from list");
System.out.println("");
}
else{
System.out.println("Failed to update ambulance " + callSign);
}

}
catch (Exception ex) {

System.out.println("Exception in sendToAmbulance: " + ex.getMessage());
}
}


The above function the calls Update on the Ambulance



public Boolean Update(IPatientRecord patientRecord) {

try {
NHSRegistrationNoTextField.setText(String.valueOf(patientRecord.getNhsRegistrationNo()));
patientNameTextField.setText(patientRecord.getName());
addressTextField.setText(patientRecord.getAddress());
postCodeTextField.setText(patientRecord.getPostCode());
conditionTextField.setText(patientRecord.getCondition());

ReadyStatusTxt.setText("ON CALL");

return true;
}
catch (Exception ex) {
System.out.println("Exception in Update: " + ex.getMessage());
return false;
}
}


It doesn't even update the ReadyStatusTxt.setText("On Call") yet returns true!



I've tried so many things. Originally i wasnt using the Patient record interface between the layers, I was being lazy but I've updated it so each different layer has to go through the Patient Interface and it still works the same way as before.



I added a seperate function to ambulance that would then call the database again pull the details for itself and then update it with this and it still will not update.



Is It as simple as I cant drive the update from an external class



Oh and another thing is if i put System.out.Println(patientRecord.getName()); in the above function it prints out the ******* name that i want to update the above aforementioned JtextField. I've tried saving that into Strings first and then adding it to the JtextField but that doesn't work either







java swing intellij-idea jtextfield rmi






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 at 22:47









Andrew Thompson

152k27162336




152k27162336










asked Nov 22 at 14:37









sfa20

287




287












  • I guess your update method is not being called in Swing EDT. Call update using SwingUtilities.invokeLater.
    – Dakshinamurthy Karra
    Nov 22 at 15:06










  • Not sure i did i right but i Made AmbulanceClass implement Runnable and changed the Update function to public Runnable Update() and it's simply trying to update one Jtextlabel ReadyStatusTxt.setText("ON CALL"); when this runs through SwingUtilities.invokeLater i get Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException"
    – sfa20
    Nov 22 at 15:51










  • For better help sooner, edit to add a Minimal, Complete, and Verifiable example or Short, Self Contained, Correct Example.
    – Andrew Thompson
    Nov 22 at 22:47


















  • I guess your update method is not being called in Swing EDT. Call update using SwingUtilities.invokeLater.
    – Dakshinamurthy Karra
    Nov 22 at 15:06










  • Not sure i did i right but i Made AmbulanceClass implement Runnable and changed the Update function to public Runnable Update() and it's simply trying to update one Jtextlabel ReadyStatusTxt.setText("ON CALL"); when this runs through SwingUtilities.invokeLater i get Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException"
    – sfa20
    Nov 22 at 15:51










  • For better help sooner, edit to add a Minimal, Complete, and Verifiable example or Short, Self Contained, Correct Example.
    – Andrew Thompson
    Nov 22 at 22:47
















I guess your update method is not being called in Swing EDT. Call update using SwingUtilities.invokeLater.
– Dakshinamurthy Karra
Nov 22 at 15:06




I guess your update method is not being called in Swing EDT. Call update using SwingUtilities.invokeLater.
– Dakshinamurthy Karra
Nov 22 at 15:06












Not sure i did i right but i Made AmbulanceClass implement Runnable and changed the Update function to public Runnable Update() and it's simply trying to update one Jtextlabel ReadyStatusTxt.setText("ON CALL"); when this runs through SwingUtilities.invokeLater i get Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException"
– sfa20
Nov 22 at 15:51




Not sure i did i right but i Made AmbulanceClass implement Runnable and changed the Update function to public Runnable Update() and it's simply trying to update one Jtextlabel ReadyStatusTxt.setText("ON CALL"); when this runs through SwingUtilities.invokeLater i get Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException"
– sfa20
Nov 22 at 15:51












For better help sooner, edit to add a Minimal, Complete, and Verifiable example or Short, Self Contained, Correct Example.
– Andrew Thompson
Nov 22 at 22:47




For better help sooner, edit to add a Minimal, Complete, and Verifiable example or Short, Self Contained, Correct Example.
– Andrew Thompson
Nov 22 at 22:47

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53433254%2funable-to-update-jtextfield-using-rmi%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53433254%2funable-to-update-jtextfield-using-rmi%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)