javafx.embed.swing.JFXPanel类的使用及代码示例

x33g5p2x  于9个月前 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(12)

本文整理了Java中javafx.embed.swing.JFXPanel类的一些代码示例,展示了JFXPanel类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFXPanel类的具体详情如下:
包路径:javafx.embed.swing.JFXPanel
类名称:JFXPanel

JFXPanel介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

private WebEngine engine;
private JFrame frame = new JFrame();
private JPanel panel = new JPanel(new BorderLayout());
private JLabel lblStatus = new JLabel();
  jfxPanel = new JFXPanel();
  topBar.add(txtURL, BorderLayout.CENTER);
  topBar.add(btnGo, BorderLayout.EAST);
  statusBar.add(lblStatus, BorderLayout.CENTER);
  frame.getContentPane().add(panel);
    @Override public void run() {
      WebView view = new WebView();
      engine = view.getEngine();
      jfxPanel.setScene(new Scene(view));
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.pack();
  frame.setVisible(true);

代码示例来源:origin: stackoverflow.com

JFXPanel jfxPanel = new JFXPanel(); // Scrollable JCompenent
Platform.runLater( () -> { // FX components need to be managed by JavaFX
  WebView webView = new WebView();
  webView.getEngine().loadContent( "<html> Hello World!" );
  webView.getEngine().load( "http://www.stackoverflow.com/" );
  jfxPanel.setScene( new Scene( webView ) );
});

代码示例来源:origin: stackoverflow.com

btnNewButton.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent arg0) {
    JFrame frame = new JFrame();
    JFXPanel jfxPanel = new JFXPanel();
    Platform.runLater(() -> {
      Parent root = ... ; // create JavaFX content, can be in a separate class
      Scene scene = new Scene(root);
      jfxPanel.setScene(scene);
    });
    frame.add(jfxPanel);
    frame.setSize(...);
    frame.setVisible(true);
  }       
});

代码示例来源:origin: stackoverflow.com

JFrame frame = new JFrame("FX");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null); // do the layout manually
final JFXPanel fxPanel = new JFXPanel();
frame.add(jButton);
frame.add(fxPanel);
frame.setVisible(true);
frame.getContentPane().setPreferredSize(new Dimension(300, 327));
frame.pack();
frame.setResizable(false);
fxPanel.setScene(scene);
WebView webView = new WebView();
webView.setMinSize(300, 300);
webView.setMaxSize(300, 300);
SwingUtilities.invokeLater(new Runnable() {
  @Override
  public void run() {

代码示例来源:origin: stackoverflow.com

SwingUtilities.invokeLater(new Runnable() {
  @Override
  public void run() {
    } catch (Exception e) {
fxContainer = new JFXPanel();
fxContainer.setPreferredSize(new Dimension(JFXPANEL_WIDTH_INT / 5, JFXPANEL_HEIGHT_INT / 5));
add(fxContainer, BorderLayout.NORTH);
fxContainerTwo = new JFXPanel();
fxContainerTwo.setPreferredSize(new Dimension(JFXPANEL_WIDTH_INT, JFXPANEL_HEIGHT_INT));
add(fxContainerTwo, BorderLayout.CENTER);
Platform.runLater(new Runnable() {
  @Override
root.getChildren().add(btn);
Scene scene = new Scene(root, Color.BLUEVIOLET);
fxContainer.setScene(scene);
root.getChildren().add(btn);
Scene scene = new Scene(root, Color.ALICEBLUE);
fxContainerTwo.setScene(scene);

代码示例来源:origin: stackoverflow.com

JFrame frame = new JFrame("Swing and JavaFX");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JFXPanel fxPanel = new JFXPanel();
frame.add(fxPanel, BorderLayout.CENTER);
frame.pack();
frame.setSize(640, 480);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
StackPane root = new StackPane();
Scene scene = new Scene(root);
webView = new WebView();
WebEngine webEngine = webView.getEngine();
webEngine.load("http://www.example.com");
root.getChildren().add(webView);
SwingUtilities.invokeLater(new WebViewTest()::initAndShowGUI);

代码示例来源:origin: stackoverflow.com

private static void initAndShowGUI() {
  JFrame frame = new JFrame("Swing and JavaFX");
  final JFXPanel fxPanel = new JFXPanel();
  frame.add(fxPanel);
  frame.setSize(300, 200);
  frame.setVisible(true);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  button2.setOnAction(new EventHandler() {
    @Override public void handle(ActionEvent e) {
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {

代码示例来源:origin: stackoverflow.com

private static void initAndShowGUI() {
 JFrame frame = new JFrame("FX");
 final JFXPanel fxPanel = new JFXPanel();
 frame.add(fxPanel);
 frame.setBounds(200, 100, 800, 250);
 frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
 frame.setVisible(true);
 SwingUtilities.invokeLater(new Runnable() {
  @Override public void run() {
   initAndShowGUI();

代码示例来源:origin: stackoverflow.com

FL.setHgap(0);
 FL.setVgap(0);
 setLayout(FL);
browserFxPanel=new JFXPanel();
add(browserFxPanel);
Platform.runLater(new Runnable() { public void run() { createScene(); } });
browserFxPanel.setScene(new Scene(browser));
view=new WebView();
if (Show_Frame_B)
 view.setMinSize(widthDouble,heightDouble);
 view.setPrefSize(widthDouble,heightDouble);
eng=view.getEngine();
 SwingUtilities.invokeLater(new Runnable()
   JFrame frame=new JFrame("JavaFX 2.2 in Swing");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.add(demo);
   frame.pack();
   frame.setLocationRelativeTo(null);
   frame.setVisible(true);

代码示例来源:origin: stackoverflow.com

setType(Type.UTILITY);
setUndecorated(true);
setSize(200, 200);
toBack();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JFXPanel fxPanel = new JFXPanel();
Widget.this.getContentPane().add(fxPanel);
    fxPanel.setScene( createFxScene());
    SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {

代码示例来源:origin: stackoverflow.com

JFrame frame = new JFrame();
frame.add(new SwingBrowser());
frame.setSize(1024, 768);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
toolbar.setLayout(new FlowLayout());
toolbar.add(button);
toolbar.add(button);
final JFXPanel fxPanel = new JFXPanel();
setLayout(new BorderLayout());
WebView webView = new WebView();
webEngine = webView.getEngine();
SwingUtilities.invokeLater(new Runnable() {
  @Override
  public void run() {

代码示例来源:origin: stackoverflow.com

private JFrame frame = new JFrame();
private JPanel panel = new JPanel(new BorderLayout());
private JLabel lblStatus = new JLabel();
  jfxPanel = new JFXPanel();
  createScene();
  topBar.add(txtURL, BorderLayout.CENTER);
  topBar.add(btnGo, BorderLayout.EAST);
  statusBar.add(lblStatus, BorderLayout.CENTER);
  statusBar.add(progressBar, BorderLayout.EAST);
  panel.add(statusBar, BorderLayout.SOUTH);
  frame.getContentPane().add(panel);
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, final String newValue) {
          SwingUtilities.invokeLater(new Runnable() {
            @Override public void run() {
              frame.setTitle(newValue);
  frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  frame.pack();
  frame.setVisible(true);

代码示例来源:origin: stackoverflow.com

import javafx.embed.swing.JFXPanel;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public class SomeClass {
  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
        JFrame frame = new JFrame("Swing Frame");
        JFXPanel jfxp = new JFXPanel();
        frame.getContentPane().add(jfxp);
        frame.setSize(600, 400);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);

        NetworkUI.main();
      }
    });
  }
}

代码示例来源:origin: stackoverflow.com

SwingUtilities.invokeLater(new Runnable() {
    final JFrame frame = new JFrame("JavaFX 2 in Swing");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(applet.getContentPane());
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
fxContainer = new JFXPanel();
fxContainer.setPreferredSize(new Dimension(300, 200));
add(fxContainer, BorderLayout.CENTER);
  double width = getWidth();
  double height = getHeight();
  double top = getInsets().getTop();
  double right = getInsets().getRight();
  double left = getInsets().getLeft();
  double bottom = getInsets().getBottom();

代码示例来源:origin: stackoverflow.com

final JFrame frame = new JFrame();
JPanel login = new JPanel();
login.setLayout(new BorderLayout());
login.setBounds(0, 0, 415, 180);
JFXPanel jfxPanel = new JFXPanel();
frame.add(login, BorderLayout.NORTH);
login.add(jfxPanel, BorderLayout.NORTH);
    WebView webView = new WebView();
    WebEngine engine = webView.getEngine();
    engine.load("http://www.google.com");
    Scene scene = new Scene(root, 414, 179);
    jfxPanel.setScene(scene);
frame.setLayout(null);
frame.setSize(415, 180);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setAlwaysOnTop(true);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice defaultScreen = ge.getDefaultScreenDevice();

代码示例来源:origin: stackoverflow.com

JFrame frame = new JFrame();
frame.setUndecorated(true);
frame.setBackground(new java.awt.Color(0, 0, 0, 0));
final JFXPanel fxPanel = new JFXPanel();
frame.add(fxPanel);
frame.setSize(422, 116);
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
fxPanel.setScene(scene);
frame.setResizable(false);
frame.setAlwaysOnTop(true);
frame.setFocusableWindowState(false); // <- Here is the secret
frame.setVisible(true);

代码示例来源:origin: stackoverflow.com

JFXPanel fxPanel;
 WebView wv;
 JFrame frame;
try {
   fxPanel = new JFXPanel ();
   // create JavaFX scene
   com.sun.javafx.application.PlatformImpl.runLater ( new Runnable () {
     @Override
     public void run () {
       wv = new WebView ();
       wv.getEngine ().load ( "http://www.google.com/" );
       fxPanel.setScene ( new Scene ( wv, 1000, 750 ) );
       frame = new JFrame ( "Google" );
       frame.add ( new JScrollPane ( fxPanel ) );
       frame.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE );
       frame.setVisible ( true );
       frame.pack ();
     }
   } );
 } catch ( Exception ex ) {
 }

代码示例来源:origin: stackoverflow.com

panel = new JFXPanel();
Platform.runLater(new Runnable(){
  @Override
this.getContentPane().add(panel);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(300, 300);
this.setVisible(true);
SwingUtilities.invokeLater(new Runnable(){
  @Override
  public void run() {

代码示例来源:origin: stackoverflow.com

frame = new JFrame("Hello Swing GMapsFX");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jfxPanel = new JFXPanel();
jfxPanel.setPreferredSize(new Dimension(600, 600));
  scene = new Scene(mapComponent);
  jfxPanel.setScene(scene);
});
frame.getContentPane().add(jfxPanel);
frame.pack();
frame.setVisible(true);
frame.setLocationRelativeTo(null);

代码示例来源:origin: stackoverflow.com

getContentPane().add(panel);
    "JavaFX Dialog",
    true);
  final JFXPanel contentPane = new JFXPanel();
  dialog.setContentPane(contentPane);
  dialog.setDefaultCloseOperation(
   @Override
   public void run() {
    contentPane.setScene(createScene());
    SwingUtilities.invokeLater(new Runnable() {
     @Override
     public void run() {
      dialog.pack();
      dialog.setVisible(true);
panel.add(button);
setSize(300, 200);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
SwingUtilities.invokeLater(new Runnable() {
 @Override
 public void run() {

相关文章