本文整理汇总了Java中javafx.stage.Screen.getVisualBounds方法的典型用法代码示例。如果您正苦于以下问题:Java Screen.getVisualBounds方法的具体用法?Java Screen.getVisualBounds怎么用?Java Screen.getVisualBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.stage.Screen
的用法示例。
在下文中一共展示了Screen.getVisualBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import javafx.stage.Screen; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("menuSample.fxml"));
primaryStage.setTitle("Hello World");
Screen screen = Screen.getPrimary();
Rectangle2D bounds = screen.getVisualBounds();
primaryStage.setX(bounds.getMinX());
primaryStage.setY(bounds.getMinY());
primaryStage.setWidth(bounds.getWidth());
primaryStage.setHeight(bounds.getHeight());
primaryStage.setMaximized(true);
Scene menuScene = new Scene(root, 1080, 720);
//primaryStage.setFullScreen(true);
primaryStage.setScene(menuScene);
//primaryStage.setFullScreen(true);
primaryStage.show();
}
示例2: start
import javafx.stage.Screen; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception{
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(getClass().getResource("sample.fxml"));
Parent root = fxmlLoader.load();
Screen screen = Screen.getPrimary ();
// 界面初始化
Controller controller = fxmlLoader.getController();
controller.init(primaryStage);
Rectangle2D bounds = screen.getVisualBounds ();
double minX = bounds.getMinX ();
double minY = bounds.getMinY ();
double maxX = bounds.getMaxX ();
double maxY = bounds.getMaxY ();
screenWidth = maxX - minX;
screenHeight = maxY - minY;
Scene scene = new Scene(root, (maxX - minX) * 0.6, (maxY - minY) * 0.6);
primaryStage.setTitle ("Higher Cloud Compute Platform");
primaryStage.setScene (scene);
primaryStage.setFullScreen(true);
primaryStage.show ();
}
示例3: start
import javafx.stage.Screen; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws SQLException, IOException
{
Parent root = FXMLLoader.load(getClass().getResource("MainScene.fxml"));
scene = new Scene(root);
Screen screen = Screen.getPrimary();
Rectangle2D bounds = screen.getVisualBounds();
Image ico=new Image("file:///D:/Study/Java/HostelProjecttest/src/hostelproject/media/net.png");
stage.setTitle("Banda Singh Bahadur Boys Hostel");
stage.getIcons().add(ico);
stage.setX(bounds.getMinX());
stage.setY(bounds.getMinY());
stage.setWidth(bounds.getWidth());
stage.setHeight(bounds.getHeight());
stage.setScene(scene);
stage.show();
}
示例4: invalidated
import javafx.stage.Screen; //导入方法依赖的package包/类
@Override
protected void invalidated() {
DockNode.this.pseudoClassStateChanged(MAXIMIZED_PSEUDO_CLASS, get());
if (borderPane != null) {
borderPane.pseudoClassStateChanged(MAXIMIZED_PSEUDO_CLASS, get());
}
stage.setMaximized(get());
// TODO: This is a work around to fill the screen bounds and not overlap the task bar when
// the window is undecorated as in Visual Studio. A similar work around needs applied for
// JFrame in Swing. http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4737788
// Bug report filed:
// https://bugs.openjdk.java.net/browse/JDK-8133330
if (this.get()) {
Screen screen = Screen.getScreensForRectangle(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight()).get(0);
Rectangle2D bounds = screen.getVisualBounds();
stage.setX(bounds.getMinX());
stage.setY(bounds.getMinY());
stage.setWidth(bounds.getWidth());
stage.setHeight(bounds.getHeight());
}
}
示例5: getResolutionOfTheSelectedScreen
import javafx.stage.Screen; //导入方法依赖的package包/类
private void getResolutionOfTheSelectedScreen() {
// Get list of active screens.
// GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
// GraphicsDevice[] graphicsDevices = graphicsEnvironment.getScreenDevices();
// Get index of selected screen in comboBoxScreen.
// int selectedScreenIndex = comboBoxScreen.getSelectionModel().getSelectedIndex();
// Get resolution of the selected screen.
// GraphicsDevice selectedScreen = graphicsDevices[selectedScreenIndex];
// int x = selectedScreen.getDisplayMode().getWidth();
// int y = selectedScreen.getDisplayMode().getHeight();
java.util.List<Screen> screens = Screen.getScreens();
Screen activeScreen = screens.get(comboBoxScreen.getSelectionModel().getSelectedIndex());
Rectangle2D activeScreenVisualBounds = activeScreen.getVisualBounds();
// Set text for text fields.
textFieldScreenResolutionX.setText(String.valueOf((int) activeScreenVisualBounds.getWidth()));
textFieldScreenResolutionY.setText(String.valueOf((int) activeScreenVisualBounds.getHeight()));
}
示例6: isVisible
import javafx.stage.Screen; //导入方法依赖的package包/类
@Override
public boolean isVisible(final Placement placement) {
ObservableList<Screen> screens = Screen.getScreensForRectangle(rectangle(placement));
if (screens.size() == 1) {
Screen screen = screens.get(0);
Rectangle2D bounds = screen.getVisualBounds();
if (placement.isPositioned()) {
return bounds.contains(placement.getX(), placement.getY(), placement.getWidth(), placement.getHeight());
} else {
return bounds.getWidth() >= placement.getWidth() && bounds.getHeight() >= placement.getHeight();
}
} else {
return false;
}
}
示例7: setY
import javafx.stage.Screen; //导入方法依赖的package包/类
/**
* Sets the Y position of the given stage, if possible.
*
* @param pStage the stage
* @param pY the calculated new Y position
*/
private void setY(Stage pStage, double pY)
{
try
{
ObservableList<Screen> screensForRectangle = Screen.getScreensForRectangle(pStage.getX(), pStage.getY(), pStage.getWidth(), pStage.getHeight());
if (screensForRectangle.size() > 0)
{
Screen screen = screensForRectangle.get(0);
Rectangle2D visualBounds = screen.getVisualBounds();
if (pY < visualBounds.getHeight() - pane.getActiveShadowSize() * 2 && pY + pane.getActiveShadowSize() >= visualBounds.getMinY())
{
pStage.setY(pY);
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
示例8: show
import javafx.stage.Screen; //导入方法依赖的package包/类
public void show() {
Screen screen = Screen.getPrimary();
Rectangle2D bounds = screen.getVisualBounds();
Stage loginStage = new LoginStage(parentStage,w,h);
loginStage.initModality(Modality.APPLICATION_MODAL);
loginStage.setX((bounds.getWidth()/2)-w/2);
loginStage.setY((bounds.getHeight()/2)-h/2);
loginStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent t) {
Platform.exit();
Dialogs.showConfirmDialog(parentStage, "Are you sure you want to exit? You will loose the opportunity of making money!"
+ " If you need help send a mail to [email protected]");
//TODO read the asnwer instead of just quitting
System.exit(0);
}
});
loginStage.setOpacity(0.9);
loginStage.setResizable(false);
loginStage.show();
}
示例9: show
import javafx.stage.Screen; //导入方法依赖的package包/类
public void show() {
Screen screen = Screen.getPrimary();
Rectangle2D bounds = screen.getVisualBounds();
Stage passpStage = new PasspStage(parentStage,w,h,app,oldPwdExists,oldPwd);
passpStage.initModality(Modality.APPLICATION_MODAL);
passpStage.setX((bounds.getWidth()/2)-w/2);
passpStage.setY((bounds.getHeight()/2)-h/2);
passpStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent t) {
Platform.exit();
System.exit(0);
}
});
passpStage.setOpacity(0.9);
passpStage.setResizable(false);
passpStage.show();
}
示例10: WelcomeDialog
import javafx.stage.Screen; //导入方法依赖的package包/类
public WelcomeDialog(Stage parentStage){
this.parentStage=parentStage;
Screen screen = Screen.getPrimary();
Rectangle2D bounds = screen.getVisualBounds();
welcomeStage = new WelcomeStage(parentStage,w,h);
welcomeStage.initModality(Modality.APPLICATION_MODAL);
welcomeStage.setX((bounds.getWidth()/2)-w/2);
welcomeStage.setY((bounds.getHeight()/2)-h/2);
welcomeStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent t) {
Platform.exit();
System.exit(0);
}
});
welcomeStage.setOpacity(0.9);
welcomeStage.setResizable(false);
}
示例11: show
import javafx.stage.Screen; //导入方法依赖的package包/类
public void show() {
Screen screen = Screen.getPrimary();
Rectangle2D bounds = screen.getVisualBounds();
if (market.equals(Constant.BITSTAMP))
{
h=h+60;
}
final Stage apiStage = new ApiStage(parentStage,w,h,wizard,market);
apiStage.initModality(Modality.APPLICATION_MODAL);
apiStage.setX((bounds.getWidth()/2)-w/2);
apiStage.setY((bounds.getHeight()/2)-h/2);
apiStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent t) {
DashboardController dbc = Global.dashBoardController.getController();
DashboardOptionsController controller = (DashboardOptionsController) Global.getController(Constant.OPTIONS);
controller.updateStatusMessages();
}
});
apiStage.setOpacity(0.9);
apiStage.setResizable(false);
apiStage.show();
}
示例12: getDockSide
import javafx.stage.Screen; //导入方法依赖的package包/类
/**
* Based on mouse position returns dock side
*
* @param mouseEvent
* @return DOCK_LEFT,DOCK_RIGHT,DOCK_TOP
*/
int getDockSide(MouseEvent mouseEvent) {
double minX = Double.POSITIVE_INFINITY;
double minY = Double.POSITIVE_INFINITY;
double maxX = 0;
double maxY = 0;
// Get "big" screen bounds
ObservableList<Screen> screens = Screen.getScreens();
for (Screen screen : screens) {
Rectangle2D visualBounds = screen.getVisualBounds();
minX = Math.min(minX, visualBounds.getMinX());
minY = Math.min(minY, visualBounds.getMinY());
maxX = Math.max(maxX, visualBounds.getMaxX());
maxY = Math.max(maxY, visualBounds.getMaxY());
}
// Dock Left
if (mouseEvent.getScreenX() == minX) {
return DOCK_LEFT;
} else if (mouseEvent.getScreenX() >= maxX - 1) { // MaxX returns the width? Not width -1 ?!
return DOCK_RIGHT;
} else if (mouseEvent.getScreenY() <= minY) { // Mac menu bar
return DOCK_TOP;
}
return 0;
}
示例13: maximizeControlAction
import javafx.stage.Screen; //导入方法依赖的package包/类
@FXML
public void maximizeControlAction(final ActionEvent actionEvent) {
final Screen screen = Screen.getPrimary();
final Rectangle2D bounds = screen.getVisualBounds();
final Stage primaryStage = (Stage) menuBar.getScene().getWindow();
maximized = !maximized;
if (maximized) {
x = primaryStage.getX();
y = primaryStage.getY();
width = primaryStage.getWidth();
height = primaryStage.getHeight();
primaryStage.setX(bounds.getMinX());
primaryStage.setY(bounds.getMinY());
primaryStage.setWidth(bounds.getWidth());
primaryStage.setHeight(bounds.getHeight());
} else {
primaryStage.setX(x);
primaryStage.setY(y);
primaryStage.setWidth(width);
primaryStage.setHeight(height);
}
}
示例14: main
import javafx.stage.Screen; //导入方法依赖的package包/类
public static void main(String[] args) {
Screen screen = Screen.getPrimary ();
// 界面初始化
Rectangle2D bounds = screen.getVisualBounds ();
double minX = bounds.getMinX ();
double minY = bounds.getMinY ();
double maxX = bounds.getMaxX ();
double maxY = bounds.getMaxY ();
screenWidth = maxX - minX;
screenHeight = maxY - minY;
launch(args);
// Map<String,String> map = Collections.singletonMap("ROLE", "DOWNLOAD");
// Ignite ignite = IgniteUtility.startDefaultIgnite(map,"DOWNLOAD");
// //使用Downloads标签注册这个ignite结点的信息。
// Map<String,String> attrs = Collections.singletonMap("AGENT","Download");
//
// //使用Downloads注册这个cache的名字。
// Ignite ignite = IgniteUtility.startDefaultIgnite(attrs,"Downloads");
//
// ClusterGroup remoteCluster = ignite.cluster().forRemotes();
// ClusterGroup localCluster = ignite.cluster().forLocal();
// Collection<ClusterNode> remoteNodes = remoteCluster.nodes();
// Collection<ClusterNode> localNodes = localCluster.nodes();
//
// for (ClusterNode clusterNode:localNodes) {
// long heapSize = clusterNode.metrics().getHeapMemoryTotal();
// int cpusNum = clusterNode.metrics().getTotalCpus();
// System.out.println("heapSize:"+heapSize);
// System.out.println("cpus:"+cpusNum);
//// Node curNode = new Node();
//
// }
}
示例15: setSizeAndLocation
import javafx.stage.Screen; //导入方法依赖的package包/类
private void setSizeAndLocation(Stage primaryStage) {
Screen primaryScreen = Screen.getPrimary();
Rectangle2D visualBounds = primaryScreen.getVisualBounds();
primaryStage.setWidth(Math.min(Constants.DEFAULT_WIDTH, visualBounds.getWidth()));
primaryStage.setHeight(Math.min(Constants.DEFAULT_HEIGHT, visualBounds.getHeight()));
}