0

As of right now I am trying to print some text on a screen when a variable is a certain value.

My code is reporting a "Cannot make a static reference…" error for the line if(ElementButton.showElement[0] == 2):

void buildDiatomicMolecules(){

   if(ElementButton.showElement[0] == 2){

   textSize(18);

   text("H", g.eXLocation/2, g.eYLocation/2 - g.eYLocation/8); 
   }

In this case ElementButton is a class. Do I need to make the ElementButton class static?

Yu Hao
  • 119,891
  • 44
  • 235
  • 294
  • possible duplicate of [Cannot Make Static Reference to Non-Static Method](http://stackoverflow.com/questions/4969171/cannot-make-static-reference-to-non-static-method) (or more precisely, since its a field: http://stackoverflow.com/questions/10200740/java-making-a-static-reference-to-the-non-static-field-list?rq=1) – Thilo Nov 24 '14 at 02:59
  • `showElement` should be a static member of `ElementButton`. – songyuanyao Nov 24 '14 at 03:02
  • Do you understand the concept of static methods and classes in Java? – v.k. Nov 24 '14 at 12:19
  • @Joshua Siktar can you also please list how you initialize ElementButton ? – George Profenza Nov 27 '14 at 12:26
  • ElementButton(float tempX, float tempY, float tempW, float tempH, Element tempElement) { super(tempX, tempY, tempW, tempH); //below line retraces steps to find the element symbol currently being stored in element buttonText = tempElement.getSymbol(); element = tempElement; } – Joshua Siktar Jan 08 '15 at 19:29

0 Answers0