gloweffectexample.java是非项目文件,是否只报告语法错误?

s4chpxco  于 2021-07-03  发布在  Java
关注(0)|答案(0)|浏览(196)

我试图尝试其中一个教程,但我无法控制错误消息,也不知道如何修复它。vs代码给出以下错误消息:
gloweffectexample.java是非项目文件,只报告语法错误
我已经把文件放在另一个文件夹,但它不工作。也许有人能帮我。
这来自以下教程:https://www.tutorialspoint.com/javafx/glow_effect.html
这就是代码:

import javafx.application.Application; 
import javafx.scene.Group; 
import javafx.scene.Scene; 
import javafx.scene.effect.Glow; 
import javafx.scene.image.Image; 
import javafx.scene.image.ImageView; 
import javafx.stage.Stage; 

public class GlowEffectExample extends Application { 
   @Override 
   public void start(Stage stage) {               
      //Creating an image 
      Image image = new Image("http://www.tutorialspoint.com/green/images/logo.png");

      //Setting the image view 
      ImageView imageView = new ImageView(image); 

      //setting the fit width of the image view 
      imageView.setFitWidth(200);  

      //Setting the preserve ratio of the image view 
      imageView.setPreserveRatio(true);       

      //Instantiating the Glow class 
      Glow glow = new Glow(); 

      //setting level of the glow effect 
      glow.setLevel(0.9); 

      //Applying bloom effect to text 
      imageView.setEffect(glow);          

      //Creating a Group object  
      Group root = new Group(imageView);   

      //Creating a scene object 
      Scene scene = new Scene(root, 600, 300);  

      //Setting title to the Stage 
      stage.setTitle("Sample Application"); 

      //Adding scene to the stage 
      stage.setScene(scene); 

      //Displaying the contents of the stage 
      stage.show();         
   } 
   public static void main(String args[]){ 
      launch(args); 
   } 
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题