Skip to content

Instantly share code, notes, and snippets.

@TheItachiUchiha
TheItachiUchiha / UnselectListCell.java
Created January 30, 2018 07:34
A ListCell which can be used to unselect
private class UnselectListCell<T> extends ListCell<T> {
public UnselectListCell() {
addEventFilter(MouseEvent.MOUSE_PRESSED, event -> {
if (!isEmpty()) {
MultipleSelectionModel<T> selectionModel = getListView().getSelectionModel();
int index = getIndex();
if (selectionModel.getSelectedIndices().contains(index)) {
selectionModel.clearSelection(index);
} else {
@dmolesUC
dmolesUC / IndexColumnDemo.java
Created December 19, 2017 19:12
Displaying JavaFX TableView row number in a column
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.ObjectBinding;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.TableCell;
@TheItachiUchiha
TheItachiUchiha / MaskerPaneTest.java
Created May 10, 2016 09:42
Tests the hide/show property of a MaskerPane
import javafx.application.Application;
import javafx.concurrent.Task;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import org.controlsfx.control.MaskerPane;
public class MaskerPaneTest extends Application {
@jewelsea
jewelsea / JavaFXTrayIconSample.java
Last active November 13, 2023 14:54
Demonstrate using the System Tray (AWT) to control a JavaFX application.
import javafx.application.*;
import javafx.geometry.Pos;
import javafx.scene.*;
import javafx.scene.control.Label;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.stage.*;
import javax.imageio.ImageIO;
import java.io.IOException;
@andytill
andytill / DragResizer.java
Last active September 22, 2021 08:42
DragResizercan be used to add mouse listeners to a Region and make it resizable by the user by clicking and dragging the border in the same way as a window. Only height resizing is currently implemented.
import javafx.event.EventHandler;
import javafx.scene.Cursor;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Region;
/**
* {@link DragResizer} can be used to add mouse listeners to a {@link Region}
* and make it resizable by the user by clicking and dragging the border in the
* same way as a window.
* <p>
@jewelsea
jewelsea / Calc.java
Last active April 4, 2024 05:49
A simple JavaFX calculator
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.beans.property.*;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.*;
import javafx.stage.*;