Click here to Skip to main content
15,884,083 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
here i want to access form objects in another class files?
so i followed a method like this?
but it wont work?

Java
VisaInfo VInfo = new VisaInfo();
VInfo.visaMenu2.setVisible(true);


current status of that menu visibility is false.
so i want to set visibility of that menu from another class.

please let me know the way of access form variables in another class?
Posted

1 solution

Not only a form variable, you can access a variable of class A to class B by making it simply public static . Did you try that?
Java
Class A
{ 
   public static int a=0;
}

Class B
{
   public void yourMethod(){
   A.a = 10;
   }
}
 
Share this answer
 
Comments
Hemas Ilearn 15-Dec-15 0:39am    
but there are two separate files?
ridoy 15-Dec-15 1:51am    
You mean 2 separate class?
Hemas Ilearn 15-Dec-15 2:26am    
Yes of course.........
ridoy 16-Dec-15 1:49am    
Make visaMenu2 public static in your VisaInfo class, and then access it from 2nd class.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900