4 ms·
I wish Java had something similar to Properties in Delphi. http://docwiki.embarcadero.com/RADStudio/Sydney/en/Properties_(Delphi) http://docwiki.embarcadero.co
by pkphilip 6y ago
I wish Java had something similar to Properties in Delphi.
http://docwiki.embarcadero.com/RADStudio/Sydney/en/Properties_(Delphi) http://docwiki.embarcadero.com/RADStudio/Sydney/en/Propertie...
You can have Get and Set methods for properties or even allow direct access to the variable itself.
type
TCompass = class(TControl)
private
FHeading: THeading;
procedure SetHeading(Value: THeading);
published
property Heading: THeading read FHeading write SetHeading;
...
end;
Also, properties can be indexed.
type
TRectangle = class
private
FCoordinates: array[0..3] of Longint;
function GetCoordinate(Index: Integer): Longint;
procedure SetCoordinate(Index: Integer; Value: Longint);
public
property Left: Longint index 0 read GetCoordinate
write SetCoordinate;
property Top: Longint index 1 read GetCoordinate
write SetCoordinate;
property Right: Longint index 2 read GetCoordinate
write SetCoordinate;
property Bottom: Longint index 3 read GetCoordinate
write SetCoordinate;
property Coordinates[Index: Integer]: Longint
read GetCoordinate
write SetCoordinate;
...
end;
Properties can also have "property pages" which can show specific user interfaces for viewing/setting these properties.
https://www.delphipower.xyz/guide_8/adding_a_property_page.html https://www.delphipower.xyz/guide_8/adding_a_property_page.h...
I have yet to see anything of this sophistication in Java or for that matter in any other component framework.