Example usage for javafx.scene.control Label Label

List of usage examples for javafx.scene.control Label Label

Introduction

In this page you can find the example usage for javafx.scene.control Label Label.

Prototype

public Label(String text) 

Source Link

Document

Creates Label with supplied text.

Usage

From source file:gov.va.isaac.gui.preferences.PreferencesViewController.java

public void aboutToShow() {
    // Using allValid_ to prevent rerunning content of aboutToShow()
    if (allValid_ == null) {
        // These listeners are for debug and testing only. They may be removed at any time.
        UserProfileBindings userProfileBindings = AppContext.getService(UserProfileBindings.class);
        for (Property<?> property : userProfileBindings.getAll()) {
            property.addListener(new ChangeListener<Object>() {
                @Override/* w ww .  j  a  va 2s . co  m*/
                public void changed(ObservableValue<? extends Object> observable, Object oldValue,
                        Object newValue) {
                    logger.debug("{} property changed from {} to {}", property.getName(), oldValue, newValue);
                }
            });
        }

        // load fields before initializing allValid_
        // in case plugin.validationFailureMessageProperty() initialized by getNode()
        tabPane_.getTabs().clear();
        List<PreferencesPluginViewI> sortableList = new ArrayList<>();
        Comparator<PreferencesPluginViewI> comparator = new Comparator<PreferencesPluginViewI>() {
            @Override
            public int compare(PreferencesPluginViewI o1, PreferencesPluginViewI o2) {
                if (o1.getTabOrder() == o2.getTabOrder()) {
                    return o1.getName().compareTo(o2.getName());
                } else {
                    return o1.getTabOrder() - o2.getTabOrder();
                }
            }
        };
        for (PreferencesPluginViewI plugin : plugins_) {
            sortableList.add(plugin);
        }
        Collections.sort(sortableList, comparator);
        for (PreferencesPluginViewI plugin : sortableList) {
            logger.debug("Adding PreferencesPluginView tab \"{}\"", plugin.getName());
            Label tabLabel = new Label(plugin.getName());

            tabLabel.setMaxHeight(Double.MAX_VALUE);
            tabLabel.setMaxWidth(Double.MAX_VALUE);
            Tab pluginTab = new Tab();
            pluginTab.setGraphic(tabLabel);
            Region content = plugin.getContent();
            content.setMaxWidth(Double.MAX_VALUE);
            content.setMaxHeight(Double.MAX_VALUE);
            content.setPadding(new Insets(5.0));

            Label errorMessageLabel = new Label();
            errorMessageLabel.textProperty().bind(plugin.validationFailureMessageProperty());
            errorMessageLabel.setAlignment(Pos.BOTTOM_CENTER);
            TextErrorColorHelper.setTextErrorColor(errorMessageLabel);

            VBox vBox = new VBox();
            vBox.getChildren().addAll(errorMessageLabel, content);
            vBox.setMaxWidth(Double.MAX_VALUE);
            vBox.setAlignment(Pos.TOP_CENTER);

            plugin.validationFailureMessageProperty().addListener(new ChangeListener<String>() {
                @Override
                public void changed(ObservableValue<? extends String> observable, String oldValue,
                        String newValue) {
                    if (newValue != null && !StringUtils.isEmpty(newValue)) {
                        TextErrorColorHelper.setTextErrorColor(tabLabel);
                    } else {
                        TextErrorColorHelper.clearTextErrorColor(tabLabel);
                    }
                }
            });
            //Initialize, if stored value is wrong
            if (StringUtils.isNotEmpty(plugin.validationFailureMessageProperty().getValue())) {
                TextErrorColorHelper.setTextErrorColor(tabLabel);
            }
            pluginTab.setContent(vBox);
            tabPane_.getTabs().add(pluginTab);
        }

        allValid_ = new ValidBooleanBinding() {
            {
                ArrayList<ReadOnlyStringProperty> pluginValidationFailureMessages = new ArrayList<>();
                for (PreferencesPluginViewI plugin : plugins_) {
                    pluginValidationFailureMessages.add(plugin.validationFailureMessageProperty());
                }
                bind(pluginValidationFailureMessages
                        .toArray(new ReadOnlyStringProperty[pluginValidationFailureMessages.size()]));
                setComputeOnInvalidate(true);
            }

            @Override
            protected boolean computeValue() {
                for (PreferencesPluginViewI plugin : plugins_) {
                    if (plugin.validationFailureMessageProperty().get() != null
                            && plugin.validationFailureMessageProperty().get().length() > 0) {
                        this.setInvalidReason(plugin.validationFailureMessageProperty().get());

                        logger.debug("Setting PreferencesView allValid_ to false because \"{}\"",
                                this.getReasonWhyInvalid().get());
                        return false;
                    }
                }

                logger.debug("Setting PreferencesView allValid_ to true");

                this.clearInvalidReason();
                return true;
            }
        };

        okButton_.disableProperty().bind(allValid_.not());
        // set focus on default
        // Platform.runLater(...);
    }

    // Reload persisted values every time view opened
    for (PreferencesPluginViewI plugin : plugins_) {
        plugin.getContent();
    }
}

From source file:fx.DownloadFxApp.java

public void createScene(Stage stage) {
    try {/*from   w w  w. j  av a2s.c  om*/
        stage.setTitle("Downloading JDK " + version + "...");

        instance.set(this);
        appStartedLatch.countDown();

        final SimpleBrowser browser = SimpleBrowser.newBuilder().useFirebug(false).useJQuery(true)
                .createWebView(!miniMode).build();

        final ProgressBar progressBar = new ProgressBar(0);
        final Label progressLabel = new Label("Retrieving a link...");

        VBox vBox = VBoxBuilder.create().children(progressLabel, progressBar, browser).fillWidth(true).build();

        Scene scene = new Scene(vBox);

        stage.setScene(scene);

        if (miniMode) {
            stage.setWidth(300);
        } else {
            stage.setWidth(1024);
            stage.setHeight(768);
        }

        stage.show();

        VBox.setVgrow(browser, Priority.ALWAYS);

        /**
         The sequence of calls
         location changed to: http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html?
         location changed to: http://download.oracle.com/otn/java/jdk/7u45-b18/jdk-7u45-linux-x64.tar.gz
         location changed to: https://edelivery.oracle.com/akam/otn/java/jdk/7u45-b18/jdk-7u45-linux-x64.tar.gz
         location changed to: https://login.oracle.com/pls/orasso/orasso.wwsso_app_admin.ls_login?Site2pstoreToken=v1.2~CA55CD32~750C6EFBC9B3CB198B2ADFE87BDD4DEB60E0218858C8BFE85DCCC65865D0E810E845839B422974847E1D489D3AF25FDC9574400197F9190C389876C1EC683A6006A06F7F05D41C94455B8354559F5699F5D0EF102F26FE905E77D40487455F7829501E3A783E1354EB0B8F05B828D0FC3BA22C62D3576883850E0B99849309B0C26F286E5650F63E9C6A7C376165C9A3EED86BF2FA0FAEE3D1F7F2957F5FBD5035AF0A3522E534141FE38DFDD55C4F7F517F9E81336C993BB76512C0D30A5B5C5FD82ED1C10E9D27284B6B1633E4B7B9FA5C2E38D9C5E3845C18C009E294E881FD8B654B67050958E57F0DC20885D6FA87A59FAA7564F94F
         location changed to: https://login.oracle.com/mysso/signon.jsp
         location changed to: https://login.oracle.com/oam/server/sso/auth_cred_submit
         location changed to: https://edelivery.oracle.com/osso_login_success?urlc=v1.2%7E30E69346FE17F27D4F83121B0B8EC362E0B315901364AAA7D6F0B7A05CD8AA31802F5A69D70C708F34C64B65D233922B57D3C31839E82CE78E5C8DA55D729DD339893285D21A8E8B1AE8557C9240D6E33C9965956E136F4CB093779F97AF67C3DB8FF19FF2A638296BD0AA81A7801904AC5607F0568B6CEAF7ED9FCE4B7BEA80071617E4B2779F60F0C76A89F7D195965D2F003F9EDD2A1ADFD264C1C4C7F921010B08D3846CEC9524237A9337B6B0BC433BB17993A670B6C913EB4CFDC217A753F9E2943DE0CBDC41D4705AC67C2B96A4892C65F5450B146939B0EBFDF098680BBBE1F13356460C95A23D8D198D1C6762E45E62F120E32C2549E6263071DA84F8321370D2410CCA93E9A071A02ED6EB40BF40EDFC6F65AC7BA73CDB06DF4265455419D9185A6256FFE41A7FF54042374D09F5C720F3104B2EAC924778482D4BE855A45B2636CE91C7D947FF1F764674CE0E42FFCCFE411AABFE07EA0E96838AFEA263D2D5A405BD
         location changed to: https://edelivery.oracle.com/akam/otn/java/jdk/7u45-b18/jdk-7u45-linux-x64.tar.gz
         location changed to: http://download.oracle.com/otn/java/jdk/7u45-b18/jdk-7u45-linux-x64.tar.gz?AuthParam=1390405890_f9186a44471784229268632878dd89e4
                
         */

        browser.getEngine().locationProperty().addListener(new ChangeListener<String>() {
            @Override
            public void changed(ObservableValue<? extends String> observableValue, String oldLoc,
                    final String uri) {
                logger.info("change: {}", uri);

                if (uri.contains("signon.jsp")) {
                    browser.getEngine().executeScript(
                            "" + "alert(document);\n" + "alert(document.getElementById('sso_username'));\n");

                    new Thread("signon.jsp waiter") {
                        @Override
                        public void run() {
                            setStatus("waiting for the login form...");

                            try {
                                Thread.sleep(1000);
                            } catch (InterruptedException e) {
                                throw Exceptions.runtime(e);
                            }

                            browser.waitFor("$('#sso_username').length > 0", 10000);

                            System.out.println("I see it all, I see it now!");

                            Platform.runLater(new Runnable() {
                                @Override
                                public void run() {
                                    browser.getEngine().executeScript(""
                                            + "alert(document.getElementById('sso_username'));\n"
                                            + "alert($('#sso_username').val('" + oracleUser + "'));\n"
                                            + "alert($('#ssopassword').val('" + oraclePassword + "'));\n"
                                            + downloadJDKJs() + "\n" + "clickIt($('.sf-btnarea a'))");
                                }
                            });
                        }
                    }.start();
                }

                if (uri.contains("download.oracle") && uri.contains("?")) {
                    // will be here after
                    // clicking accept license and link -> * not logged in * -> here -> download -> redirect to login
                    // download -> fill form -> * logged in * -> here -> download
                    Thread thread = new Thread(new Runnable() {
                        @Override
                        public void run() {
                            try {
                                DefaultHttpClient httpClient = new DefaultHttpClient();

                                HttpGet httppost = new HttpGet(uri);

                                HttpResponse response = httpClient.execute(httppost);

                                int code = response.getStatusLine().getStatusCode();

                                if (code != 200) {
                                    System.out.println(IOUtils.toString(response.getEntity().getContent()));
                                    throw new RuntimeException("failed to download: " + uri);
                                }

                                final File file = new File(tempDestDir,
                                        StringUtils.substringBefore(FilenameUtils.getName(uri), "?"));
                                HttpEntity entity = response.getEntity();

                                final long length = entity.getContentLength();

                                final CountingOutputStream os = new CountingOutputStream(
                                        new FileOutputStream(file));

                                System.out.printf("Downloading %s to %s...%n", uri, file);

                                Thread progressThread = new Thread(new Runnable() {
                                    double lastProgress;

                                    @Override
                                    public void run() {
                                        while (!Thread.currentThread().isInterrupted()) {
                                            long copied = os.getCount();

                                            double progress = copied * 100D / length;

                                            if (progress != lastProgress) {
                                                final String s = String.format("%s: %s/%s %s%%", file.getName(),
                                                        FileUtils.humanReadableByteCount(copied, false, false),
                                                        FileUtils.humanReadableByteCount(length, false, true),
                                                        LangUtils.toConciseString(progress, 1));

                                                setStatus(s);

                                                System.out.print("\r" + s);
                                            }

                                            lastProgress = progress;
                                            progressBar.setProgress(copied * 1D / length);

                                            //                                                progressProp.set(progress);

                                            try {
                                                Thread.sleep(500);
                                            } catch (InterruptedException e) {
                                                break;
                                            }
                                        }
                                    }
                                }, "progressThread");

                                progressThread.start();

                                ByteStreams.copy(entity.getContent(), os);

                                progressThread.interrupt();

                                System.out.println("Download complete.");

                                downloadResult.set(new DownloadResult(file, "", true));
                                downloadLatch.countDown();
                            } catch (Exception e) {
                                LoggerFactory.getLogger("log").warn("", e);
                                downloadResult.set(new DownloadResult(null, e.getMessage(), false));
                                throw Exceptions.runtime(e);
                            }
                        }
                    }, "fx-downloader");

                    thread.start();
                }
            }

            public void setStatus(final String s) {
                Platform.runLater(new Runnable() {
                    @Override
                    public void run() {
                        progressLabel.setText(s);
                    }
                });
            }
        });

        // links from http://www.oracle.com/technetwork/java/archive-139210.html

        Map<Integer, String> archiveLinksMap = new HashMap<Integer, String>();

        archiveLinksMap.put(5,
                "http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase5-419410.html");
        archiveLinksMap.put(6,
                "http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html");
        archiveLinksMap.put(7,
                "http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html");

        Map<Integer, String> latestLinksMap = new HashMap<Integer, String>();

        latestLinksMap.put(7,
                "http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html");

        String archiveUrl = null;
        String latestUrl = null;

        char ch = version.charAt(0);

        switch (ch) {
        case '7':
        case '6':
        case '5':
            latestUrl = latestLinksMap.get(ch - '0');
            archiveUrl = archiveLinksMap.get(ch - '0');
            break;
        default:
            archiveUrl = null;
        }

        if (latestUrl != null) {
            final String finalArchiveUrl = archiveUrl;
            tryFind(browser, latestUrl, new WhenDone() {
                @Override
                public void whenDone(boolean found) {
                    tryArchiveLink(found, finalArchiveUrl, browser);
                }
            });
        } else {
            tryArchiveLink(false, archiveUrl, browser);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:bear.fx.DownloadFxApp.java

public void createScene(Stage stage) {
    try {/*w  ww  .j  av a2s . com*/
        stage.setTitle("Downloading JDK " + version + "...");

        instance.set(this);
        appStartedLatch.countDown();

        final SimpleBrowser browser = SimpleBrowser.newBuilder().useFirebug(false).useJQuery(true)
                .createWebView(!miniMode).build();

        final ProgressBar progressBar = new ProgressBar(0);
        final Label progressLabel = new Label("Retrieving a link...");

        VBox vBox = VBoxBuilder.create().children(progressLabel, progressBar, browser).fillWidth(true).build();

        Scene scene = new Scene(vBox);

        stage.setScene(scene);

        if (miniMode) {
            stage.setWidth(300);
        } else {
            stage.setWidth(1024);
            stage.setHeight(768);
        }

        stage.show();

        VBox.setVgrow(browser, Priority.ALWAYS);

        /**
         *
         location changed to: http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html?
         location changed to: http://download.oracle.com/otn/java/jdk/7u45-b18/jdk-7u45-linux-x64.tar.gz
         location changed to: https://edelivery.oracle.com/akam/otn/java/jdk/7u45-b18/jdk-7u45-linux-x64.tar.gz
         location changed to: https://login.oracle.com/pls/orasso/orasso.wwsso_app_admin.ls_login?Site2pstoreToken=v1.2~CA55CD32~750C6EFBC9B3CB198B2ADFE87BDD4DEB60E0218858C8BFE85DCCC65865D0E810E845839B422974847E1D489D3AF25FDC9574400197F9190C389876C1EC683A6006A06F7F05D41C94455B8354559F5699F5D0EF102F26FE905E77D40487455F7829501E3A783E1354EB0B8F05B828D0FC3BA22C62D3576883850E0B99849309B0C26F286E5650F63E9C6A7C376165C9A3EED86BF2FA0FAEE3D1F7F2957F5FBD5035AF0A3522E534141FE38DFDD55C4F7F517F9E81336C993BB76512C0D30A5B5C5FD82ED1C10E9D27284B6B1633E4B7B9FA5C2E38D9C5E3845C18C009E294E881FD8B654B67050958E57F0DC20885D6FA87A59FAA7564F94F
         location changed to: https://login.oracle.com/mysso/signon.jsp
         location changed to: https://login.oracle.com/oam/server/sso/auth_cred_submit
         location changed to: https://edelivery.oracle.com/osso_login_success?urlc=v1.2%7E30E69346FE17F27D4F83121B0B8EC362E0B315901364AAA7D6F0B7A05CD8AA31802F5A69D70C708F34C64B65D233922B57D3C31839E82CE78E5C8DA55D729DD339893285D21A8E8B1AE8557C9240D6E33C9965956E136F4CB093779F97AF67C3DB8FF19FF2A638296BD0AA81A7801904AC5607F0568B6CEAF7ED9FCE4B7BEA80071617E4B2779F60F0C76A89F7D195965D2F003F9EDD2A1ADFD264C1C4C7F921010B08D3846CEC9524237A9337B6B0BC433BB17993A670B6C913EB4CFDC217A753F9E2943DE0CBDC41D4705AC67C2B96A4892C65F5450B146939B0EBFDF098680BBBE1F13356460C95A23D8D198D1C6762E45E62F120E32C2549E6263071DA84F8321370D2410CCA93E9A071A02ED6EB40BF40EDFC6F65AC7BA73CDB06DF4265455419D9185A6256FFE41A7FF54042374D09F5C720F3104B2EAC924778482D4BE855A45B2636CE91C7D947FF1F764674CE0E42FFCCFE411AABFE07EA0E96838AFEA263D2D5A405BD
         location changed to: https://edelivery.oracle.com/akam/otn/java/jdk/7u45-b18/jdk-7u45-linux-x64.tar.gz
         location changed to: http://download.oracle.com/otn/java/jdk/7u45-b18/jdk-7u45-linux-x64.tar.gz?AuthParam=1390405890_f9186a44471784229268632878dd89e4
                
         */

        browser.getEngine().locationProperty().addListener(new ChangeListener<String>() {
            @Override
            public void changed(ObservableValue<? extends String> observableValue, String oldLoc,
                    final String uri) {
                logger.info("change: {}", uri);

                if (uri.contains("signon.jsp")) {
                    browser.getEngine().executeScript(
                            "" + "alert(document);\n" + "alert(document.getElementById('sso_username'));\n");

                    new Thread("signon.jsp waiter") {
                        @Override
                        public void run() {
                            setStatus("waiting for the login form...");

                            try {
                                Thread.sleep(1000);
                            } catch (InterruptedException e) {
                                throw Exceptions.runtime(e);
                            }

                            browser.waitFor("$('#sso_username').length > 0", 10000);

                            System.out.println("I see it all, I see it now!");

                            Platform.runLater(new Runnable() {
                                @Override
                                public void run() {
                                    browser.getEngine().executeScript(""
                                            + "alert(document.getElementById('sso_username'));\n"
                                            + "alert($('#sso_username').val('" + oracleUser + "'));\n"
                                            + "alert($('#ssopassword').val('" + oraclePassword + "'));\n"
                                            + downloadJDKJs() + "\n" + "clickIt($('.sf-btnarea a'))");
                                }
                            });
                        }
                    }.start();
                }

                if (uri.contains("download.oracle") && uri.contains("?")) {
                    //will be here after
                    // clicking accept license and link -> * not logged in * -> here -> download -> redirect to login
                    // download -> fill form -> * logged in * -> here -> download
                    Thread thread = new Thread(new Runnable() {
                        @Override
                        public void run() {
                            try {
                                DefaultHttpClient httpClient = new DefaultHttpClient();

                                HttpGet httppost = new HttpGet(uri);

                                HttpResponse response = httpClient.execute(httppost);

                                int code = response.getStatusLine().getStatusCode();

                                if (code != 200) {
                                    System.out.println(IOUtils.toString(response.getEntity().getContent()));
                                    throw new RuntimeException("failed to download: " + uri);
                                }

                                final File file = new File(tempDestDir,
                                        StringUtils.substringBefore(FilenameUtils.getName(uri), "?"));
                                HttpEntity entity = response.getEntity();

                                final long length = entity.getContentLength();

                                final CountingOutputStream os = new CountingOutputStream(
                                        new FileOutputStream(file));

                                System.out.printf("Downloading %s to %s...%n", uri, file);

                                Thread progressThread = new Thread(new Runnable() {
                                    double lastProgress;

                                    @Override
                                    public void run() {
                                        while (!Thread.currentThread().isInterrupted()) {
                                            long copied = os.getCount();

                                            double progress = copied * 100D / length;

                                            if (progress != lastProgress) {
                                                final String s = String.format("%s: %s/%s %s%%", file.getName(),
                                                        FileUtils.humanReadableByteCount(copied, false, false),
                                                        FileUtils.humanReadableByteCount(length, false, true),
                                                        LangUtils.toConciseString(progress, 1));

                                                setStatus(s);

                                                System.out.print("\r" + s);
                                            }

                                            lastProgress = progress;
                                            progressBar.setProgress(copied * 1D / length);

                                            //                                                progressProp.set(progress);

                                            try {
                                                Thread.sleep(500);
                                            } catch (InterruptedException e) {
                                                break;
                                            }
                                        }
                                    }
                                }, "progressThread");

                                progressThread.start();

                                ByteStreams.copy(entity.getContent(), os);

                                progressThread.interrupt();

                                System.out.println("Download complete.");

                                downloadResult.set(new DownloadResult(file, "", true));
                                downloadLatch.countDown();
                            } catch (Exception e) {
                                LoggerFactory.getLogger("log").warn("", e);
                                downloadResult.set(new DownloadResult(null, e.getMessage(), false));
                                throw Exceptions.runtime(e);
                            }
                        }
                    }, "fx-downloader");

                    thread.start();
                }
            }

            public void setStatus(final String s) {
                Platform.runLater(new Runnable() {
                    @Override
                    public void run() {
                        progressLabel.setText(s);
                    }
                });
            }
        });

        // links from http://www.oracle.com/technetwork/java/archive-139210.html

        Map<Integer, String> archiveLinksMap = new HashMap<Integer, String>();

        archiveLinksMap.put(5,
                "http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase5-419410.html");
        archiveLinksMap.put(6,
                "http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html");
        archiveLinksMap.put(7,
                "http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html");

        Map<Integer, String> latestLinksMap = new HashMap<Integer, String>();

        latestLinksMap.put(7,
                "http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html");

        String archiveUrl = null;
        String latestUrl = null;

        char ch = version.charAt(0);

        switch (ch) {
        case '7':
        case '6':
        case '5':
            latestUrl = latestLinksMap.get(ch - '0');
            archiveUrl = archiveLinksMap.get(ch - '0');
            break;
        default:
            archiveUrl = null;
        }

        if (latestUrl != null) {
            final String finalArchiveUrl = archiveUrl;
            tryFind(browser, latestUrl, new WhenDone() {
                @Override
                public void whenDone(boolean found) {
                    tryArchiveLink(found, finalArchiveUrl, browser);
                }
            });
        } else {
            tryArchiveLink(false, archiveUrl, browser);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:de.perdian.apps.tagtiger.fx.handlers.batchupdate.UpdateFileNamesFromTagsActionEventHandler.java

private Parent createLegendPane() {

    GridPane legendPane = new GridPane();
    legendPane.setPadding(new Insets(5, 5, 5, 5));
    int columnCount = 3;
    int currentRow = 0;
    int currentColumn = 0;
    for (UpdateFileNamesPlaceholder placeholder : UpdateFileNamesPlaceholder.values()) {

        StringBuilder placeholderText = new StringBuilder();
        placeholderText.append("${").append(placeholder.getPlaceholder()).append("}: ");
        placeholderText.append(placeholder.resolveLocalization(this.getLocalization()));

        Label placeholderLabel = new Label(placeholderText.toString());
        placeholderLabel.setMaxWidth(Double.MAX_VALUE);
        placeholderLabel.setPadding(new Insets(3, 3, 3, 3));
        placeholderLabel.setAlignment(Pos.TOP_LEFT);
        legendPane.add(placeholderLabel, currentColumn, currentRow);
        GridPane.setFillWidth(placeholderLabel, Boolean.TRUE);
        GridPane.setHgrow(placeholderLabel, Priority.ALWAYS);

        currentColumn++;//w  w  w. ja  v a 2  s.  c o m
        if (currentColumn >= columnCount) {
            currentRow++;
            currentColumn = 0;
        }

    }

    TitledPane legendTitlePane = new TitledPane(this.getLocalization().legend(), legendPane);
    legendTitlePane.setCollapsible(false);
    return legendTitlePane;

}

From source file:MediaControl.java

public MediaControl(final MediaPlayer mp) {
    this.mp = mp;
    setStyle("-fx-background-color: #bfc2c7;");
    mediaView = new MediaView(mp);
    Pane mvPane = new Pane() {
    };/*from   w  w w.j av a2 s.  c om*/
    mvPane.getChildren().add(mediaView);
    mvPane.setStyle("-fx-background-color: black;");
    setCenter(mvPane);
    mediaBar = new HBox();
    mediaBar.setAlignment(Pos.CENTER);
    mediaBar.setPadding(new Insets(5, 10, 5, 10));
    BorderPane.setAlignment(mediaBar, Pos.CENTER);

    final Button playButton = new Button(">");

    playButton.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent e) {
            Status status = mp.getStatus();

            if (status == Status.UNKNOWN || status == Status.HALTED) {
                // don't do anything in these states
                return;
            }

            if (status == Status.PAUSED || status == Status.READY || status == Status.STOPPED) {
                // rewind the movie if we're sitting at the end
                if (atEndOfMedia) {
                    mp.seek(mp.getStartTime());
                    atEndOfMedia = false;
                }
                mp.play();
            } else {
                mp.pause();
            }
        }
    });
    mp.currentTimeProperty().addListener(new InvalidationListener() {
        public void invalidated(Observable ov) {
            updateValues();
        }
    });

    mp.setOnPlaying(new Runnable() {
        public void run() {
            if (stopRequested) {
                mp.pause();
                stopRequested = false;
            } else {
                playButton.setText("||");
            }
        }
    });

    mp.setOnPaused(new Runnable() {
        public void run() {
            System.out.println("onPaused");
            playButton.setText(">");
        }
    });

    mp.setOnReady(new Runnable() {
        public void run() {
            duration = mp.getMedia().getDuration();
            updateValues();
        }
    });

    mp.setCycleCount(repeat ? MediaPlayer.INDEFINITE : 1);
    mp.setOnEndOfMedia(new Runnable() {
        public void run() {
            if (!repeat) {
                playButton.setText(">");
                stopRequested = true;
                atEndOfMedia = true;
            }
        }
    });
    mediaBar.getChildren().add(playButton);
    // Add spacer
    Label spacer = new Label("   ");
    mediaBar.getChildren().add(spacer);

    // Add Time label
    Label timeLabel = new Label("Time: ");
    mediaBar.getChildren().add(timeLabel);

    // Add time slider
    timeSlider = new Slider();
    HBox.setHgrow(timeSlider, Priority.ALWAYS);
    timeSlider.setMinWidth(50);
    timeSlider.setMaxWidth(Double.MAX_VALUE);

    timeSlider.valueProperty().addListener(new InvalidationListener() {
        public void invalidated(Observable ov) {
            if (timeSlider.isValueChanging()) {
                // multiply duration by percentage calculated by slider position
                mp.seek(duration.multiply(timeSlider.getValue() / 100.0));
            }
        }
    });

    mediaBar.getChildren().add(timeSlider);

    // Add Play label
    playTime = new Label();
    playTime.setPrefWidth(130);
    playTime.setMinWidth(50);
    mediaBar.getChildren().add(playTime);

    // Add the volume label
    Label volumeLabel = new Label("Vol: ");
    mediaBar.getChildren().add(volumeLabel);

    // Add Volume slider
    volumeSlider = new Slider();
    volumeSlider.setPrefWidth(70);
    volumeSlider.setMaxWidth(Region.USE_PREF_SIZE);
    volumeSlider.setMinWidth(30);
    volumeSlider.valueProperty().addListener(new InvalidationListener() {
        public void invalidated(Observable ov) {
            if (volumeSlider.isValueChanging()) {
                mp.setVolume(volumeSlider.getValue() / 100.0);
            }
        }
    });
    mediaBar.getChildren().add(volumeSlider);
    setBottom(mediaBar);
}

From source file:org.pdfsam.ui.dashboard.about.AboutDashboardPane.java

private void addSectionTitle(String title, Pane pane) {
    Label label = new Label(title);
    label.getStyleClass().add("section-title");
    pane.getChildren().add(label);/*from  w w  w .  j  a va 2 s. c o m*/
}

From source file:com.bdb.weather.display.preferences.ColorPreferencePanel.java

public ColorPreferencePanel() {
    VBox vbox = new VBox();
    GridPane colorPanel = new GridPane();

    for (ColorPreferenceEntry entry : entries2) {
        ColorPicker colorPicker = new ColorPicker(preferences.getColorPref(entry.preferenceName));
        entry.button = colorPicker;/*from w ww. ja  v a2 s  . c o  m*/
        colorPanel.add(new Label(entry.preferenceName), 0, entry.row);
        colorPanel.add(colorPicker, 1, entry.row);
    }

    GridPane plotColorPanel = new GridPane();

    int gridx = 0;
    int gridy = 0;

    //
    // Layout the column headers
    //
    for (int i = 0; i < COLOR_COL_HEADERS.length; i++) {
        gridx = i;
        plotColorPanel.add(new Label(COLOR_COL_HEADERS[i]), gridx, gridy);
    }

    //
    // Layout the row leaders
    //
    //c.anchor = GridBagConstraints.EAST;
    for (String header : COLOR_ROW_HEADERS) {
        gridx = 0;
        gridy++;
        plotColorPanel.add(new Label(header), gridx, gridy);

        gridx = 5;

        Set<String> names = ColorSchemeCollection.getColorSchemeNames();
        ComboBox<String> scheme = new ComboBox<>();
        scheme.getItems().addAll(names);
        scheme.setUserData(gridy);
        plotColorPanel.add(scheme, gridx, gridy);
        scheme.setOnAction((ActionEvent e) -> {
            ComboBox<String> cb = (ComboBox<String>) e.getSource();
            applyColorScheme((Integer) cb.getUserData(), cb.getSelectionModel().getSelectedItem());
        });
        gridx = 6;
        CheckBox showSeries = new CheckBox();
        showSeries.setUserData(gridy);
        plotColorPanel.add(showSeries, gridx, gridy);
        showSeries.setOnAction((ActionEvent e) -> {
            CheckBox cb = (CheckBox) e.getSource();
            int row = (Integer) cb.getUserData();
            for (ColorPreferenceEntry entry : entries) {
                if (entry.row == row) {
                    addRemoveSeries(entry.preferenceName, cb.isSelected());
                }
            }
            createSeriesData();
            configureRenderer();
        });
    }

    //c.anchor = GridBagConstraints.CENTER;
    for (ColorPreferenceEntry entry : entries) {
        gridx = entry.column;
        gridy = entry.row;
        ColorPicker button = new ColorPicker();
        button.setValue(preferences.getColorPref(entry.preferenceName));
        //button.setPrefSize(10, 10);
        button.setUserData(entry);
        plotColorPanel.add(button, gridx, gridy);
        entry.button = button;
    }

    JFreeChart chart = ChartFactory.createXYLineChart("Example", "X Axis", "Y Axis", dataset,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(renderer);

    ChartViewer graphExamplePanel = new ChartViewer(chart);

    vbox.getChildren().addAll(colorPanel, plotColorPanel);
    setTop(vbox);
    setCenter(graphExamplePanel);
    FlowPane buttonPanel = new FlowPane();
    Button button = new Button("OK");
    button.setOnAction((ActionEvent e) -> {
        saveData();
    });
    buttonPanel.getChildren().add(button);
    setBottom(buttonPanel);
}

From source file:Main.java

private static Node createConfirmationPanel() {
    final Label acceptanceLabel = new Label("Not Available");

    final Button acceptButton = new Button("Accept");
    acceptButton.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(final ActionEvent event) {
            acceptanceLabel.setText("Accepted");
        }/* w ww . ja va  2  s. c o  m*/
    });

    final Button declineButton = new Button("Decline");
    declineButton.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(final ActionEvent event) {
            acceptanceLabel.setText("Declined");
        }
    });

    final HBox panel = createHBox(6, acceptButton, declineButton, acceptanceLabel);
    panel.setAlignment(Pos.CENTER_LEFT);
    configureBorder(panel);

    return panel;
}

From source file:caillou.company.clonemanager.gui.customComponent.location.LocationController.java

@Subscribe
public void showErrors(ShowErrorsEvent showErrorsEvent) {
    final List<Error> errors = this.getModel().getErrors();
    if (!errors.isEmpty()) {
        VBox vbox = new VBox();
        vbox.setSpacing(5);/*w w w  .  j a va 2s.co  m*/
        for (Error error : errors) {
            Label errorLabel = new Label(error.getMessage());
            errorLabel.getStylesheets().add(StyleSheet.LOCATION_CSS);
            if (error.getSeverityLevel()
                    .equals(caillou.company.clonemanager.gui.bean.error.Error.SEVERITY_LEVEL.ERROR)) {
                errorLabel.getStyleClass().add("error");
            } else if (error.getSeverityLevel()
                    .equals(caillou.company.clonemanager.gui.bean.error.Error.SEVERITY_LEVEL.WARNING)) {
                errorLabel.getStyleClass().add("warning");
            }

            vbox.getChildren().add(new Label(error.getMessage()));
        }
        errorPopOver.setContentNode(vbox);
        errorPopOver.show(path);
    } else {
        errorPopOver.hide();
    }
}

From source file:de.perdoctus.ebikeconnect.gui.MainWindowController.java

public void showAbout() throws IOException {
    Alert alert = new Alert(Alert.AlertType.INFORMATION);
    alert.initOwner(tabPane.getScene().getWindow());
    alert.initModality(Modality.WINDOW_MODAL);
    alert.setWidth(640);/*from w w  w . j av  a  2s  .  co m*/
    alert.setTitle(rb.getString("application-name"));
    alert.setHeaderText(rb.getString("application-name") + " Version " + rb.getString("app-version"));

    final String aboutInfo = IOUtils.toString(getClass().getResourceAsStream("/about-info.txt"), "UTF-8");
    alert.setContentText(aboutInfo);

    final String licenseInfo = IOUtils.toString(getClass().getResourceAsStream("/license-info.txt"), "UTF-8");

    final Label label = new Label(rb.getString("licenses"));
    final TextArea licenses = new TextArea(licenseInfo);
    licenses.setMaxWidth(Double.MAX_VALUE);
    licenses.setEditable(false);

    GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(licenses, 0, 1);

    alert.getDialogPane().setExpandableContent(expContent);
    alert.show();

}