 |
|
BaselScript |
Beschreibung
Form
▀ ▀ ▀ ▀ JAVA ▀ ▀ ▀ ▀
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class FormExample extends Application {
@Override
public void start(Stage primaryStage) {
GridPane grid = new GridPane();
grid.setPadding(new Insets(10, 10, 10, 10));
grid.setVgap(10);
grid.setHgap(10);
Label nameLabel = new Label("Name:");
GridPane.setConstraints(nameLabel, 0, 0);
TextField nameTextField = new TextField();
GridPane.setConstraints(nameTextField, 1, 0);
Label ageLabel = new Label("Age:");
GridPane.setConstraints(ageLabel, 0, 1);
TextField ageTextField = new TextField();
GridPane.setConstraints(ageTextField, 1, 1);
Label emailLabel = new Label("Email:");
GridPane.setConstraints(emailLabel, 0, 2);
TextField emailTextField = new TextField();
GridPane.setConstraints(emailTextField, 1, 2);
Button submitButton = new Button("Submit");
GridPane.setConstraints(submitButton, 1, 3);
Label resultLabel = new Label();
submitButton.setOnAction(e -> {
String name = nameTextField.getText();
String age = ageTextField.getText();
String email = emailTextField.getText();
// Process the input data (e.g., validation or saving to a database)
String result = "Name: " + name + ", Age: " + age + ", Email: " + email;
resultLabel.setText(result);
});
grid.getChildren().addAll(nameLabel, nameTextField, ageLabel, ageTextField, emailLabel, emailTextField, submitButton, resultLabel);
Scene scene = new Scene(grid, 300, 200);
primaryStage.setTitle("Java Form Example");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
▀ ▀ ▀ ▀ KOTLIN ▀ ▀ ▀ ▀
import javafx.application.Application
import javafx.geometry.Insets
import javafx.scene.Scene
import javafx.scene.control.Button
import javafx.scene.control.Label
import javafx.scene.control.TextField
import javafx.scene.layout.GridPane
import javafx.stage.Stage
class FormExample : Application() {
override fun start(primaryStage: Stage) {
val grid = GridPane()
grid.padding = Insets(10.0, 10.0, 10.0, 10.0)
grid.vgap = 10.0
grid.hgap = 10.0
val nameLabel = Label("Name:")
GridPane.setConstraints(nameLabel, 0, 0)
val nameTextField = TextField()
GridPane.setConstraints(nameTextField, 1, 0)
val ageLabel = Label("Age:")
GridPane.setConstraints(ageLabel, 0, 1)
val ageTextField = TextField()
GridPane.setConstraints(ageTextField, 1, 1)
val emailLabel = Label("Email:")
GridPane.setConstraints(emailLabel, 0, 2)
val emailTextField = TextField()
GridPane.setConstraints(emailTextField, 1, 2)
val submitButton = Button("Submit")
GridPane.setConstraints(submitButton, 1, 3)
val resultLabel = Label()
submitButton.setOnAction {
val name = nameTextField.text
val age = ageTextField.text
val email = emailTextField.text
// Process the input data (e.g., validation or saving to a database)
val result = "Name: $name, Age: $age, Email: $email"
resultLabel.text = result
}
grid.children.addAll(nameLabel, nameTextField, ageLabel, ageTextField, emailLabel, emailTextField, submitButton, resultLabel)
val scene = Scene(grid, 300.0, 200.0)
primaryStage.title = "Kotlin Form Example"
primaryStage.scene = scene
primaryStage.show()
}
}
▀ ▀ ▀ ▀ PYTHON ▀ ▀ ▀ ▀
import tkinter as tk
def submit_form():
name = name_entry.get()
age = age_entry.get()
email = email_entry.get()
result_label.config(text=f"Name: {name}, Age: {age}, Email: {email}")
# Create the main window
root = tk.Tk()
root.title("Python Form")
# Create and arrange input fields and labels
name_label = tk.Label(root, text="Name:")
name_label.pack()
name_entry = tk.Entry(root)
name_entry.pack()
age_label = tk.Label(root, text="Age:")
age_label.pack()
age_entry = tk.Entry(root)
age_entry.pack()
email_label = tk.Label(root, text="Email:")
email_label.pack()
email_entry = tk.Entry(root)
email_entry.pack()
# Create and configure the "Submit" button
submit_button = tk.Button(root, text="Submit", command=submit_form)
submit_button.pack()
# Create a label to display the result
result_label = tk.Label(root, text="")
result_label.pack()
# Start the Tkinter main loop
root.mainloop()
▀ ▀ ▀ ▀ DELPHI ▀ ▀ ▀ ▀
program FormExample;
uses
Vcl.Forms, Vcl.Controls, Vcl.StdCtrls, Vcl.ExtCtrls;
type
TForm1 = class(TForm)
NameLabel: TLabel;
NameTextField: TEdit;
AgeLabel: TLabel;
AgeTextField: TEdit;
EmailLabel: TLabel;
EmailTextField: TEdit;
SubmitButton: TButton;
ResultLabel: TLabel;
procedure SubmitButtonClick(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.SubmitButtonClick(Sender: TObject);
var
NameValue, AgeValue, EmailValue: string;
begin
NameValue := NameTextField.Text;
AgeValue := AgeTextField.Text;
EmailValue := EmailTextField.Text;
// Process the input data (e.g., validation or saving to a database)
ResultLabel.Caption := `Name: ` + NameValue + `, Age: ` + AgeValue + `, Email: ` + EmailValue;
end;
end.
And here is the corresponding Delphi form file (.dfm):
delphi
Copy code
object Form1: TForm1
Left = 0
Top = 0
Caption = `Delphi Form Example`
ClientHeight = 153
ClientWidth = 331
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = `Tahoma`
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object NameLabel: TLabel
Left = 12
Top = 16
Width = 32
Height = 13
Caption = `Name:`
end
object NameTextField: TEdit
Left = 88
Top = 12
Width = 216
Height = 21
TabOrder = 0
Text = ``
end
object AgeLabel: TLabel
Left = 12
Top = 44
Width = 27
Height = 13
Caption = `Age:`
end
object AgeTextField: TEdit
Left = 88
Top = 40
Width = 216
Height = 21
TabOrder = 1
Text = ``
end
object EmailLabel: TLabel
Left = 12
Top = 72
Width = 34
Height = 13
Caption = `Email:`
end
object EmailTextField: TEdit
Left = 88
Top = 68
Width = 216
Height = 21
TabOrder = 2
Text = ``
end
object SubmitButton: TButton
Left = 228
Top = 100
Width = 75
Height = 25
Caption = `Submit`
TabOrder = 3
OnClick = SubmitButtonClick
end
object ResultLabel: TLabel
Left = 12
Top = 116
Width = 301
Height = 17
AutoSize = False
Caption = ``
end
end
▀ ▀ ▀ ▀ BASEL SCRIPT ▀ ▀ ▀ ▀
scene=1 name=" form"
// start script
section init
if #_screen_rotate== landscape
draw form=landscape
else
draw form=portrait
end
end section
// define form landscape
form landscape
tile=text name=#titel x=400 y=40 text=ADDRESS
tile=property x=30
tile=text y=140 text="last name"
tile=text y=240 text="first name"
tile=text y=340 text="city"
tile=text y=440 text="street"
tile=property x=260
tile=input y=140 name=#name_person
tile=input y=240 name=#firstname_person
tile=input y=340 name=#city_person
tile=input y=440 name=#street_person
tile=button name=b text=Back x=260 y= 580 action=back
tile=button name=b text=Submit x=700 y= 580 action=save
end
// define form portrait
form portrait
...
end
// button save pressed
section save
message " button save was pressed"
end
end scene 1