Pular para o conteúdo principal

Postagens

A minimal Java 8 project using Maven

To use Java 8 with Maven is easy. Maven already supports it and it's good for JavaFX developers that a Java 8 is a JavaFX 8 application already! To make easy the creation of new projects using JavaFX 8, I created an archetype for JavaFX applications. It will be useful for me, so it might be useful for someone else as well. Using Maven with JavaFX 8 Having Maven 3.x and a Java 8 newest build, you are able to create JavaFX 8 applications using Maven! I created a "Hello World" application to serve as a starting point for new applications. The pom.xml is on github and the directories structure is as follow: Building and Running from Maven Make sure you export JAVA_HOME to the root path of your Java 8 installation. In my case, before running Maven I used the followin command (in Ubuntu 12.04): $  export JAVA_HOME=/opt/java/jdk1.8.0/  After this you should be able to build your project: $ mvn clean project Notice that in the root direc...

A generic handler for all input events in JavaFX 2

The JavaFX API is really complete and sometimes I find new possibilities with it. This is a small blog post to describe what I recently did with the event handling part of the JavaFX API. Update:   Jonathan Giles pointed that we can add a handler  to all kind of events with one single line instead call setOn* multiple times:  lbl.addEventHandler( MouseEvent.ANY, eventHandler) One handler to all Events I'm creating a sample application for my portuguese blog about JavaFX basics and I was exploring the Event class to find the best way to create an event handler to demonstrate all Node's possible event input handlers.(or the most famous one) I found that the event object has an attribute of type EventType and all the events implementations contains a String representation of that event. It can be done checking, for example, the MouseEvent class source code. With this I created only one class to handle all the events on my sample program. I think it might be useful...

Using BRMS/Drools 5 REST API - Part 1

As you might have noticed already, everything comes with a RESTful API . REST is just awesome. A friend of mine works everyday with Business Rule Management System , BRMS, and it has a simple,but useful, client API. In this series of articles, we will create a Java wrapper for the REST API and then a simple JavaFX 2.2 application to use it. In this article I'll describe the reusable wrapper I created. On next article we will talk about the JavaFX application. * I call a programming language   wrapper  an API that allow us to access a REST API without caring about the HTTP operations, but only with the programming language itself. Our wrapper is aimed to help us access the REST API provided by BRMS without having to handle HTTP requests. About BRMS/Drools Drools is a community project  which is part of the product created by Red Hat called BRMS. The BRMS 5.x documentation defines it as follow: "JBoss Enterprise BRMS Platform is a business rules management ...

JavaFX CRUD: The Client Side

Beta post In my last post I showed a JEE application to make CRUD operation on a domain object called Framework, which represents an application framework. In this post we will show the client part, the technologies that were used and how simple is to create JavaFX applications using FXML and pure Java. The view I had the honor of being one of the first "bloggers" to test JavaFX Scene Builder . Using this tool you can drag and drop interface elements and a XML will be generated and it has the .fxml extension. This FXML can be loaded in a JavaFX application and the view elements can be inject in a controller class using the @FXML annotation. Screenshots from the application are in a previous post . Then, in Java side, we have a class called  CrudframeworksPresenter . This class is linked with the FXML and it the presenter, which updates the view and handle the CRUD actions. See the FXML source code first line where I refer to the controller class. I tell the con...

Another JavaFX CRUD: The server side

In my last post I briefly showed a project that was supposed to be a small project to test Afterburner.fx. It is basically a CRUD application, but it uses REST to access a JEE application installed in JBoss AS 7 ( renamed as Wildfly ). In this post we will show the server side and how JEE 6 makes easier creating robust enterprise applications. It's required at least basic knowledge in JEE. Architecture  I won't go further on this subject since Hendrik Ebbers did a great job doing this in this post . The following image explains everything: JavaFX communication with the server through a REST interface and it will access the model data using a Business Layer . The difference is that we won't have a JSF layer at the moment and we will have a Service Layer , which is equivalent to the Business Layer . Understood this part, we will now talk about code! The application model Everything starts with a model that is the class that reflects the business of your applic...

Testing Afterburner.fx in a CRUD Application using JavaFX and FXML

It's been a few months without any new post on this blog :( I was preparing an application using Infinispan, NoSQL and JavaFX and unfortunately I lost my data in the disc... That would an epic post! In this post I'm going to show you a good old CRUD using FXML, JavaFX and the recent framework called Afterburner.fx , created by Adam Bien . About Afterburner.fx   Afterburner.fx is a minimalistic (2 classes) JavaFX MVP framework based on Convention over Configuration. It's not me saying this, it's on afterburner.fx web page. What I can say I like the idea of this simple framework. I can say that it will not solve all issues, but it brings DI and the conventions saves  from writing repetitive code. What is FXML? It's a declarative way to build JavaFX interfaces using XML. FXMLs declare elements using XML and you can relate it to a controller that will handle the view for you. The controller can have the view elements injected where you will be able to retrie...

Showing Object Properties in a TableView

This post is not to talk about any specific app but to show a simple How-To with TableView.  Show values in a table in JavaFX is easy. You can show an object property with a few lines of code since we have classes that allows you to produce cells that read directly from the object. For example, let's say we have a class Person that contains two properties: public class Person { private String name; private int id; //getters, setters.. } If you want to create to columns to show the id and name properties, you need to create two columns and inform each column a PropertyValueFactory object instance: TableView tableView = new TableView (); TableColumn idColumn = new TableColumn ("Id"); idColumn.setCellValueFactory(new PropertyValueFactory ("id")); TableColumn nameColumn = new TableColumn ("Name"); nameColumn.setCellValueFactory(new PropertyValueFactory ("name")); tableView.getColumns().addAll(idColumn, nameColumn); Let's ...