Default properties in oxygene for JAVA


(Damian Nguyen) #1

How can I set default property value for Java in oxygene?

(Carlo Kok) #2

Depends on what you mean with default; if you mean what a serializer considers the default that’s going to depend on an attribute specified. But if it’s the initial value:

property Value: Integer := 1234;

this will make Value start with 1234.

(Damian Nguyen) #3

I mean that when declaring class i have :
property x : boolean read get_x write set_x ;

and i want x to have default value lets say ‘true’

(Carlo Kok) #4

That’d depend on the implementation of get_x? What’s your end goal here?

(Damian Nguyen) #5

End goal is to have default value fo property in swing designer or to override its default value from base class

(marc hoffman) #6

I think you’d need to encode this manually, eg:

  var fX: Boolean:= true;
  property X : boolean read fX write set_X;

if you have a plain getter; or other logic (such as a flag whether it had bene set before or not) if you need a custom getter…