Dukascopy
 
 
Wiki JStore Search Login

FXML deinit
 Post subject: FXML deinit Post rating: 0   New post Posted: Fri 14 Sep, 2018, 22:28 

User rating: 0
Joined: Fri 14 Sep, 2018, 22:20
Posts: 2
Location: United KingdomUnited Kingdom
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 254 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: FXML deinit Post rating: 0   New post Posted: Wed 19 Sep, 2018, 08:18 

User rating: 0
Joined: Fri 14 Sep, 2018, 22:20
Posts: 2
Location: United KingdomUnited Kingdom
Anyone dealt with this?


 

Jump to:  

  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com