Skip to content

Instantly share code, notes, and snippets.

james-d

Block or report user

Report or block james-d

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@james-d
james-d / ZoomableLineChart.java
Created Oct 31, 2013
Example of a LineChart that can be zoomed via mouse.
View ZoomableLineChart.java
import java.util.Collections;
import java.util.Random;
import javafx.application.Application;
import javafx.beans.binding.BooleanBinding;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
@james-d
james-d / ComboBoxSortableTable.java
Last active Jun 1, 2018
TableView that sorts either by clicking on the column headers or by selecting a column from a combo box.
View ComboBoxSortableTable.java
import java.util.Arrays;
import java.util.Collections;
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
@james-d
james-d / PseudoClassExample.java
Last active Dec 28, 2015
Example of using new Pseudoclass API in JavaFX 8.
View PseudoClassExample.java
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;
View BoundTableColumnExample.java
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;
@james-d
james-d / ListCellTaskExample.java
Last active Oct 14, 2019
Example of a ListView which displays tasks. The customized ListCell updates its display depending on the state and progress of the task. The Task implementation introduces a counter property: since changing the value of this property will result in changes to the UI, these changes must be performed on the FX Application Thread.
View ListCellTaskExample.java
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.binding.Bindings;
import javafx.beans.property.ReadOnlyIntegerProperty;
import javafx.beans.property.ReadOnlyIntegerWrapper;
import javafx.beans.value.ChangeListener;
@james-d
james-d / TableViewSample.java
Created Dec 2, 2013
TableView with context menu applied to table rows. Based on the example in the tutorial at http://docs.oracle.com/javafx/2/ui_controls/table-view.htm#CJAGAAEE. (I don't necessarily like the style of some of this, but wanted to keep changes to the standard example minimal.)
View TableViewSample.java
import java.util.Arrays;
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
@james-d
james-d / HighlightingTableViewSample.java
Last active Jun 15, 2016
Example of a row factory wrapper for TableViews which manages adding and removing a style class from a list of row indexes.
View HighlightingTableViewSample.java
import java.util.Arrays;
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
@james-d
james-d / HighlightingTableViewSample.java
Last active Jan 18, 2016
JavaFX 8 version of https://gist.github.com/james-d/7813134, taking advantage of pseudoclasses.
View HighlightingTableViewSample.java
import java.util.Arrays;
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
@james-d
james-d / ShootingGame.java
Last active Apr 28, 2019
Demo of using Shape.intersect(...) in conjunction with a TranslateTransition to test for collisions.
View ShootingGame.java
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import javafx.animation.TranslateTransition;
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
@james-d
james-d / Person.java
Last active Oct 5, 2016
Example of attaching context-specific context menus to a TableView. Menus are attached for the TableView context, TableRow context, and TableCell context.
View Person.java
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
public class Person {
private final StringProperty firstName ;
private final StringProperty lastName ;
private final StringProperty email ;
public Person(String firstName, String lastName, String email) {
this.firstName = new SimpleStringProperty(this, "firstName", firstName);
You can’t perform that action at this time.