Last active
March 31, 2024 17:24
-
-
Save CaelumF/ac54faa10b801ab9af17f4fce2416a19 to your computer and use it in GitHub Desktop.
Java 8 Tuturial: First stage, simple FXML program
This file contains 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
!!!!!!!!complete intelliJ project zip: http://www.filedropper.com/dfdfg | |
File layout: http://i.imgur.com/dviIFhU.png | |
This gist is the first stage, and the end result of Tutorial 8. | |
Other helpful links: | |
Pircbot site, with download: http://www.jibble.org/pircbot.php | |
Pircbot maven online: https://mvnrepository.com/artifact/pircbot/pircbot | |
Pircbot maven location: pircbot:pircbot:1.5.0 | |
Scene Builder download page:http://gluonhq.com/labs/scene-builder/ | |
Gist 2(After exercise, working JavaFX IRC client): https://gist.github.com/CaelumF/dc54a2b3082d7827ee24feb9a20ca094 |
This file contains 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 sample; | |
import javafx.fxml.FXML; | |
import javafx.fxml.Initializable; | |
import javafx.scene.control.TextArea; | |
import javafx.scene.control.TextField; | |
import java.net.URL; | |
import java.util.ResourceBundle; | |
public class Controller implements Initializable{ | |
@FXML | |
TextArea myTextArea; | |
@FXML | |
TextField myTextField; | |
public void onTextFieldEnter(){ | |
myTextArea.setText(myTextArea.getText() + "\n" + myTextField.getText()); | |
myTextField.clear(); // Clears input field | |
myTextArea.end(); //Scrolls to bottom of textArea | |
} | |
@Override public void initialize(URL location, ResourceBundle resources){ | |
//Called when the Controller has been initialised. | |
} | |
} |
This file contains 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 sample; | |
import javafx.application.Application; | |
import javafx.fxml.FXMLLoader; | |
import javafx.scene.Parent; | |
import javafx.scene.Scene; | |
import javafx.stage.Stage; | |
public class Main extends Application { | |
@Override | |
public void start(Stage primaryStage) throws Exception{ | |
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml")); | |
primaryStage.setTitle("Hello World"); | |
primaryStage.setScene(new Scene(root, 300, 275)); | |
primaryStage.show(); | |
} | |
public static void main(String[] args) { | |
launch(args); | |
} | |
} |
This file contains 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.scene.control.TextArea?> | |
<?import javafx.scene.control.TextField?> | |
<?import javafx.scene.layout.AnchorPane?> | |
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Controller"> | |
<children> | |
<TextArea fx:id="myTextArea" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="25.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /> | |
<TextField fx:id="myTextField" onAction="#onTextFieldEnter" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" /> | |
</children> | |
</AnchorPane> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment