• Post Reply Bookmark Topic Watch Topic
  • New Topic

frame vs. JFrame

 
Abder Rahman Ali
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a difference between using frame or JFrame as in the following? As, when I ran the program it operated the same.





Thanks.
 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... in the behavior of your program there shouldn't be a difference as you stated already.
But it would be interesting to see, if byte code differs?
I guess it doesn't, because sun's compiler should recognize that this is a final static field, i.e. a constant.

But anyway, even this doesn't probably relate to your question,
most IDE's would issue a warning if you use latter code
and sun also highly recommends to use the first statement instead.
 
Campbell Ritchie
Marshal
Posts: 52580
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to JavaRanch
 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
deleted (misread the question)
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since his "frame" is not capitalized, I'm guessing that the OP is not mixing Frame (AWT) with Swing but rather that he has a JFrame variable named "frame" and is asking if calling a static method or referencing a static variable from an object of the class will change his code.

To the OP: as noted above, it likely won't but it will sure confuse folks reading your code since most of us expect static members to be referenced by the class name not by a variable of the class that holds an object of the class. Since much of coding is not writing for a compiler but rather writing for readability, I agree with others who tell you "don't do this".
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!