Dukascopy Support Board
http://www.dukascopy.com/swiss/english/forex/jforex/forum/

FXML deinit
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=200&t=56712
Page 1 of 1

Author:  oGV1lQEG [ Fri 14 Sep, 2018, 22:28 ]
Post subject:  FXML deinit

This example runs fine only once, but if you run it again FXML doesn't work, you need to restart JFOREX for it to work again.

What am I missing here?

package jforex.guitests;

import javax.swing.*;
import com.dukascopy.api.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

// FXML
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public class FXML implements IStrategy {   
    private IUserInterface userInterface;
    private final String tabName = "FXML Test";

    public void onStart(IContext context) throws JFException {
        this.userInterface = context.getUserInterface();
        JPanel myTab; myTab = userInterface.getBottomTab(tabName);

        final JButton btn = new JButton("Test Button");
        myTab.add(btn);

        // FXML
        final JFXPanel fxPanel = new JFXPanel();
        myTab.add(fxPanel);

        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                initFX(fxPanel);
            }
        });
        // FXML

    }

    // FXML
    private static void initFX(JFXPanel fxPanel) {
        // This method is invoked on JavaFX thread
        Scene scene = createScene();
        fxPanel.setScene(scene);
    }

    private static Scene createScene() {
        Group  root  =  new  Group();
        Scene  scene  =  new  Scene(root, Color.BLUE);
        Text  text  =  new  Text();
       
        text.setX(40);
        text.setY(100);
        text.setFont(new Font(25));
        text.setText("Welcome JavaFX!");

        root.getChildren().add(text);

        return (scene);
    }
    // FXML


    public void onTick(Instrument instrument, ITick tick) throws JFException {
    }

    public void onStop() throws JFException {
       
        userInterface.removeBottomTab(tabName);
    }

    public void onAccount(IAccount account) throws JFException {
    }

    public void onMessage(IMessage message) throws JFException {
    }

    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
    }


}

Image

Attachments:
Screenshot from 2018-09-14 22-27-35.png [8.62 KiB]
Downloaded 263 times

Author:  oGV1lQEG [ Wed 19 Sep, 2018, 08:18 ]
Post subject:  Re: FXML deinit

Anyone dealt with this?

  Page 1 of 1