Results 1 to 3 of 3
  1. #1
    rcbandit is offline Member
    Join Date
    Aug 2011
    Posts
    16
    Rep Power
    0

    Default How to rewrite this code for JavaFX 2.2

    Can you help me to rewrite this source code for JavaFX 2.2

    Source Use Growl in JavaFX - bluepapa32”Ēs Java Blog

    Java FX Code:
    import java.lang.Thread;
    
    import javafx.async.Task;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.Label;
    import javafx.scene.control.ProgressBar;
    import javafx.scene.layout.HBox;
    import javafx.scene.layout.LayoutInfo;
    import javafx.scene.layout.VBox;
    import javafx.stage.Stage;
    
    import com.bluepapa32.async.ActionTask;
    import com.bluepapa32.async.ProgressTask;
    
    import net.sf.libgrowl.Application;
    import net.sf.libgrowl.GrowlConnector;
    import net.sf.libgrowl.Notification;
    import net.sf.libgrowl.NotificationType;
    
            
    var task: Task;
    
    Stage {
      title: "Use Growl in Javafx"
      width: 260
      height: 100
      scene: Scene {
        content: VBox {
          translateX: 10, translateY: 10
          spacing: 10
          content: [
            HBox {
              spacing: 5
              content:[
                ProgressBar {
                    progress: bind task.percentDone / 100
                    layoutInfo: LayoutInfo { width: 200 }
                }
                Label { text: bind "{task.percentDone as Integer} %"; }
              ]
            }
            HBox {
              spacing: 10
              content: [
                Button { text: "Start",  action: start,  disable: bind started() }
                Button { text: "Cancel", action: cancel, disable: bind not started() }
              ]
            }
          ]
        }
      }
    }
    
    function start(): Void {
        task = ProgressTask { task: GrowlTask {} }
        task.start();
    }
    
    function cancel(): Void {
        task.stop();
    }
    
    bound function started(): Boolean {
        task.started and not task.stopped and not task.done
    }
    
    class GrowlTask extends ActionTask {
    
        def COMPLETE = new NotificationType("COMPLETE", "Sample Complete");
    
        init {
    
            var application = new Application("Growl on JavaFX");
            application.setIcon("http://duke.kenai.com/iconSized/duke.gif");
    
            var growl = new GrowlConnector();
            growl.register(application, [ COMPLETE ]);
    
            action = function() {
                this.progress = 0;
                this.maxProgress = 100;
                for (progress in [1..100]) {
                    Thread.sleep(50);
                    this.progress = progress;
                }
            }
            onDone = function() {
                growl.notify(new Notification(
                                    application, COMPLETE,
                                    "Hello, World!!", "My name is Duke!"));
            }
        }
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: How to rewrite this code for JavaFX 2.2

    Quote Originally Posted by rcbandit View Post
    Can you help me to rewrite this source code for JavaFX 2.2
    Sure.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: How to rewrite this code for JavaFX 2.2

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. JavaFX Book | Learn JavaFX More In Depth
    By SnakeDoc in forum JavaFX
    Replies: 0
    Last Post: 05-17-2013, 11:10 PM
  2. help me rewrite my long code.
    By Nes_java in forum New To Java
    Replies: 1
    Last Post: 04-15-2011, 12:52 AM
  3. JavaFX Script and JavaFX Mobile
    By levent in forum Java Software
    Replies: 1
    Last Post: 01-27-2010, 04:48 PM
  4. How to rewrite this as applet?
    By tpname in forum Java Applets
    Replies: 3
    Last Post: 01-01-2010, 06:19 PM
  5. rewrite mousedown code
    By brahms666 in forum New To Java
    Replies: 0
    Last Post: 11-26-2008, 01:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •