java - Getting values from another frame -


so i'm having these classes

public class init {     ...     jframe addstream = new addstream();     addstream.setvisible(true);     addstream.setlocationrelativeto(null);     addstream.getdata(); //not working  }  public class addstream extends javax.swing.jframe {      private string namedata, urldata, qualitydata;      /** creates new form addstream */     public addstream() {         initcomponents();     }     private void initcomponents() {     ...     }      private void addactionperformed(java.awt.event.actionevent evt) {         namedata = name.gettext();         urldata = url.gettext();         qualitydata = quality.getselecteditem().tostring();     }      public string[] getdata() {         return new string[]{namedata, urldata, qualitydata};     } } 

note classes arent complete, snippets.

when user clicks on add button(addactionperformed) values saved local variables in addstream class , returned getdata().

the problem i'm having addstream.getdata();, "cannot find symbol"

is there way data addstream jframe init class?

your problem can fixed changing line:

jframe addstream = new addstream(); 

to this:

addstream addstream = new addstream(); 

what's happening in code you're trying call method on jframe doesn't exist on jframe, exists in addstream. though jframe is-a addstream in case, compiler forbids unless tell compiler is-a addstream. , code i've shown you.

another way cast in call. imagine using code above, on last line:

((addstream) addstream).getdata(); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -