2012-10-10 3 views
0

이 코드를 테스트하려고하는데 문제가 있습니다. 기본 JavaFX 플랫폼이있는 netbeans 있습니다. enter image description hereJavaFX에서 오류 받기

이 예는이 웹 사이트에서입니다 : http://onjava.com/pub/a/onjava/2007/07/27/introduction-to-javafx-script.html?page=4

 package captureexample1; 


import java.io.*; 
import javafx.ui.*; 
    import javafx.ui.canvas.*; 
import javafx.ui.filter.*; 
import java.awt.Robot; 
import java.awt.Rectangle; 
import java.awt.image.RenderedImage; 
import javax.imageio.ImageIO; 
import java.lang.System; 
    class CaptureExample extends CompositeNode{ 
    attribute lx: Integer; 
    attribute ly: Integer; 
    operation CaptureExample(); 
    } 
    attribute CaptureExample.lx = 0; 
    attribute CaptureExample.ly = 0; 
    operation saveCapture(lx_copy:Integer, ly_copy:Integer) { 
    var robot = new Robot(); 
    var rect = new Rectangle (lx_copy, ly_copy, 50, 50); 
    var BI=robot.createScreenCapture(rect); 
    var file = new File(".//capture.jpg"); 
    ImageIO.write((RenderedImage)BI, "jpg", file); 
    } 
    function CaptureExample.composeNode() = 
    Group{ 
    transform: [] 
    content:[ImageView { 
    transform: [] 
     image: Image { url: ".//app//Sunset.gif" } 
     cursor: DEFAULT 
    onMouseClicked: operation(e:CanvasMouseEvent) { 
    saveCapture(e.source.XOnScreen,e.source.YOnScreen); 
    } 
     onMouseMoved: operation(e:CanvasMouseEvent) { 
     lx = e.x; 
     ly = e.y; 
     } 
    }, 
     Rect{ 
    x: bind lx 
    y: bind ly 
    width: 50 
    height:50 
    strokeWidth: 1 
    stroke: black 
    }] 
    }; 
    Frame { 
    centerOnScreen: true 
    visible: true 
    height: 230 
    width: 300 
    title: "Capture the screen..." 
    onClose: operation() {System.exit(0);} 
     content: ScrollPane { 
    background: white 
    view: Canvas { 
     background: black 
     cursor: DEFAULT 
     content: CaptureExample 
      } 
     } 
      } 

답변

2

그것은 당신이 자바 FX 스크립트와 JavaFX2을 혼합하는 것 같다.

은 : 6.1

  • 처럼

    • 나이가 넷빈즈를 얻을 수의 이름을 변경하면 .java 파일 .fx

    하지만 JavaFX를 배우려고하면 JavaFX 2를 사용하는 것이 좋습니다.