Search in sources :

Example 1 with JFXPanel

use of javafx.embed.swing.JFXPanel in project L42 by ElvisResearchGroup.

the class Frame method createNew.

private static Frame createNew(String wName, String html, int x, int y) {
    FutureTask<Frame> future = new FutureTask<>(() -> {
        final Frame frame = new Frame(Frame.extractTitle(html));
        JFXPanel jfxPanel = new JFXPanel();
        frame.createHtmlContent(jfxPanel, html);
        frame.getContentPane().add(jfxPanel);
        frame.setMinimumSize(new Dimension(x, y));
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        frame.addWindowListener(new WindowAdapter() {

            public void windowClosing(WindowEvent e) {
                Frame.close(wName);
            }
        });
        frame.setVisible(true);
        return frame;
    });
    SwingUtilities.invokeLater(future);
    try {
        return future.get();
    } catch (ExecutionException e) {
        throw propagateException(e.getCause());
    } catch (InterruptedException e) {
        throw propagateException(e);
    }
}
Also used : JFrame(javax.swing.JFrame) JFXPanel(javafx.embed.swing.JFXPanel) FutureTask(java.util.concurrent.FutureTask) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with JFXPanel

use of javafx.embed.swing.JFXPanel in project jabref by JabRef.

the class EntryEditor method addSpecialTabs.

private void addSpecialTabs() {
    // MathSciNet Review
    entry.getField(FieldName.MR_NUMBER).flatMap(MathSciNetId::parse).ifPresent(mrNumber -> {
        JFXPanel reviewPane = new JFXPanel();
        tabbed.addTab(Localization.lang("MathSciNet Review"), reviewPane);
        tabs.add(reviewPane);
        Platform.runLater(() -> {
            StackPane root = new MathSciNetPaneView(mrNumber).getPane();
            reviewPane.setScene(new Scene(root));
        });
    });
}
Also used : JFXPanel(javafx.embed.swing.JFXPanel) Scene(javafx.scene.Scene) StackPane(javafx.scene.layout.StackPane)

Example 3 with JFXPanel

use of javafx.embed.swing.JFXPanel in project BlocklyArduinoIDEPlugin by technologiescollege.

the class BlocklyArduinoPlugin method initGUI.

private void initGUI() {
    window = new JFrame();
    window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    window.setLayout(new BorderLayout());
    window.setSize(1024, 768);
    window.setLocationRelativeTo(null);
    window.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            SwingUtilities.invokeLater(() -> {
                Platform.runLater(() -> {
                    // browser.webEngine.load("about:blank");
                    SwingUtilities.invokeLater(() -> {
                        // System.out.println("test");
                        try {
                            e.getWindow().dispose();
                        } catch (NullPointerException ex) {
                        // System.out.println("This is a bug in java: https://bugs.openjdk.java.net/browse/JDK-8089371");
                        }
                    });
                });
            });
        }
    });
    jfxPanel = new JFXPanel();
    jfxPanel.setPreferredSize(new Dimension(JFXPANEL_WIDTH_INT, JFXPANEL_HEIGHT_INT));
    window.add(jfxPanel, BorderLayout.CENTER);
    window.setVisible(true);
    Platform.runLater(() -> {
        showBrowser();
    });
}
Also used : JFXPanel(javafx.embed.swing.JFXPanel) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension)

Example 4 with JFXPanel

use of javafx.embed.swing.JFXPanel in project BlocklyArduinoIDEPlugin by technologiescollege.

the class StartupApplet method init.

@Override
public void init() {
    BlocklyArduinoPlugin.startTimestamp = System.currentTimeMillis();
    fxContainer = new JFXPanel();
    fxContainer.setPreferredSize(new Dimension(JFXPANEL_WIDTH_INT, JFXPANEL_HEIGHT_INT));
    add(fxContainer, BorderLayout.CENTER);
    Platform.setImplicitExit(false);
    Runnable activeRunnable = new Runnable() {

        @Override
        public void run() {
            createScene();
        }
    };
    Platform.runLater(activeRunnable);
}
Also used : JFXPanel(javafx.embed.swing.JFXPanel) Dimension(java.awt.Dimension)

Example 5 with JFXPanel

use of javafx.embed.swing.JFXPanel in project osumer by mob41.

the class Main method runUi.

private static void runUi(Config config, String[] args, ArgParser ap) {
    if (!SockThread.testPortFree(SockThread.PORT)) {
        // osumer to work
        try {
            Socket socket = new Socket(InetAddress.getLoopbackAddress().getHostName(), SockThread.PORT);
            socket.setSoTimeout(5000);
            PrintWriter writer = new PrintWriter(socket.getOutputStream());
            writer.println("RUN " + buildArgStr(args));
            writer.flush();
            BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            String line = reader.readLine();
            if (line == null || !line.equals("OK")) {
                reader.close();
                socket.close();
                System.out.println("Not OK: " + line);
                DebugDump dump = new DebugDump(null, null, "Asking BG osumer to run with args: \"" + buildArgStr(args) + "\"", null, false, "Could not start up BG osumer sucessfully. Destination did not response \"OK\": " + line);
                DumpManager.getInstance().addDump(dump);
                ErrorDumpDialog dialog = new ErrorDumpDialog(dump);
                dialog.setModal(true);
                dialog.setVisible(true);
                return;
            }
            reader.close();
            socket.close();
            System.exit(0);
            return;
        } catch (IOException e) {
            e.printStackTrace();
            DebugDump dump = new DebugDump(null, null, "Opening connection to BG osumer socket", null, "Could not open socket at 46725 for BG call. Not osumer running at that port?", false, e);
            DumpManager.getInstance().addDump(dump);
            ErrorDumpDialog dialog = new ErrorDumpDialog(dump);
            dialog.setModal(true);
            dialog.setVisible(true);
            System.exit(-1);
            return;
        }
    } else {
        String urlStr = null;
        for (int i = 0; i < args.length; i++) {
            if (Osums.isVaildBeatMapUrl(args[i])) {
                urlStr = args[i];
                break;
            }
        }
        boolean runUi = true;
        if (args.length > 0 && urlStr == null && !ap.isDaemonFlag()) {
            if (config.isSwitchToBrowserIfWithoutUiArg()) {
                System.out.println("Configuration specified that switch to browser if an \"-ui\" arugment wasn't specified.");
                if (runUi = ap.isUiFlag() && !ap.isNoUiFlag()) {
                    System.out.println("An \"-ui\" argument was specified. Launching UI.");
                } else {
                    System.out.println("An \"-ui\" argument wasn't specified. Opening the default browser instead.");
                    runBrowser(config, args);
                    return;
                }
            } else {
                System.out.println("Non-beatmap URL detected.");
                if (!config.isAutoSwitchBrowser()) {
                    System.out.println("Auto switch to default browser is off. Nothing to do with such URL.");
                    return;
                } else {
                    System.out.println("Switching to default browser with the URL.");
                    runBrowser(config, args);
                }
            }
        }
        // Initialize JFX toolkit
        new JFXPanel();
        TrayIcon icon = new TrayIcon(Toolkit.getDefaultToolkit().getImage(UIFrame.class.getResource("/com/github/mob41/osumer/ui/osumerIcon_16px.png")));
        UIFrame frame = new UIFrame(config, new QueueManager(config), icon);
        if (ap.isDaemonFlag()) {
            if (!SystemTray.isSupported()) {
                JOptionPane.showMessageDialog(null, "Your operating system does not support System Tray.\nAs a result, you are not able to start osumer from the tray.", "Warning", JOptionPane.WARNING_MESSAGE);
                return;
            }
            frame.setDaemonMode(true);
            SystemTray tray = SystemTray.getSystemTray();
            icon.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent arg0) {
                    frame.setVisible(!frame.isVisible());
                    if (!frame.isVisible()) {
                        icon.displayMessage("osumer2", "osumer2 is now running in background.", TrayIcon.MessageType.INFO);
                    }
                }
            });
            icon.setToolTip("osumer2");
            try {
                tray.add(icon);
                icon.displayMessage("osumer2", "osumer2 is now running in background.", TrayIcon.MessageType.INFO);
            } catch (AWTException e) {
                e.printStackTrace();
                JOptionPane.showMessageDialog(null, "Error when adding tray icon: " + e + "\nAs a result, you are not able to start osumer from the tray.", "Warning", JOptionPane.WARNING_MESSAGE);
                return;
            }
        } else {
            frame.setVisible(true);
            new Thread() {

                public void run() {
                    JOptionPane.showMessageDialog(frame, "The osumer2 daemon (background process) is not running.\nThis might slow down further osumerExpress downloads.\nNow this process is listening for more queues till it is stopped.\n\nPlease check \"Help\" for more details.", "Warning", JOptionPane.WARNING_MESSAGE);
                }
            }.start();
        }
        if (urlStr != null) {
            frame.addBtQueue(urlStr, false);
        }
    }
}
Also used : JFXPanel(javafx.embed.swing.JFXPanel) InputStreamReader(java.io.InputStreamReader) ErrorDumpDialog(com.github.mob41.osumer.ui.ErrorDumpDialog) SystemTray(java.awt.SystemTray) ActionEvent(java.awt.event.ActionEvent) UIFrame(com.github.mob41.osumer.ui.UIFrame) IOException(java.io.IOException) QueueManager(com.github.mob41.osumer.io.queue.QueueManager) SockThread(com.github.mob41.osumer.sock.SockThread) ActionListener(java.awt.event.ActionListener) TrayIcon(java.awt.TrayIcon) BufferedReader(java.io.BufferedReader) DebugDump(com.github.mob41.organdebug.DebugDump) Socket(java.net.Socket) PrintWriter(java.io.PrintWriter) AWTException(java.awt.AWTException)

Aggregations

JFXPanel (javafx.embed.swing.JFXPanel)50 Scene (javafx.scene.Scene)16 Test (org.junit.Test)16 CountDownLatch (java.util.concurrent.CountDownLatch)11 Dimension (java.awt.Dimension)6 BorderPane (javafx.scene.layout.BorderPane)6 Stage (javafx.stage.Stage)6 FXMLLoader (javafx.fxml.FXMLLoader)5 WebView (javafx.scene.web.WebView)5 BorderLayout (java.awt.BorderLayout)4 WindowAdapter (java.awt.event.WindowAdapter)4 WindowEvent (java.awt.event.WindowEvent)4 ExecutorService (java.util.concurrent.ExecutorService)4 JFrame (javax.swing.JFrame)4 WebEngine (javafx.scene.web.WebEngine)3 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 Random (java.util.Random)2 FutureTask (java.util.concurrent.FutureTask)2 Memory (php.runtime.Memory)2 ParameterTimeManagerImpl (blue.automation.ParameterTimeManagerImpl)1