Skip to content

Instantly share code, notes, and snippets.

View nezarjhons's full-sized avatar
🎯
Focusing

nezar nezarjhons

🎯
Focusing
View GitHub Profile
@nezarjhons
nezarjhons / ToggleSwitch
Created August 25, 2021 02:34 — forked from TheItachiUchiha/ToggleSwitch
A simple Toggle Switch using JavaFX
import javafx.beans.property.SimpleBooleanProperty;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
public class ToggleSwitch extends HBox {
private final Label label = new Label();
.root {
-fx-accent: #1e74c6;
-fx-focus-color: -fx-accent;
-fx-base: #373e43;
-fx-control-inner-background: derive(-fx-base, 35%);
-fx-control-inner-background-alt: -fx-control-inner-background ;
}
.label{
.root {
-fx-accent: #1e74c6;
-fx-focus-color: -fx-accent;
-fx-base: #373e43;
-fx-control-inner-background: derive(-fx-base, 35%);
-fx-control-inner-background-alt: -fx-control-inner-background ;
}
.label{
@Da9el00
Da9el00 / Controller.java
Created April 15, 2021 12:11
Alarm Clock
package sample;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TextField;
import javafx.scene.text.Text;
import javafx.util.Duration;
public class VirtualKeyboard {
private final VBox root ;
/**
* Creates a Virtual Keyboard.
* @param target The node that will receive KeyEvents from this keyboard.
* If target is null, KeyEvents will be dynamically forwarded to the focus owner
* in the Scene containing this keyboard.
*/
public VirtualKeyboard(ReadOnlyObjectProperty<Node> target) {
public class VirtualKeyboard {
private final VBox root ;
/**
* Creates a Virtual Keyboard.
* @param target The node that will receive KeyEvents from this keyboard.
* If target is null, KeyEvents will be dynamically forwarded to the focus owner
* in the Scene containing this keyboard.
*/
public VirtualKeyboard(ReadOnlyObjectProperty<Node> target) {
@omernaci
omernaci / ScreenResolutionDemo.java
Created April 19, 2017 05:56
JavaFX Scene Size with Screen Resolution
import java.awt.Dimension;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
public class ScreenResolutionDemo extends Application {
@Faoc
Faoc / AutoCompleteTextBox.java
Last active April 12, 2023 05:47 — forked from floralvikings/AutoCompleteTextBox.java
Simple JavaFX TextBox with AutoComplete functionality based on a supplied set.
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Side;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.CustomMenuItem;
import javafx.scene.control.TextField;
@james-d
james-d / LineItemTable.java
Last active April 21, 2021 20:58
Demonstrates using a TransformationList to create a "total line" in a TableView.
import java.util.function.Function;
import java.util.stream.Collectors;
import javafx.application.Application;
import javafx.beans.Observable;
import javafx.beans.binding.Bindings;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ReadOnlyIntegerProperty;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.ReadOnlyObjectWrapper;
@james-d
james-d / EditCell.java
Created February 13, 2015 03:18
(Fairly) reusable edit cell that commits on loss of focus on the text field. Overriding the commitEdit(...) method is difficult to do without relying on knowing the default implementation, which I had to do here. The test code includes a key handler on the table that initiates editing on a key press.
import javafx.event.Event;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableColumn.CellEditEvent;
import javafx.scene.control.TablePosition;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;