Re: Converting from AWT to Swing - Compile Error
From: A. Bolmarcich (aggedor_at_earl-grey.cloud9.net)
Date: 03/21/04
- Next message: Rhino: "Re: JTable that displays a row in two lines"
- Previous message: Jason Dumler: "Converting from AWT to Swing - Compile Error"
- In reply to: Jason Dumler: "Converting from AWT to Swing - Compile Error"
- Next in thread: Thomas Weidenfeller: "Re: Converting from AWT to Swing - Compile Error"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 21 Mar 2004 04:38:21 -0000
In article <YD77c.12735$TV6.10356@lakeread02>, Jason Dumler wrote:
> Hello All,
>
> I am converting an application from using AWT to swing. I have the
> following function inside a class:
> public void setParent(JComponent comp)
> {
> // What is our parent frame? Thanks to Paul Wheaton for posting the
> // example
> synchronized(comp.getTreeLock())
> {
> while((comp != null) && !(comp instanceof JFrame))
> comp = comp.getParent();
> }
> parentWindow = (JFrame) comp;
> }
>
> In converting, all I did was change Component to JComponent and Frame to
> JFrame, etc. However, this doesn't compile. Does anyone know why?
[snip]
Because an object of type JComonent can never be an instance of JFrame.
JFrame extends Frame which extents Window which extends Container which
extends Component which extends Object.
On the other hand, Frame is a subclass of Component. It is possible
for an object of type Component to be an instace of Frame.
- Next message: Rhino: "Re: JTable that displays a row in two lines"
- Previous message: Jason Dumler: "Converting from AWT to Swing - Compile Error"
- In reply to: Jason Dumler: "Converting from AWT to Swing - Compile Error"
- Next in thread: Thomas Weidenfeller: "Re: Converting from AWT to Swing - Compile Error"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|