This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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
But, what now? Will i fail? Can i retake the assignment, just deleting this part of code?
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,...)
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..
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...