• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Did i use awt components?

 
Ranch Hand
Posts: 59
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

i was searching through my code by looking for "java.awt.Component". And, what the hell, i found one reference. I found it when i was overriding JTable and
it's method "prepareRenderer(TableCellRenderer, int, int)" which returns java.awt.Component, so i did use it right? I mean i was unsing a swing component which uses
awt components.

But, what now? Will i fail? Can i retake the assignment, just deleting this part of code?

Thanks and greetz
Bernd
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you not use any layout managers? These are also awt components. As long as you use awt components which does not have a swing alternative you are fine, so don't use TextField, but use JTextField.
So you would not fail for overriding a method which returns Component. The Component class is even the parent class of a lot of swing classes (e.g. JTextField, JButton,...)
 
Ranch Hand
Posts: 170
Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
first of all, even JComponent is-a awt.component.

this method return indeed a component reference, but as the javadoc
say it may be a Jcomponent (remember you can reference a subclass
with a variable of type superclass)

besides, all swing component use awt component internally, the important
thing is that the high level components are Jcomponent.
what's going on inside shouldn't matter.
so to sum up, i don't think you'll fail on that..
 
Bernd Wollny
Ranch Hand
Posts: 59
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, puuuuhh....i am using layout manager, but as the FAQ states here, it is ok because they do not extend java.awt.Component. But i am using the java.awt.Component directly in my class, so i was wondering if it is prohibited...

Roel: thanks for changing my headline, was the first shock...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic