java - Unable to change JLabel value -


i'm new netbeans. unable run in eclipse. when try run error non static variable cannot referenced static context. please me solve.

image

inetaddress ip;  try {     ip = inetaddress.getlocalhost();     string t1= ip.gethostname();      sysname.settext(t1);               // here error     //sysname.settext("hi");           // make error } catch (unknownhostexception ex) {      logger.getlogger(mainframe.class.getname()).log(level.severe, null, ex);  } 

from exception you've posted, seems code you've shown in static method, maybe main(), while variable sysname instance variable, possibly declared as

private jlabel sysname; 

you cannot access instance field without instance, ie static context.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -