Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Did i use awt components?

 
Bernd Wollny
Ranch Hand
Posts: 59
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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
 
Roel De Nijs
Sheriff
Posts: 10593
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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,...)
 
Jonathan Elkharrat
Ranch Hand
Posts: 170
Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic