Skip to content

Instantly share code, notes, and snippets.

@netopyr
netopyr / builder_api_0_2.java
Created February 21, 2017 20:28
Example of ReduxFX builder API 0.2
return HBox()
.padding(50.0)
.spacing(20.0)
.children(
ColorChooser()
.color(state.getColor(), (oldValue, newValue) -> Actions.updateColor(newValue)),
Region()
.background(state.getColor())
.minWidth(100.0)
.minHeight(100.0)
@netopyr
netopyr / multi_stage_view.java
Created February 21, 2017 20:32
Example for multiple stages with ReduxFX
public static VNode view(AppModel state) {
return Stages()
.children(
Stage()
.title("Left Screen")
.showing(state.getScreen() == Screen.LEFT)
.scene(
Scene()
.root(
StackPane()
@netopyr
netopyr / cached_threads1.java
Created March 13, 2017 10:18
Example where a cached-thread-pool prevents immediate exit of the application
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class CachedThreads {
public static void main(String[] args) {
final ExecutorService executor = Executors.newCachedThreadPool();
executor.submit(() -> System.out.println("Hello World"));
}
@netopyr
netopyr / cached_threads2.java
Created March 13, 2017 10:24
Example of a cached-thread-pool where all threads are daemon-threads
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
public class ImprovedCachedThreads {
public static void main(String[] args) {
final ThreadFactory threadFactory = runnable -> {
final Thread thread = new Thread(runnable, "HelloWorldThread");
thread.setDaemon(true);
@netopyr
netopyr / string_init.java
Last active May 7, 2020 18:30
Example of setting a String
final String s = "He said \"Good morning\" while entering the room.";