Java Code Examples for javafx.embed.swing.SwingNode

The following examples show how to use javafx.embed.swing.SwingNode. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: kafka-message-tool   Source File: SwingTextAreaWrapper.java    License: MIT License 6 votes vote down vote up
public SwingTextAreaWrapper(JTextArea textArea) {
    this.textArea = textArea;
    textArea.setEditable(true);
    textArea.setFont(FONT);

    final DefaultCaret caret = (DefaultCaret) textArea.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    node = new SwingNode();
    JScrollPane sp = new JScrollPane(textArea);
    textArea.setComponentPopupMenu(popupMenu);
    node.setContent(sp);

    popupMenu.add(saveToFileMenu);

}
 
Example 2
Source Project: BowlerStudio   Source File: FirmataTab.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void initializeUI(BowlerAbstractDevice pm) {
	FirmataDevice device  =( (FirmataBowler) pm).getFirmataDevice();
	// TODO Auto-generated method stub
	JFrame frame = new JFrame("Pinboard Example");
	frame.add(new JPinboard(device  ));
	frame.pack();
	frame.setVisible(true);
	
	JPinboard pinboard = new JPinboard(device  );
	pinboard.setVisible(true);
	SwingNode sn = new SwingNode();
       sn.setContent(pinboard);
       ScrollPane s1 = new ScrollPane();
      
       s1.setContent(sn);
       setContent(s1);
       setText("Firmata Pinpoard");
	onTabReOpening();
}
 
Example 3
@Override
public void initializeUI(BowlerAbstractDevice pm) {
	NRPrinter printer = (NRPrinter)pm;
	BowlerBoardDevice delt = printer.getDeltaDevice();
	
	if (delt.isAvailable()){
		gui.setDevices(delt,printer);
	}
	if (delt.isAvailable()){
		gui.updateSettings();
	}
	
	SwingNode sn = new SwingNode();
       sn.setContent(gui);
       ScrollPane s1 = new ScrollPane();
      
       s1.setContent(sn);
       setContent(s1);
       setText("Printer Config");
	onTabReOpening();
}
 
Example 4
Source Project: mars-sim   Source File: MainScene.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
	 * Create the desktop swing node
	 */
	private void createDesktopNode() {
		// Create group to hold swingNode which in turns holds the Swing desktop
		desktopNode = new SwingNode();
		// desktopNode.setStyle("-fx-background-color: black; ");
		desktop = new MainDesktopPane(this);
		desktopNode.setStyle("-fx-background-color: transparent; -fx-border-color: black; ");	
		desktopPane = new Pane(desktopNode);
		desktopPane.setMaxSize(screen_width - 25, screen_height); // TAB_PANEL_HEIGHT

		// Add main pane
		WebPanel mainPane = new WebPanel(new BorderLayout());
		mainPane.setSize(screen_width - 25 , screen_height - 15);
		mainPane.add(desktop, BorderLayout.CENTER);	
//		desktopNode.setContent(mainPane);
		SwingUtilities.invokeLater(() -> desktopNode.setContent(mainPane));

//		desktopNode.requestFocus();
	}
 
Example 5
Source Project: BowlerStudio   Source File: PidLab.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void initializeUI(BowlerAbstractDevice pm) {
	engine = (LinearPhysicsEngine)pm;
	wrapper = new SwingNode();

	wrapper.setContent(engine.getPid().getGraphingPanel());
       ScrollPane s1 = new ScrollPane();
       
       s1.setContent(wrapper);
       setContent(s1);
       setText("PID Lab");
	
}
 
Example 6
private void setUpListenerPanel(){
	//Platform.runLater(()->{
		textArea = new RSyntaxTextArea(15, 80);
		textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_GROOVY);
		textArea.setCodeFoldingEnabled(true);
		textArea.setText("return new IChannelEventListener() { \n"+
			"\tpublic \n"
			+ "\tvoid onChannelEvent(DyIOChannelEvent dyioEvent){\n"+
			"\t\tprintln \"From Listener=\"+dyioEvent.getValue();\n"+
			"\t}\n"+
		"}"
			);
		sp = new RTextScrollPane(textArea);
		
		sn = new SwingNode();
		SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
            	sn.setContent(sp);
            }
        });
		
		Platform.runLater(()->listenerCodeBox.getChildren().setAll(sn));
		
		listenerCodeBox.setFocusTraversable(false);
		
		sn.setOnMouseEntered(mouseEvent -> {
			sn.requestFocus();
			SwingUtilities.invokeLater(new Runnable() {
	            @Override
	            public void run() {
	            	textArea.requestFocusInWindow();
	            }
	        });
		});
	//});
}
 
Example 7
Source Project: BowlerStudio   Source File: BootloaderPanel.java    License: GNU General Public License v3.0 5 votes vote down vote up
public BootloaderPanel(){
		////System.out.println("Starting GUI");
		setText("NR Bootloader");
//		fileButton = new JButton();
//		fileButton.addActionListener(this);
//		resetFile();
		
		
		loadButton = new JButton();
		loadButton.addActionListener(this);
		resetLoad();
		
		JPanel buttonPanel = new JPanel(new MigLayout());

		//buttonPanel.add(fileStatus);
//        buttonPanel.add(fileButton, "wrap");
        
        JPanel prog = new JPanel(new MigLayout());
        prog.add(loadButton, "wrap");
        prog.add(progress,"wrap");
        
        buttonPanel.add(loadStatus);
        buttonPanel.add(prog);
        
        SwingNode sn = new SwingNode();
        sn.setContent(buttonPanel);
        setContent(sn);
 
	}
 
Example 8
@Override
public void initializeUI(BowlerAbstractDevice pm) {
	// TODO Auto-generated method stub
	gui.setConnection(pm);
	SwingNode sn = new SwingNode();
       sn.setContent(gui);
       ScrollPane s1 = new ScrollPane();
      
       s1.setContent(sn);
       setContent(s1);
       setText("Anamation Sequencer");
	onTabReOpening();
}
 
Example 9
@Override
public void initializeUI(BowlerAbstractDevice pm) {

	bcp.setConnection((BowlerCamDevice)pm);
	
	SwingNode sn = new SwingNode();
       sn.setContent(bcp);
       ScrollPane s1 = new ScrollPane();
      
       s1.setContent(sn);
       setContent(s1);
       setText("BowlerCam Control");
	onTabReOpening();
}
 
Example 10
Source Project: java-ml-projects   Source File: Clustering.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
	loadData();
	tree = new J48();
	tree.buildClassifier(data);

	noClassificationChart = buildChart("No Classification (click to add new data)", buildSingleSeries());
	clusteredChart = buildChart("Clustered", buildClusteredSeries());
	realDataChart = buildChart("Real Data (+ Decision Tree classification for new data)", buildLabeledSeries());

	noClassificationChart.setOnMouseClicked(e -> {
		Axis<Number> xAxis = noClassificationChart.getXAxis();
		Axis<Number> yAxis = noClassificationChart.getYAxis();
		Point2D mouseSceneCoords = new Point2D(e.getSceneX(), e.getSceneY());
		double x = xAxis.sceneToLocal(mouseSceneCoords).getX();
		double y = yAxis.sceneToLocal(mouseSceneCoords).getY();
		Number xValue = xAxis.getValueForDisplay(x);
		Number yValue = yAxis.getValueForDisplay(y);
		reloadSeries(xValue, yValue);
	});

	Label lblDecisionTreeTitle = new Label("Decision Tree generated for the Iris dataset:");
	Text txtTree = new Text(tree.toString());
	String graph = tree.graph();
	SwingNode sw = new SwingNode();
	SwingUtilities.invokeLater(() -> {
		TreeVisualizer treeVisualizer = new TreeVisualizer(null, graph, new PlaceNode2());
		treeVisualizer.setPreferredSize(new Dimension(600, 500));
		sw.setContent(treeVisualizer);
	});

	Button btnRestore = new Button("Restore original data");
	Button btnSwapColors = new Button("Swap clustered chart colors");
	StackPane spTree = new StackPane(sw);
	spTree.setPrefWidth(300);
	spTree.setPrefHeight(350);
	VBox vbDecisionTree = new VBox(5, lblDecisionTreeTitle, new Separator(), spTree,
			new HBox(10, btnRestore, btnSwapColors));
	btnRestore.setOnAction(e -> {
		loadData();
		reloadSeries();
	});
	btnSwapColors.setOnAction(e -> swapClusteredChartSeriesColors());
	lblDecisionTreeTitle.setTextFill(Color.DARKRED);
	lblDecisionTreeTitle.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD, FontPosture.ITALIC, 16));
	txtTree.setTranslateX(100);
	txtTree.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD, FontPosture.ITALIC, 14));
	txtTree.setLineSpacing(1);
	txtTree.setTextAlignment(TextAlignment.LEFT);
	vbDecisionTree.setTranslateY(20);
	vbDecisionTree.setTranslateX(20);

	GridPane gpRoot = new GridPane();
	gpRoot.add(realDataChart, 0, 0);
	gpRoot.add(clusteredChart, 1, 0);
	gpRoot.add(noClassificationChart, 0, 1);
	gpRoot.add(vbDecisionTree, 1, 1);

	stage.setScene(new Scene(gpRoot));
	stage.setTitle("Íris dataset clustering and visualization");
	stage.show();
}