-4

I have a class which is having static methods, So i am calling the static methods without creating object reference for it. like below:

public Class DateChooser extends VLayout implements com.smartgwt.client.widgets.events.HasDataChangedHandlers {

 public static native void changeAutoChildDefaults(String autoChildName, Canvas defaults) /*-{
        $wnd.isc.DateChooser.changeDefaults(autoChildName + "Defaults", defaults.@com.smartgwt.client.widgets.Canvas::getConfig()());
    }-*/;

}


public class Myclass{
 DateItem dateField;// Smart Gwt class
 dateField = new DateItem("counterDateItem","");
DateChooser dateChooser = new DateChooser();  // Smart Gwt class
dateChooser.changeAutoChildDefaults("hideBtn", canvas); // calling static method

dateField.setDateChooser(dateChooser);
}

how can i eliminate creating the object for calling static methods in above case.

majji
  • 169
  • 2
  • 3
  • 19
  • Java basics: http://docs.oracle.com/javase/tutorial/java/javaOO/classvars.html – sp00m Oct 30 '14 at 09:10
  • I don't know the people are here down vote for the questions. Please let me know the reason before downvote – majji Oct 30 '14 at 09:13
  • Is that the exact MyClass that you are using? Because you can not call methods (`dateChooser.changeAutoChildDefaults`, `dateField.setDateChooser`) the way you did in class body (http://stackoverflow.com/questions/6151218/method-calls-inside-a-java-class) – Sithsu Oct 30 '14 at 11:57
  • No its not like that, I have some other code along with it. DateItem and DateChooser is Smart gwt classes. – majji Oct 30 '14 at 12:09
  • Hello all, Please carefully look into query first, its not like normal java basic, The classes are smart gwt classes. Please don't downvote without observing carefully. – majji Nov 05 '14 at 06:26

1 Answers1

3

Call it directly. With static methods, you don't need to create a reference anymore.

DateChooser.changeAutoChildDefaults();
lxcky
  • 1,668
  • 2
  • 13
  • 26
  • Thank you @J.Lucky, I know the above solution but i want that object to set it in my object. Please look at code once again – majji Oct 30 '14 at 09:12
  • @majji, then maybe your `changeAutoChildDefaults()` shouldn't be a `static` method? – lxcky Oct 30 '14 at 09:14
  • it is a static method which is Smart Gwt method not my own method – majji Oct 30 '14 at 09:16