1

This maybe a basic question, but I am new to programming.

I have two GUI forms running at one time, UploadGui and UploadPurchaseData. I need the UploadPurchaseData form to call a value from a text field in UploadGui called txtFirstName. UploadGui and UploadPurchaseData are separate jFrame files, but they are in the same project.

Here is the code I have so far for the UploadPurchaseData button to upload the inserted values into the database

private void cmdAddPurchaseActionPerformed(java.awt.event.ActionEvent evt) {                                                      
    String ps = comboPurchaseStage.getSelectedItem().toString();
    int pv = Integer.parseInt(txtPropertyValue.getText());
    int la = Integer.parseInt(txtLoanAmount.getText());
    //here is where is need the code to reference txtFirstName from UploadGUI
}

Here is the code that opens UploadPurchaseData at the same time as UploadGUI is open:

private void comboLTActionPerformed(java.awt.event.ActionEvent evt) {                                        
    String lt = comboLT.getSelectedItem().toString();
    if (lt == "Purchase")
    {
    UploadPurchaseData anotherFrame = new  UploadPurchaseData();
    anotherFrame.pack();
    anotherFrame.setVisible(true);
    }
Mike Laren
  • 8,028
  • 17
  • 51
  • 70
Ali Prasla
  • 11
  • 2
  • 4
    Pass a reference of UploadGui (or the 'text field' `txtFirstName`) to the `UploadPurchaseData` object. – copeg Jun 01 '15 at 17:50
  • How do I pass that reference? As in that would be the code for that? – Ali Prasla Jun 01 '15 at 17:55
  • There are many ways: in the constructor, via a setter method...without any context (eg `code`) we can only provide textual suggestions (rather than code suggestions ) – copeg Jun 01 '15 at 17:57
  • 1
    See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/q/9554636/418556) – Andrew Thompson Jun 01 '15 at 18:40

0 Answers0