Skip to content

Instantly share code, notes, and snippets.

@jewelsea
jewelsea / BreakoutGame.java
Created July 9, 2021 03:54
Breakout Game
import javafx.animation.AnimationTimer;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.geometry.BoundingBox;
import javafx.geometry.Bounds;
import javafx.geometry.Point2D;
import javafx.scene.Scene;
@jewelsea
jewelsea / ClippedShadow.java
Created August 27, 2014 23:53
Demonstrates adding a halo effect (a drop shadow) around a translucent window.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.*;
import javafx.stage.*;
import org.scenicview.ScenicView;
// Java 8 code
public class ClippedShadow extends Application {
@jewelsea
jewelsea / JavaFXTrayIconSample.java
Last active July 22, 2024 07:42
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;
@jewelsea
jewelsea / DoughnutChart.java
Last active July 1, 2023 00:23
Creating a Doughnut chart in JavaFX
import javafx.collections.ObservableList;
import javafx.geometry.Bounds;
import javafx.scene.Node;
import javafx.scene.chart.PieChart;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
public class DoughnutChart extends PieChart {
private final Circle innerCircle;
@jewelsea
jewelsea / Frosty.java
Created March 25, 2014 19:49
iOS 7 style sliding glass pane prototype for JavaFX
import javafx.animation.*;
import javafx.application.Application;
import javafx.beans.property.*;
import javafx.geometry.Rectangle2D;
import javafx.scene.*;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.effect.*;
import javafx.scene.image.*;
import javafx.scene.input.ScrollEvent;
@jewelsea
jewelsea / SimpleDocking.java
Created March 16, 2014 05:45
Simplistic docking setup for JavaFX
import javafx.application.Application;
import javafx.geometry.Orientation;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.*;
public class SimpleDocking extends Application {
public void start(final Stage stage) throws Exception {
final SplitPane rootPane = new SplitPane();
@jewelsea
jewelsea / PepsiChallenge.java
Created February 28, 2014 07:17
JavaFX BlendMode.DIFFERENCE sample.
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.BlendMode;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
@jewelsea
jewelsea / CharacterMovement.java
Created January 8, 2014 18:25
JavaFX sample to move a character around a field based on key controls.
import javafx.animation.AnimationTimer;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.*;
import javafx.scene.image.*;
import javafx.scene.input.KeyEvent;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
/**
@jewelsea
jewelsea / ShadowedRoundedImage.java
Last active November 18, 2019 21:55
Creates a JavaFX ImageView which contains an image displayed in as a rounded rectangle with a drop shadow effect.
import javafx.application.Application;
import javafx.fxml.*;
import javafx.scene.*;
import javafx.scene.effect.DropShadow;
import javafx.scene.image.*;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
@jewelsea
jewelsea / Hoverboard.java
Created December 6, 2013 09:50
Hover over a JavaFX Label to reveal a ComboBox to change the label's text.
import javafx.application.Application;
import javafx.geometry.*;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.Stage;
public class Hoverboard extends Application {
public class TextChooser extends StackPane {