Created
March 3, 2016 15:55
-
-
Save SamuelSchwent/485beb737a97b8a2aab2 to your computer and use it in GitHub Desktop.
Java - Scene Builder Application 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <?import javafx.geometry.Insets?> | |
| <?import javafx.scene.control.Button?> | |
| <?import javafx.scene.control.Label?> | |
| <?import javafx.scene.control.TextField?> | |
| <?import javafx.scene.layout.AnchorPane?> | |
| <AnchorPane prefHeight="350.0" prefWidth="300.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.65" fx:controller="Challenge3.NameFormatterController"> | |
| <children> | |
| <Label layoutX="48.0" layoutY="30.0" text="First Name:" textAlignment="CENTER" /> | |
| <Label layoutX="33.0" layoutY="55.0" text="Middle Name:" textAlignment="CENTER" /> | |
| <Label layoutX="49.0" layoutY="80.0" text="Last Name:" textAlignment="CENTER" /> | |
| <Label layoutX="79.0" layoutY="105.0" text="Title:" textAlignment="CENTER" /> | |
| <TextField fx:id="firstName" layoutX="114.0" layoutY="26.0" /> | |
| <TextField fx:id="middleName" layoutX="114.0" layoutY="51.0" /> | |
| <TextField fx:id="lastName" layoutX="114.0" layoutY="76.0" /> | |
| <TextField fx:id="title" layoutX="114.0" layoutY="101.0" /> | |
| <Button fx:id="tfmlButton" layoutX="19.0" layoutY="138.0" mnemonicParsing="false" onAction="#tfml" prefWidth="135.0" text="Title First Middle Last" /> | |
| <Button fx:id="fmlButton" layoutX="19.0" layoutY="163.0" mnemonicParsing="false" onAction="#fml" prefWidth="135.0" text="First Middle Last" /> | |
| <Button fx:id="flButton" layoutX="19.0" layoutY="188.0" mnemonicParsing="false" onAction="#fl" prefWidth="135.0" text="First Last" /> | |
| <Button fx:id="lfmtButton" layoutX="19.0" layoutY="213.0" mnemonicParsing="false" onAction="#lfmt" prefWidth="135.0" text="Last, First Middle, Title" /> | |
| <Button fx:id="lfmButton" layoutX="18.0" layoutY="238.0" mnemonicParsing="false" onAction="#lfm" prefWidth="135.0" text="Last, First Middle" /> | |
| <Button fx:id="lfButton" layoutX="18.0" layoutY="263.0" mnemonicParsing="false" onAction="#lf" prefWidth="135.0" text="Last, First" /> | |
| <Label fx:id="outputLabel" alignment="CENTER" layoutX="16.0" layoutY="310.0" prefHeight="17.0" prefWidth="269.0" textAlignment="CENTER" /> | |
| <Label alignment="CENTER" layoutX="165.0" layoutY="140.0" prefHeight="146.0" prefWidth="107.0" text="Enter Your Name and click a button to format it." textAlignment="CENTER" wrapText="true"> | |
| <padding> | |
| <Insets left="15.0" right="15.0" /> | |
| </padding> | |
| </Label> | |
| </children> | |
| </AnchorPane> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package Challenge3; | |
| import javafx.application.Application; | |
| import javafx.fxml.FXMLLoader; | |
| import javafx.scene.Parent; | |
| import javafx.scene.Scene; | |
| import javafx.stage.Stage; | |
| public class NameFormatter extends Application{ | |
| @Override | |
| public void start(Stage stage) throws Exception { | |
| Parent parent = FXMLLoader.load(getClass().getResource("NameFormatter.fxml")); | |
| Scene scene = new Scene(parent); | |
| stage.setTitle("Name Formatter"); | |
| stage.setScene(scene); | |
| stage.show(); | |
| } | |
| public static void main(String[] args) { | |
| launch(args); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package Challenge3; | |
| import javafx.fxml.FXML; | |
| import javafx.scene.control.Button; | |
| import javafx.scene.control.Label; | |
| import javafx.scene.control.TextField; | |
| public class NameFormatterController { | |
| @FXML | |
| private Button tfmlButton; | |
| @FXML | |
| private Button fmlButton; | |
| @FXML | |
| private Button flButton; | |
| @FXML | |
| private Button lfmtButton; | |
| @FXML | |
| private Button lfmButton; | |
| @FXML | |
| private Button lfButton; | |
| @FXML | |
| private Label outputLabel; | |
| @FXML | |
| private TextField firstName; | |
| @FXML | |
| private TextField middleName; | |
| @FXML | |
| private TextField lastName; | |
| @FXML | |
| private TextField title; | |
| public void initialize(){} | |
| public void tfml() | |
| { | |
| outputLabel.setText(title.getText() + " " + | |
| firstName.getText() + " " + | |
| middleName.getText() + " " + | |
| lastName.getText()); | |
| } | |
| public void fml() | |
| { | |
| outputLabel.setText(firstName.getText() + " " + | |
| middleName.getText() + " " + | |
| lastName.getText()); | |
| } | |
| public void fl() | |
| { | |
| outputLabel.setText(firstName.getText() + " " + | |
| lastName.getText()); | |
| } | |
| public void lfmt() | |
| { | |
| outputLabel.setText(lastName.getText() + ", " + | |
| firstName.getText() + " " + | |
| middleName.getText() + ", " + | |
| title.getText()); | |
| } | |
| public void lfm() | |
| { | |
| outputLabel.setText(lastName.getText() + ", " + | |
| firstName.getText() + " " + | |
| middleName.getText()); | |
| } | |
| public void lf() | |
| { | |
| outputLabel.setText(lastName.getText() + ", " + | |
| firstName.getText()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment