本文整理汇总了Java中javafx.embed.swing.JFXPanel.setPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:Java JFXPanel.setPreferredSize方法的具体用法?Java JFXPanel.setPreferredSize怎么用?Java JFXPanel.setPreferredSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.embed.swing.JFXPanel
的用法示例。
在下文中一共展示了JFXPanel.setPreferredSize方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initGui
import javafx.embed.swing.JFXPanel; //导入方法依赖的package包/类
/**
* Initializes the interface
*/
private void initGui() {
JFXPanel jfxPanel = new JFXPanel();
jfxPanel.setPreferredSize(new Dimension(800, 600));
Platform.runLater(() -> {
webView = new WebView();
webView.getEngine().setUserStyleSheetLocation(MarkdownViewer.class.getResource("MarkdownViewer.css").toExternalForm());
Scene scene = new Scene(webView);
jfxPanel.setScene(scene);
});
setLayout(new BorderLayout());
add(jfxPanel);
}
示例2: GameArena
import javafx.embed.swing.JFXPanel; //导入方法依赖的package包/类
/**
* Constructor. Creates an instance of the GameArena class, and displays a window on the
* screen upon which shapes can be drawn.
*
* @param width The width of the window, in pixels.
* @param height The height of the window, in pixels.
* @param createWindow Determines if a JFrame containing the GameArena should be created (true) or not (false).
*/
public GameArena(int width, int height, boolean createWindow)
{
this.arenaWidth = width;
this.arenaHeight = height;
this.objectCount = 0;
this.initialised = false;
// Create a lock to reduce flicker on rendering
renderLock = new ReentrantLock();
// Create a JavaFX canvas as a Swing panel.
jfxPanel = new JFXPanel();
jfxPanel.setPreferredSize(new java.awt.Dimension(width, height));
// Create a window, if necessary.
if (createWindow)
{
window = new JFrame();
window.setTitle("Let's Play!");
window.setContentPane(jfxPanel);
window.setResizable(false);
window.pack();
window.setVisible(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
root = new Group();
scene = new Scene(root, arenaWidth, arenaHeight, Color.BLACK);
renderLock.lock();
Platform.runLater(new Runnable() {
@Override
public void run() {
initFX();
}
});
}
示例3: initSwingDialog
import javafx.embed.swing.JFXPanel; //导入方法依赖的package包/类
void initSwingDialog() {
LOG.trace("initSwingDialog()");
setTitle(title);
setMinimumSize(new Dimension(600, 300));
addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(true);
}
});
JFXPanel fxContainer = createJavaFXUI();
fxContainer.setPreferredSize(new Dimension(width, height));
add(fxContainer, BorderLayout.CENTER);
pack();
}
示例4: GameArena
import javafx.embed.swing.JFXPanel; //导入方法依赖的package包/类
/**
* Constructor. Creates an instance of the GameArena class, and displays a window on the
* screen upon which shapes can be drawn.
*
* @param width The width of the window, in pixels.
* @param height The height of the window, in pixels.
* @param createWindow Determines if a JFrame containing the GameArena should be created (true) or not (false).
*/
public GameArena(int width, int height, boolean createWindow)
{
this.arenaWidth = width;
this.arenaHeight = height;
this.objectCount = 0;
// Create a lock to reduce flicker on rendering
renderLock = new ReentrantLock();
// Create a JavaFX canvas as a Swing panel.
jfxPanel = new JFXPanel();
jfxPanel.setPreferredSize(new java.awt.Dimension(width, height));
// Create a window, if necessary.
if (createWindow)
{
window = new JFrame();
window.setTitle("Let's Play!");
window.setContentPane(jfxPanel);
window.setResizable(false);
window.pack();
window.setVisible(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
root = new Group();
scene = new Scene(root, arenaWidth, arenaHeight, Color.BLACK);
renderLock.lock();
Platform.runLater(new Runnable() {
@Override
public void run() {
initFX();
}
});
}
示例5: GameArena
import javafx.embed.swing.JFXPanel; //导入方法依赖的package包/类
/**
* Constructor. Creates an instance of the GameArena class, and displays a window on the
* screen upon which shapes can be drawn.
*
* @param width The width of the window, in pixels.
* @param height The height of the window, in pixels.
*/
public GameArena(int width, int height)
{
this.arenaWidth = width;
this.arenaHeight = height;
this.objectCount = 0;
// Create a window
window = new JFrame();
window.setTitle("Let's Play!");
// Create a JavaFX canvas as a Swing panel.
jfxPanel = new JFXPanel();
jfxPanel.setPreferredSize(new java.awt.Dimension(width, height));
window.setContentPane(jfxPanel);
window.setResizable(false);
window.pack();
window.setVisible(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
root = new Group();
scene = new Scene(root, arenaWidth, arenaHeight, Color.BLACK);
Platform.runLater(new Runnable() {
@Override
public void run() {
initFX();
}
});
}
示例6: GameArena
import javafx.embed.swing.JFXPanel; //导入方法依赖的package包/类
/**
* Constructor. Creates an instance of the GameArena class, and displays a window on the
* screen upon which shapes can be drawn.
*
* @param width The width of the window, in pixels.
* @param height The height of the window, in pixels.
*/
public GameArena(int width, int height)
{
this.arenaWidth = width;
this.arenaHeight = height;
this.objectCount = 0;
// Create a lock to reduce flicker on rendering
renderLock = new ReentrantLock();
// Create a window
window = new JFrame();
window.setTitle("Let's Play!");
// Create a JavaFX canvas as a Swing panel.
jfxPanel = new JFXPanel();
jfxPanel.setPreferredSize(new java.awt.Dimension(width, height));
window.setContentPane(jfxPanel);
window.setResizable(false);
window.pack();
window.setVisible(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
root = new Group();
scene = new Scene(root, arenaWidth, arenaHeight, Color.BLACK);
renderLock.lock();
Platform.runLater(new Runnable() {
@Override
public void run() {
initFX();
}
});
}
示例7: init
import javafx.embed.swing.JFXPanel; //导入方法依赖的package包/类
@Override
public void init() {
fxContainer = new JFXPanel();
fxContainer.setPreferredSize(new Dimension(JFXPANEL_WIDTH_INT, JFXPANEL_HEIGHT_INT));
add(fxContainer, BorderLayout.CENTER);
// create JavaFX scene
Platform.runLater(new Runnable() {
@Override
public void run() {
createScene();
}
});
}
示例8: init
import javafx.embed.swing.JFXPanel; //导入方法依赖的package包/类
@Override
public void init() {
fxContainer = new JFXPanel();
fxContainer.setPreferredSize(new Dimension(JFXPANEL_WIDTH_INT, JFXPANEL_HEIGHT_INT));
add(fxContainer, BorderLayout.CENTER);
// create JavaFX scene
Platform.runLater(new Runnable() {
@Override
public void run() {
tabScene();
}
});
}
示例9: init
import javafx.embed.swing.JFXPanel; //导入方法依赖的package包/类
public void init() {
tableModel = new SampleTableModel();
// create javafx panel for charts
chartFxPanel = new JFXPanel();
chartFxPanel.setPreferredSize(new Dimension(PANEL_WIDTH_INT, PANEL_HEIGHT_INT));
// create javafx panel for browser
browserFxPanel = new JFXPanel();
//create tabbed pane
JTabbedPane tabbedPane = new JTabbedPane();
//JTable
JTable table = new JTable(tableModel);
table.setAutoCreateRowSorter(true);
table.setGridColor(Color.DARK_GRAY);
SwingInterop.DecimalFormatRenderer renderer = new SwingInterop.DecimalFormatRenderer();
renderer.setHorizontalAlignment(JLabel.RIGHT);
for (int i = 0; i < table.getColumnCount(); i++) {
table.getColumnModel().getColumn(i).setCellRenderer(renderer);
}
JScrollPane tablePanel = new JScrollPane(table);
tablePanel.setPreferredSize(new Dimension(PANEL_WIDTH_INT, TABLE_PANEL_HEIGHT_INT));
JPanel chartTablePanel = new JPanel();
chartTablePanel.setLayout(new BorderLayout());
//Split pane that holds both chart and table
JSplitPane jsplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
jsplitPane.setTopComponent(chartTablePanel);
jsplitPane.setBottomComponent(tablePanel);
jsplitPane.setDividerLocation(410);
chartTablePanel.add(chartFxPanel, BorderLayout.CENTER);
tabbedPane.addTab("JavaFX Chart and Swing JTable", jsplitPane);
tabbedPane.addTab("Web Browser", browserFxPanel);
add(tabbedPane, BorderLayout.CENTER);
// create JavaFX scene
Platform.runLater(new Runnable() {
public void run() {
createScene();
}
});
}
示例10: init
import javafx.embed.swing.JFXPanel; //导入方法依赖的package包/类
public void init() {
tableModel = new SampleTableModel();
// create javafx panel for charts
chartFxPanel = new JFXPanel();
chartFxPanel.setPreferredSize(new Dimension(PANEL_WIDTH_INT, PANEL_HEIGHT_INT));
// create javafx panel for browser
browserFxPanel = new JFXPanel();
//create tabbed pane
JTabbedPane tabbedPane = new JTabbedPane();
//JTable
JTable table = new JTable(tableModel);
table.setAutoCreateRowSorter(true);
table.setGridColor(Color.DARK_GRAY);
DecimalFormatRenderer renderer = new DecimalFormatRenderer();
renderer.setHorizontalAlignment(JLabel.RIGHT);
for (int i = 0; i < table.getColumnCount(); i++) {
table.getColumnModel().getColumn(i).setCellRenderer(renderer);
}
JScrollPane tablePanel = new JScrollPane(table);
tablePanel.setPreferredSize(new Dimension(PANEL_WIDTH_INT, TABLE_PANEL_HEIGHT_INT));
JPanel chartTablePanel = new JPanel();
chartTablePanel.setLayout(new BorderLayout());
//Split pane that holds both chart and table
JSplitPane jsplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
jsplitPane.setTopComponent(chartTablePanel);
jsplitPane.setBottomComponent(tablePanel);
jsplitPane.setDividerLocation(410);
chartTablePanel.add(chartFxPanel, BorderLayout.CENTER);
tabbedPane.addTab("JavaFX Chart and Swing JTable", jsplitPane);
tabbedPane.addTab("Web Browser", browserFxPanel);
add(tabbedPane, BorderLayout.CENTER);
// create JavaFX scene
Platform.runLater(new Runnable() {
public void run() {
createScene();
}
});
}