Hello.
I'm familiar with using a Swing Container, but what about a Swing component?
I'd like to have a component which is a Swing class, such as a JInternalFrame.
The container looks up the component and adds it do the larger Swing desktop
frame. Problem is, the component is a proxy class so I get
ClassCastExceptions. Is there any other way to do this?
Code examples:
interface MyComponent {
...
}
class MySwingComponent extends JInternalFrame implements MyComponent {
...
}
inside Container :
JDesktopPane desktop = new JDesktopPane();
MyComponent c = (MyComponent) m_serviceManager.lookup(MyComponent.ROLE);
MySwingComponent swingC = (SwingComponent) c; <-- this throws an error
desktop.add(swingC);
I'd rather not have to cast the component anyway, but even if I have
MyComponent be an abstract class which extends JInternalFrame, I still get a
ClassCastException, but this time at the lookup.(MyComponent.ROLE) line. From
this I gather that one cannot lookup Abstract classes, but only interfaces
(yes?).
Since it's the container which is using this component, I could manual
initialize it, but if there is a more elegant way, I'd rather use that. I
suppose I could just have the component be a wrapper and return a
JInternalFrame from some method but I'd rather extend for simplicity (or is
this a bad idea?). Has anyone found a better way to use Swing components?
jaaron
jaaron
__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]