Skip to content

Instantly share code, notes, and snippets.

@guigarage
guigarage / gist:6ea110b098222ae0c83c
Created September 16, 2014 17:33
Add a custom font to a JavaFX application by using CSS
@font-face {
font-family: 'Roboto';
src: url('Roboto-Medium.ttf');
}
.text {
-fx-font-family: "Roboto";
}
@guigarage
guigarage / DataFX concurreny
Created October 22, 2014 16:22
JavaFX concurreny
ProcessChain.create().
addRunnableInPlatformThread(() -> blockUI()).
addSupplierInExecutor(() -> loadFromServer()).
addConsumerInPlatformThread(d -> updateUI(d)).
onException(e -> handleException(e)).
withFinal(() -> unblockUI()).
run();
@guigarage
guigarage / gist:23b4bbed2823e84b9a52
Created October 22, 2014 22:27
DataFX dependency
<dependencies>
<dependency>
<groupId>org.javafxdata</groupId>
<artifactId>datafx-core</artifactId>
<version>8.0</version>
</dependency>
</dependencies>
@guigarage
guigarage / background thread - old way
Created October 22, 2014 16:40
background thread - old way
Runnable backgroundRunnable = () -> {
try {
data = loadFromServer();
Platform.runLater(() -> {
updateUI(data);
});
} catch(Exception e) {
Platform.runLater(() -> {
handleException(e);
});
@guigarage
guigarage / ProcessChain usage
Created October 22, 2014 16:41
Background thread DataFX way - ProcessChain
ProcessChain.create().
addRunnableInPlatformThread(() -> blockUI()).
addSupplierInExecutor(() -> loadFromServer()).
addConsumerInPlatformThread(d -> updateUI(d)).
onException(e -> handleException(e)).
withFinal(() -> unblockUI()).
run();
@guigarage
guigarage / gist:ec12d20ab5b145429f2f
Created September 16, 2014 19:42
Awesone Font icon
button.setText('\uf040' + "");
// \uf040 is the unicode char for the icon as defines here: http://fortawesome.github.io/Font-Awesome/icon/pencil/
@guigarage
guigarage / gist:73bb8632aaf658216ae1
Created September 16, 2014 19:52
Define an awesome icon for a button
#myButton {
-fx-icon-text: "\uf0a9";
}
@guigarage
guigarage / gist:606a097fc001dcd3e5e4
Created September 16, 2014 19:49
Usage of IconifiedButtonSkin
IconifiedButtonSkin.addStyle(myButton);
@guigarage
guigarage / gist:dd2add8ad17e43ac74f7
Created September 16, 2014 19:06
How to use the SimpleMediaListCell
public class Album implements Media {
private String artist;
private String coverUrl;
private String name;
//getter & setter
@guigarage
guigarage / gist:1fc3427c4139d312f9e1
Created September 16, 2014 19:07
Dependency to ui-basics
<dependency>
<groupId>com.guigarage</groupId>
<artifactId>ui-basics</artifactId>
<version>X.Y</version>
</dependency>