Skip to content

Instantly share code, notes, and snippets.

View andytill's full-sized avatar

Andy Till andytill

View GitHub Profile
gist test
@andytill
andytill / FXUtils.java
Last active May 7, 2021 06:59
Utility for for finding a JavaFX node by it's ID
package test;
import javafx.scene.*;
import javafx.scene.control.*;
public class FXUtils {
/**
* Find a {@link Node} within a {@link Parent} by it's ID.
* <p>
@andytill
andytill / GuiceControllerFactory.java
Created July 1, 2012 17:53
Creating JavaFX Controllers using Guice
/**
* A JavaFX controller factory for constructing controllers via Guice DI. To
* install this in the {@link FXMLLoader}, pass it as a parameter to
* {@link FXMLLoader#setControllerFactory(Callback)}.
* <p>
* Once set, make sure you do <b>not</b> use the static methods on
* {@link FXMLLoader} when creating your JavaFX node.
*/
class GuiceControllerFactory implements Callback<Class<?>, Object> {
@andytill
andytill / TestApp2.java
Created July 15, 2012 10:31
Getting observable collections working with an extractor callback
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.util.Callback;
import java.util.ArrayList;
@andytill
andytill / ListViewIndexChangesWhenItemUpdated .java
Created July 15, 2012 13:07
Example application showing how changing an item in a ListView changes its index
import java.io.IOException;
import java.util.Arrays;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.Observable;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
@andytill
andytill / ListBuilderController.java
Created July 29, 2012 19:24
JavaFX controller implementing IdentifiableController
import javafx.fxml.FXML;
import javafx.scene.Parent;
@FXMLLoadingScoped
public class ListBuilderController<T> implements IdentifiableController {
@FXML
private Parent root;
@andytill
andytill / embedListBuilder.fxml
Created July 29, 2012 19:44
AnchorPane with embedded FXML control, in this case ListBuilder.fxml
<AnchorPane fx:id="factorsList" minHeight="138.0" prefHeight="138.0" prefWidth="418.0">
<children>
<fx:include source="listBuilder.fxml" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
<VBox.margin>
<Insets left="2.0" right="2.0" />
</VBox.margin>
</AnchorPane>
public interface IdentifiableController {
String getId();
}
@andytill
andytill / brume.css
Created August 20, 2012 12:17
JavaFX Light Grey Brume Theme
/**
* JavaFX CSS light grey/white 'brume' theme.
*/
.titled-pane {
-fx-effect: dropshadow(three-pass-box, #9F9F9F, 15, 0, 0, 0);
-fx-animated: true;
-fx-text-fill: #505050;
}
import java.util.List;
public class ControllerLookup {
private final List<IdentifiableController> identifiables;
public ControllerLookup(List<IdentifiableController> identifiables) {
this.identifiables = identifiables;
}
@SuppressWarnings("unchecked")