GUI from Ali
FirstName LastName and Miunknown
plain_text
4 years ago
1.5 kB
9
Indexable
package ca.seneca.eventhanding; import java.io.File; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Pos; 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 FormFill extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage ps) throws Exception { GridPane gp =new GridPane(); gp.setAlignment(Pos.CENTER); gp.setHgap(5); gp.add(new Label("First Name:"), 0, 0); TextField fn=new TextField(); gp.add(fn, 1, 0); gp.add(new Label("MI: "), 0, 1); TextField mi=new TextField(); gp.add(mi, 1, 1); gp.add(new Label("Last Name: "), 0, 2); TextField ln=new TextField(); gp.add(ln, 1, 2); Button btnA= new Button("Add Name"); Button btnR= new Button("Read Name(s)"); gp.add(btnA, 1, 3); gp.add(btnR, 1, 4); //get user input //TODO put it into "info.txt" file btnA.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { String fns =fn.getText(); String mis =mi.getText(); String lns= ln.getText(); // File file new File ("info.txt"); } }); Scene sc = new Scene(gp,400,400); ps.setTitle("Name Name "); ps.setScene(sc); ps.show(); } }
Editor is loading...