This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Subclasses and protected methods
- From: Adam Warner <lists at consulting dot net dot nz>
- To: Kawa Mailing List <kawa at sources dot redhat dot com>
- Date: Tue, 04 May 2004 01:39:33 +1200
- Subject: Subclasses and protected methods
Hi all,
I've been getting stuck on a SWT/jface Hello World-ish problem and I
hope you can put me on the right track.
After learning about the abstracted jface interface to IBM's SWT widgets
I am able to easily create a native window:
(define-namespace jface.window.Window "class:org.eclipse.jface.window.Window")
(define-namespace jface.window.ApplicationWindow "class:org.eclipse.jface.window.ApplicationWindow")
(define window (jface.window.ApplicationWindow:new #!null))
(jface.window.Window:setBlockOnOpen window #t)
(jface.window.Window:open window)
(jface.window.Window:close window)
Problems arose when I tried to add a status line to the window:
(jface.window.ApplicationWindow:addStatusLine window)
(jface.window.ApplicationWindow:setStatus window "The status line.")
A java.lang.NoSuchMethodException for
org.eclipse.jface.window.ApplicationWindow.addStatusLine() is thrown
because addStatusLine is a protected method. I may only access it within
a subclass of ApplicationWindow.
A second complication is that addStatusLine should be constructed at the
time of initialising the window ("This method must be called before this
window's shell is created") and I have learned that Kawa doesn't support
constructor syntax in define-simple-class.
I understand the subclassing syntax should look like this:
(define-simple-class <MyApplicationWindow> (<org.eclipse.jface.window.ApplicationWindow>)
...)
(where ... is my lack of understanding about how to generate a
MyApplicationWindow instance within its own class definition).
I also understand that I can get around the constructor limitation using
this syntax:
((primitive-virtual-method <org.eclipse.jface.window.ApplicationWindow>
'addStatusLine <void> ())
window)
I'm just hoping for a tip about putting this all together.
This is very recent introduction to SWT/JFace:
<http://www.javaworld.com/javaworld/jw-04-2004/jw-0426-swtjface_p.html>
Many thanks,
Adam