前景提要
HDC调试需求开发(15万预算),能者速来!>>>
项目结构
Controller.java代码: import javafx.fxml.FXML; import javafx.scene.control.ListView; public class Controller { @FXML private ListView<String> listView; }
Main.java import cn.lsj.musicplayer.util.AudioFilePlayer; import javafx.application.Application; import javafx.event.EventHandler; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.stage.WindowEvent; public class Main extends Application { @Override public void start(Stage primaryStage) throws Exception{ Parent root = FXMLLoader.load(getClass().getResource("sample.fxml")); primaryStage.setTitle("音乐播放器"); Scene scene = new Scene(root, 1250, 750); primaryStage.setResizable(false);//固定窗口大小 primaryStage.setScene(scene); scene.getStylesheets().add(Main.class.getResource("style.css").toExternalForm()); primaryStage.show(); //窗口关闭事件监听 primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { AudioFilePlayer.stopPlaying(); } }); } public static void main(String[] args) { launch(args); } }