java - Controlling JComponents from other classes -


is possible control instances variables, jcomponents, timer in other external classes?

for example class1

public class class1 extends jframe {     jlabel lbl = new jlabel("hello");     public class1() {         super("class1");         container c = getcontentpane();         setlayout(null);         c.add(lbl);         lbl.setbounds(0,0,100,20);         class2.process();         setsize(200,100);         setlocationrelativeto(null);         setvisible(true);     }     public static void main(string var[]) {         new class1();     } } 

you can see there's class2.process(); here's other class externally in same folder

public class class2 {     public static void process() {         // want control lbl class1 class inside method         // lbl.setvisible(false);     }     public static void main(string args[]) {         //     } } 

is possible? sorry. can't find answers on other website.

you have pass instance of jlabel e.g.;

jlabel lbl = new jlabel("hello");); class2.process(lbl);   public class class2 {     public static void process(jlabel lbl) {         // want control lbl class1 class inside method         lbl.setvisible(false); // change class1 jlabel     } 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -