PDA

View Full Version : Trouble converting Java examples to Oxygene using inherited in classes



paul_nicholls
14-04-2012, 11:42 AM
I tried to convert the first Java example from here:
http://home.cogeco.ca/~ve3ll/jatutorg.htm

This is my code:


namespace platformation;

interface
uses
java.awt,
javax.swing;

type
GFrame = public class(JFrame)
public
constructor();
class method main(arg: array of String);
end;
GCanvas = public class(Canvas)
public
method paint(g: Graphics); override;
end;

implementation

constructor GFrame();
begin
inherited ('Graphics Demo');
setBounds(50, 50, 300, 300);
// set frame
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
var con: Container := self.getContentPane();
// inherit main frame
con.setBackground(Color.white);
// paint background
var canvas: GCanvas := new GCanvas();
// create drawing canvas
con.&add(canvas);
setVisible(true)
end;

class method GFrame.main(arg: array of String);
begin
new GFrame()
end;

method GCanvas.paint(g: Graphics);
begin
end;

end.

When I compile the project, it complains on this line:

inherited ('Graphics Demo');


Error 1 (E105) Cannot invoke non-delegate type "javax.swing.JFrame" C:\Shared\My Dropbox\Oxygene for java\projects\platformation\platformation\Program. pas 23 3 platformation

Any ideas how to fix this sort of error?

cheers,
Paul

pstudio
14-04-2012, 02:12 PM
inherited constructor ('Graphics Demo');

paul_nicholls
15-04-2012, 03:39 AM
Thanks mate, that worked :)