Pular para o conteúdo principal

Postagens

Mostrando postagens com o rótulo nashorn

Another World Cup App... Using JavaFX, FXML, Javascript, CSS

The World Cup Brazil is happening! It's exciting to see people from all over the world visiting my country! Today I decided to create another World Cup App, this time I'll use JavaFX, but I won't write any Java code . It's a simple app to visualize all the world cup matches and click on a game for details about it. I spent less than 3 hours working on the core of the application and a few more hours working on the details. Getting the resources to create the App By resources I meant images and to do this I downloaded all the flags images from Fifa site. It was a small and easy scrapping. Notice that all images are in under the following URL:  http://img.fifa.com/images/flags/4/{CODE}.png. To download all flags I used the following Python Script: import urllib2 codes = open('countries_codes.txt', 'r') for line in codes:         code = line.replace('\n', '').lower() + '.png'         img_url = 'http://img.fifa.com/ima...

Writing JavaFX apps using Javascript with the Java 8 Nashorn engine

Java 8 was just a great release! We already talked about Lambdas and created JavaFX 8 apps on this blog. Bruno Borges created a fx2048 , a JavaFX version of the famous 2048 game, which shows Lambdas and the Stream library usage. Today I'll rewrite the Sentiments App view in Javascript using the new JS engine named Nashorn , one of the exciting Java 8 new features. Loading the Script We load a file with the view contents, but before doing this, we add the main Stage so it can be referenced from the javascript file. That's enough for the Java part! package org.jugvale.sentiments.view; import javafx.application.Application; import javafx.stage.Stage; import javax.script.*; import java.io.FileReader; public class AppJS extends Application{ private final String SCRIPT = getClass().getResource("/sentimentsView.js").getPath(); public static void main(String args[]){ launch(args); } @Override public voi...