Example usage for javafx.stage Stage iconifiedProperty

List of usage examples for javafx.stage Stage iconifiedProperty

Introduction

In this page you can find the example usage for javafx.stage Stage iconifiedProperty.

Prototype

public final ReadOnlyBooleanProperty iconifiedProperty() 

Source Link

Usage

From source file:eu.over9000.skadi.ui.MainWindow.java

@Override
public void start(final Stage stage) throws Exception {
    this.stage = stage;

    this.detailPane = new ChannelDetailPane(this);

    this.bp = new BorderPane();
    this.sp = new SplitPane();
    this.sb = new StatusBar();

    this.setupTable();
    this.setupToolbar(stage);

    this.sp.getItems().add(this.table);

    this.bp.setTop(this.tb);
    this.bp.setCenter(this.sp);
    this.bp.setBottom(this.sb);

    final Scene scene = new Scene(this.bp, 1280, 720);
    scene.getStylesheets().add(this.getClass().getResource("/styles/copyable-label.css").toExternalForm());
    scene.setOnDragOver(event -> {/*from   w  w  w .  ja va2 s . c  o m*/
        final Dragboard d = event.getDragboard();
        if (d.hasUrl() || d.hasString()) {
            event.acceptTransferModes(TransferMode.COPY);
        } else {
            event.consume();
        }
    });
    scene.setOnDragDropped(event -> {
        final Dragboard d = event.getDragboard();
        boolean success = false;
        if (d.hasUrl()) {
            final String user = StringUtil.extractUsernameFromURL(d.getUrl());
            if (user != null) {
                success = this.channelHandler.addChannel(user, this.sb);
            } else {
                this.sb.setText("dragged url is no twitch stream");
            }
        } else if (d.hasString()) {
            success = this.channelHandler.addChannel(d.getString(), this.sb);
        }
        event.setDropCompleted(success);
        event.consume();

    });

    stage.setTitle("Skadi");
    stage.getIcons().add(new Image(this.getClass().getResourceAsStream("/icons/skadi.png")));
    stage.setScene(scene);
    stage.show();

    stage.iconifiedProperty().addListener((obs, oldV, newV) -> {
        if (this.currentState.isMinimizeToTray()) {
            if (newV) {
                stage.hide();
            }
        }
    });
    stage.setOnCloseRequest(event -> Platform.exit());

    this.bindColumnWidths();

}