Tuesday, 6 August 2013

My First JavaFX Radial Gauge


public class MyFirstRadialGauge extends Application {

    @Override
    public void start(Stage primaryStage) {
//primaryStage.initStyle(StageStyle.TRANSPARENT);
Marker temperature = new Marker(50, Color.MAGENTA);
Marker[] markerList = new Marker[]{temperature};

Gauge radial = GaugeBuilder.create()
                           .prefWidth(500)
                           .prefHeight(500)
                           .gaugeType(GaugeBuilder.GaugeType.RADIAL)
                           .frameDesign(Gauge.FrameDesign.STEEL)
                             

...
                           .title("Temperature")
                           .unit("°C")
                           .build();
       
        StackPane root = new StackPane();
        root.getChildren().add(radial);
        radial.setLcdValue(10.00);
        radial.setLcdDecimals(2);
        radial.setLcdUnitVisible(false);    
       
        temperature.setValue(30);
       
        Scene scene = new Scene(root, 500, 500);
       
        primaryStage.setTitle("My First Radial Gauge");
        primaryStage.setScene(scene);
        primaryStage.show();
    }


References

http://harmoniccode.blogspot.ro/2012/06/jfxtras-series-radial-gauge.html 

http://grepcode.com/snapshot/repo1.maven.org/maven2/org.jfxtras/jfxtras-labs/2.2-r5/ 

Monday, 5 August 2013

Programming a JavaFX Web Service Client using NetBeans IDE 7.3

1. File -> New Project -> JavaFX -> JavaFX Application
    Project Name: JavaFXWebClient
    Finish

2. Right click JavaFXWebClient in Projects window  and select New -> Web Service Client
   (You need to have Java EE plugin installed. This is available in Tools -> Plugins.)
   WSDL URL: http://www.webservicex.net/stockquote.asmx?WSDL

3. Right click in source editor window -> Insert  Code -> Call Web Service Operation
    This automatically adds method definitions corresponding to Web service calls, for example the following piece of code:

private static String getQuote(java.lang.String symbol) {
        net.webservicex.StockQuote service = new net.webservicex.StockQuote();
        net.webservicex.StockQuoteSoap port = service.getStockQuoteSoap();
        return port.getQuote(symbol);
    }


4. Write your JavaFX Web service client using the methods defined in the previous step.

public class JavaFXWebClient extends Application {
   
    Label quoteLbl = new Label();
    TextField textFld = new TextField();
    Button btn = new Button();
   
    @Override
    public void start(Stage primaryStage) {
        btn.setText("Get IBM Quote");
        btn.setOnAction(new EventHandler() {
            @Override
            public void handle(ActionEvent event) {
                quoteLbl.setText(getQuote("IBM"));
                textFld.setText(getQuote("IBM"));
            }
        });
       
        Group root = new Group();
        root.getChildren().add(0,btn);
        root.getChildren().add(1,quoteLbl);
        root.getChildren().add(2,textFld);
       
        root.getChildren().get(0).setLayoutX(50);              
        root.getChildren().get(0).setLayoutY(70);      
        root.getChildren().get(1).setLayoutX(50);      
        root.getChildren().get(1).setLayoutY(10);
        root.getChildren().get(2).setLayoutX(50);      
        root.getChildren().get(2).setLayoutY(40);
       
        Scene scene = new Scene(root, 700, 250);
       
        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        primaryStage.show();
    }


References

http://lehelsipos.blogspot.ro/2012/09/javafx-22-webservice-example.html

http://www.actionscript.org/forums/showthread.php3?t=70742

https://netbeans.org/kb/docs/websvc/jax-ws.html

https://netbeans.org/kb/docs/websvc/intro-ws.html