本文整理匯總了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();
}
});
}