Skip to content

Instantly share code, notes, and snippets.

@james-d
james-d / TableWithAddDialog.java
Last active August 29, 2015 14:22
Example of using the javafx.scene.control.Dialog API from Java 8u40.
import java.util.function.Function;
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ObservableValue;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
@james-d
james-d / PlayerCountExample.java
Last active August 29, 2015 14:27
Demos a table column counting elements of a different list with a property matching the value in a given row.
import java.util.List;
import java.util.Objects;
import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import javafx.application.Application;
import javafx.beans.Observable;
import javafx.beans.binding.Bindings;
@james-d
james-d / Assignment.java
Last active October 11, 2015 22:05
Demo of creating TreeViews with dynamic connections between them. Not guaranteed to be memory-leak-free or efficient....
package connectedtrees;
public class Assignment {
private final Task task ;
private final Employee assignee ;
public Assignment(Task task, Employee assignee) {
this.task = task;
this.assignee = assignee;
}
public Task getTask() {
@james-d
james-d / AnimatingPlot.java
Created October 25, 2015 00:53
Example of function plot with animation along plotted function in JavaFX. Uses Canvas to render the plot.
import java.util.function.DoubleUnaryOperator;
import javafx.animation.Animation;
import javafx.animation.Transition;
import javafx.application.Application;
import javafx.beans.property.DoubleProperty;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import java.util.stream.Stream;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import javafx.stage.Stage;
@james-d
james-d / streamingdatafx.DataStreamParser.java
Last active November 15, 2015 11:59
Demo of a JavaFX application which is updated by data streaming in. Created as a solution to https://community.oracle.com/message/12694944#12694944. There are two components: the main application, which consists of a server waiting for messages of the form "speed=<value>", an FXML file, FXML controller, and a main class that creates the server, …
package streamingdatafx;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.nio.ByteBuffer;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.PixelReader;
import javafx.scene.image.WritablePixelFormat;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
@james-d
james-d / PseudoClassExample.java
Last active December 28, 2015 19:19
Example of using new Pseudoclass API in JavaFX 8.
package pseudoclasstest;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import java.util.Arrays;
import java.util.List;
import javafx.application.Application;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ReadOnlyDoubleProperty;
import javafx.beans.property.ReadOnlyDoubleWrapper;
import javafx.beans.property.SimpleDoubleProperty;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import java.util.regex.Pattern;
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.IntegerProperty;