/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package fsstestcase; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.util.logging.Level; import java.util.logging.Logger; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.*; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; import javax.jnlp.FileSaveService; import javax.jnlp.ServiceManager; /** * * @author Imperia AG */ public class FSSTestCase extends Application { private final static Logger logger = Logger.getLogger(FSSTestCase.class.getName()); /** * @param args the command line arguments */ public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { primaryStage.setTitle("FSS Test"); Button btn = new Button(); btn.setText("Save File!"); btn.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { try { FileSaveService fileSaveService = (FileSaveService) ServiceManager.lookup("javax.jnlp.FileSaveService"); ByteArrayOutputStream os = new ByteArrayOutputStream(); os.write(10); InputStream imageInputStream = new ByteArrayInputStream(os.toByteArray()); //Save the image using the JNLP FileSaveService String[] extenstions = {"png"}; fileSaveService.saveFileDialog(null, extenstions, imageInputStream, "name.png"); } catch(Exception e) { logger.log(Level.WARNING, e.toString(), e); } } }); TextField tf = new TextField("I loose my text cursor as soon as you click on the cancel button in the Security Dialog! Only Alt+Tab can bring it back to me!"); Accordion accordion = new Accordion(); TitledPane pane1 = new TitledPane("Pane 1", new Label("Content 1")); accordion.getPanes().add(pane1); accordion.getPanes().add(new TitledPane("Pane 2", new Label("Content 2"))); accordion.setExpandedPane(pane1); VBox root = new VBox(); root.setSpacing(5); root.setAlignment(Pos.CENTER); root.getChildren().add(btn); root.getChildren().add(tf); root.getChildren().add(accordion); primaryStage.setScene(new Scene(root, 300, 400)); primaryStage.show(); } }