How can I call a non-static method from another class in Java? -


OK, this is a bit messy:

I am using netbeans, and I have A main parameter called UI is a GUI (this is a GUI) There are some sliders on the GUI of this class, and since it's private, I have a method called getBounds (). I do not want to mess up my GUI, and in order to calculate the stuff, essentially all important methods are called structures, in another class, then the parameter is called a method in UI structure, which calls for some other ways inside of it. , And get one of these calls.

The problem is that getBounds can not be stable, but I can not call it if it is not.

In the parameter UI Category:

  public int [] getBounds () {int [] border = new int [2]; Limits [0] = jSlider2.getMinimum (); Range [1] = jSlider2.getMaximum (); Return limit; } Structure.class in  

:

  Private static zero myMethod (Graphics G, Double [] Planet, Long Mass) {int [] bounds = ParameterUI .getBounds (); // & lt; - does not work}  

MyMethod does not help to make the non-static I am afraid that until I know the basics about static versus non-static, I I am not programming with classes etc.

EDIT: Basically, I know what the problem is, and I'm looking for a better way to solve it.

Pass parameter UI instance with static method

  Private static Zero Merimath (Parameter UI Ultimate, Graphics G, Double [] Planet, Long Mass) {int [] range = param.getBounds (); // & lt; - Although it does not work}  

Although you are calling in the static methods of the other classes for calculating things about the first class, where one might want to reconsider it That all the logic required for your UI category is not included in it, and it is hard to test the code in public reliably.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -