See which of your colleagues or former colleagues are already on Java Link: Check out the Contact Finder
News »Browse Articles » Intro to JavaFX - Dummy Chess
0
Vote Vote

Intro to JavaFX - Dummy Chess

Views 0 Views    Comments 0 Comments    Share Share    Posted 12-09-2009  
Introduction

Sun recently released a new programming language for the Java platform called JavaFX. It`s primary purpose is to make it easier to develop rich internet applications (RIAs) that can run on a variety of devices including PCs, mobile phones, and Blu-ray players. It is most often compared to the new RIA languages from Microsoft (Silverlight) and Adobe (AIR). JavaFX is not limited to creating RIAs. In this article, I develop a Chess application that runs on the desktop. I call it dummy chess because the algorithm I used just selects a move at random. So if you can`t beat this chess program, then you are a worse player than me. And that`s pretty bad. Perhaps one day I`ll write a better chess playing program and post an article called smart chess.
Background

I have been programming in Java for over 5 years and recently decided to teach myself JavaFX. I figured the best way to learn JavaFX would be to assign myself a programming project on a topic I`m interested in and to complete the project in the new language. So over the course of about a month I wrote a Chess program written in JavaFX. This article describes my learning experience and introduces the basics of programming in JavaFX.

I was expecting JavaFX to be just like Java only with a new set of framework classes to learn. I was wrong. JavaFX is an entirely different programming language. In order to help the experienced Java programmers who are reading this article, I have put in some code translations from JavaFX to Java to help you better understand the sample JavaFX code posted in this article.
Using the Code

I use IDEs at work (Eclipse and Visual Studio) and really enjoy working with them. For this project, however, I decided not to use an IDE. I like working on my VI skills whenever I can. The following list describes the downloads that you will need depending on whether you are using the command line or an IDE:

* In order to build the Chess program from the command line, you must download the JavaFX 1.1 SDK.
* If you prefer to work in an IDE, you can download the NetBeans IDE 6.5 for JavaFX 1.1.
* If you prefer Eclipse to NetBeans, there is a plugin available.
* In order to convert SVG to JavaFX graphics, you also need to download the JavaFX 1.1 Production Suite.

All of these downloads are available from javafx.com except for the Eclipse plugin which is available from kenai.com. I have never used NetBeans or Eclipse to build a JavaFX program, so I am not sure how good either of them works.

The source code files contain both Java 1.6 and JavaFX 1.1 source code files. So you will also need a Java 1.6 compiler to build the code. NetBeans and Eclipse will already come with the Java compiler, if you are building from the command line you will need to download the latest JDK from java.sun.com.

Source:
http://www.codeproject.com/KB/java/Chess_JavaFX.aspx
0
Vote  Vote
Enter your comment:
No Comments For This News

Search News

What's the News?

Post a link to something interesting from another site, or submit your own original writing for the Java community to read.

Most Popular News

Most Recent User Submitted News