• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

frame vs. JFrame

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 76055
362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to JavaRanch
 
Rancher
Posts: 3270
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
deleted (misread the question)
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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".
 
reply
    Bookmark Topic Watch Topic
  • New Topic