0 Replies Latest reply on Dec 2, 2012 2:31 AM by 977433

    JavaFX2 Application - Wall Board News Ticker (General assistance request)


      I'm a newcomer to java 7 and javafx, I'm teaching myself and really enjoying working with and through the api's on offer. I work on a service desk and started to develop a means of communicating important news items to our team when they occur, sort of like news flash items that the whole team can see by displaying it using the wall board monitor. We do use Office communicator and email, but with some much going on, its easy to ignore.

      This is what I have so far, most of which has been pulled from the detailed tutorials available,my own knowledge and of course Google:
      package canvastestfx;
      import java.awt.Dimension;
      import java.awt.Toolkit;
      import javafx.animation.KeyFrame;
      import javafx.animation.KeyValue;
      import javafx.animation.Timeline;
      import javafx.application.Application;
      import javafx.application.Platform;
      import javafx.scene.Group;
      import javafx.scene.Scene;
      import javafx.scene.canvas.Canvas;
      import javafx.scene.canvas.GraphicsContext;
      import javafx.scene.paint.Color;
      import javafx.scene.text.Font;
      import javafx.scene.text.FontSmoothingType;
      import javafx.scene.text.Text;
      import javafx.stage.Stage;
      import javafx.stage.StageStyle;
      import javafx.util.Duration;
      public class CanvasTestFX extends Application {
          private double textXPos;
          private double textYPos;
          private double textSize;
          private Toolkit tk;
          private Dimension screenDimension;
          private String stringToDisplay;
          private Text text;
          private Canvas canvas;
          private GraphicsContext canvasgc;
          public void init(){
              tk = Toolkit.getDefaultToolkit();
              screenDimension = tk.getScreenSize();
              stringToDisplay = "Text to display";
              text = new Text(stringToDisplay);
              textSize = 60.00;
              text.setFont(Font.font("Verdana", textSize));
              textXPos = screenDimension.getWidth();
              textYPos = textSize;
          public void start(Stage primaryStage) {
              primaryStage.setTitle("JavaFX 2 Canvas Test");
              Group root = new Group();
              canvas = new Canvas(screenDimension.getWidth(), textSize+10);
              canvasgc = canvas.getGraphicsContext2D();
              canvasgc.fillRect(0, 0, canvas.getWidth(), canvas.getHeight());
              primaryStage.setScene(new Scene(root));
          private void Animate(){
              final Timeline timeline = new Timeline();
              final KeyValue keyvalue = new KeyValue(text.xProperty(), screenDimension.getWidth()-screenDimension.getWidth()-text.getBoundsInLocal().getWidth());
              final KeyFrame keyframe = new KeyFrame(Duration.millis(10000), keyvalue);
          public void stop()
          public static void main(String[] args) {
      It seems to work quite well, except after a couple of cycles, the text starts to skip forward a few pixels, before normalising again and I'm not sure why this is. Also, if I set the stage style to StageStyle.UTILITY, it tends to stabilise it further. I don't really want the frame or decoration around the ticker as we have other information below where the ticker will be displayed, such as calls waiting and abandon rate graphs (which I'll be looking to convert to java aswell, runs with VB from an excel doc at the moment).

      In addition, I'm looking at a way to network this application, create a client GUI which will reside on the team leaders machine so she can use it to change the text displayed on the wallboard machine.

      Any and all suggestions/comments on the above code with regard to improvement would be most welcome as would suggestions or pointers on how's best to network this application.