Jump to content

GUI component interaction: Difference between revisions

(+Java)
Line 238:
}
</lang>
 
=={{header|Delphi}}==
 
<lang Delphi>FILE: Unit1.pas</lang>
<lang Delphi>
unit Unit1;
 
interface
 
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
 
type
TForm1 = class(TForm)
EditInputField: TEdit;
ButtonRandom: TButton;
ButtonIncrement: TButton;
procedure EditInputFieldChange(Sender: TObject);
procedure ButtonIncrementClick(Sender: TObject);
procedure ButtonRandomClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
 
var
Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.EditInputFieldChange(Sender: TObject);
begin
TRY
StrToInt(EditInputField.Text);
EXCEPT
ShowMessage('Error! The Input Value is not numeric!');
EditInputField.Text := '0';
END;
end;
 
procedure TForm1.ButtonIncrementClick(Sender: TObject);
begin
EditInputField.text := IntToStr(StrToInt(EditInputField.Text) + 1);
end;
 
procedure TForm1.ButtonRandomClick(Sender: TObject);
begin
Randomize;
EditInputField.Text := IntToStr(Random(High(Integer)));
end;
 
end.</lang>
<lang Delphi>FILE: Unit1.dfm (No manual interaction!!! Will automatically be generated/modified when editing the GUI)</lang>
<lang Delphi>
object Form1: TForm1
Left = 1899
Top = 212
Width = 266
Height = 172
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object EditInputField: TEdit
Left = 16
Top = 16
Width = 121
Height = 21
TabOrder = 0
Text = '0'
OnChange = EditInputFieldChange
end
object ButtonRandom: TButton
Left = 96
Top = 56
Width = 75
Height = 25
Caption = 'Random'
TabOrder = 1
OnClick = ButtonRandomClick
end
object ButtonIncrement: TButton
Left = 16
Top = 56
Width = 75
Height = 25
Caption = 'Increment'
TabOrder = 2
OnClick = ButtonIncrementClick
end
end
</lang>
 
 
 
 
=={{header|Fantom}}==
16

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.