下面列出了javafx.scene.web.WebErrorEvent#javafx.stage.Screen 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@FXML
public void showAppointmentSuccessIndicator(String patientId, String consult, String appDate, String appId)
{
Stage stage= new Stage();
AppointmentSuccessController success = new AppointmentSuccessController();
success.fillAppointmentData(patientId,consult,appDate,appId);
Scene scene = new Scene(success);
stage.setScene(scene);
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//set Stage boundaries to visible bounds of the main screen
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.initStyle(StageStyle.UNDECORATED);
scene.setFill(null);
stage.initStyle(StageStyle.TRANSPARENT);
stage.show();
}
@FXML private void addNewDrug()
{
Stage stage= new Stage();
AddNewDrugController addDrug = new AddNewDrugController(pharmacist,this);
addDrug.loadGenericNames();
Scene scene = new Scene(addDrug);
stage.setScene(scene);
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//set Stage boundaries to visible bounds of the main screen
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.initStyle(StageStyle.UNDECORATED);
scene.setFill(null);
stage.initStyle(StageStyle.TRANSPARENT);
stage.show();
}
@FXML
private void viewOnlineAccounts()
{
Stage stage = new Stage();
UserAccountController userAccounts = new UserAccountController("",admin);
ArrayList<ArrayList<String>> data = admin.getOnlineInfo();
userAccounts.fillUserDetail(data);
Scene scene = new Scene(userAccounts);
stage.setScene(scene);
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//set Stage boundaries to visible bounds of the main screen
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.initStyle(StageStyle.UNDECORATED);
scene.setFill(null);
stage.initStyle(StageStyle.TRANSPARENT);
stage.show();
}
public static void openNotification(ClientObject client) {
Stage stage = new Stage();
stage.setWidth(300);
stage.setHeight(125);
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
NotificationView notificationView = new NotificationView();
stage.setScene(new Scene(notificationView.getNotificationView(), 300, 125));
stage.setResizable(false);
stage.setAlwaysOnTop(true);
stage.setX(primaryScreenBounds.getMinX() + primaryScreenBounds.getWidth() - 300);
stage.setY(primaryScreenBounds.getMinY() + primaryScreenBounds.getHeight() - 125);
stage.initStyle(StageStyle.UNDECORATED);
notificationView.getNotificationText().setWrapText(true);
notificationView.getNotificationText().setAlignment(Pos.CENTER);
notificationView.getNotificationText().setPadding(new Insets(0, 5, 0, 20));
notificationView.getNotificationText().setText("New Connection: " + client.getIP() + " (" + client.getNickName() + ")");
stage.show();
PauseTransition delay = new PauseTransition(Duration.seconds(5));
delay.setOnFinished(event -> stage.close());
delay.play();
}
@Override
public void start(final Stage stage) throws Exception {
stage.initStyle(StageStyle.UTILITY);
stage.setScene(new Scene(new Group(), 100, 100));
stage.setX(0);
stage.setY(Screen.getPrimary().getBounds().getHeight() + 100);
stage.show();
Stage app = new Stage();
app.setScene(new Scene(new Group(), 300, 200));
app.setTitle("JavaFX隐藏任务栏");
app.initOwner(stage);
app.initModality(Modality.APPLICATION_MODAL);
app.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
event.consume();
stage.close();
}
});
app.show();
}
@FXML
private void viewLabAccounts()
{
Stage stage = new Stage();
UserAccountController userAccounts = new UserAccountController("lab_assistant",admin);
ArrayList<ArrayList<String>> data = admin.getUserInfo("lab_assistant");
userAccounts.fillUserDetail(data);
Scene scene = new Scene(userAccounts);
stage.setScene(scene);
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//set Stage boundaries to visible bounds of the main screen
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.initStyle(StageStyle.UNDECORATED);
scene.setFill(null);
stage.initStyle(StageStyle.TRANSPARENT);
stage.show();
}
/**
* Create a new device watcher. Internal use only (singleton.)
*/
private GraphicsDeviceWatcher() {
//lastDeviceCount = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices().length;
lastDeviceCount = javafx.stage.Screen.getScreens().size();
listeners = new ArrayList<>();
poller = Executors.newScheduledThreadPool(1);
poller.scheduleAtFixedRate(() -> {
//GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
ObservableList<Screen> monitors = Screen.getScreens();
int thisDeviceCount = monitors.size(); // devices.length;
if(thisDeviceCount != lastDeviceCount) {
for(GraphicsDeviceListener listener : listeners) {
LOGGER.log(Level.INFO, "Number of devices changed, was {0} now {1}", new Object[]{lastDeviceCount, thisDeviceCount});
if (thisDeviceCount > lastDeviceCount && QueleaProperties.get().getUseAutoExtend()) {
QueleaProperties.get().setProjectorScreen(thisDeviceCount - 1);
}
lastDeviceCount = thisDeviceCount;
listener.devicesChanged(monitors);
}
}
}, 0, 3, TimeUnit.SECONDS);
}
public void showSuccessIndicator()
{
Stage stage= new Stage();
SuccessIndicatorController success = new SuccessIndicatorController();
Scene scene = new Scene(success);
stage.setScene(scene);
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//set Stage boundaries to visible bounds of the main screen
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.initStyle(StageStyle.UNDECORATED);
scene.setFill(null);
stage.initStyle(StageStyle.TRANSPARENT);
stage.show();
}
/**
* 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;
}
@Override
public void start(Stage stage) throws Exception {
initHandle();
this.stage = stage;
Platform.setImplicitExit(false);
SwingUtilities.invokeLater(this::addTray);
stage.setTitle("proxyee-down-" + version);
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.getIcons().add(new Image(
Thread.currentThread().getContextClassLoader().getResourceAsStream("favicon.png")));
stage.setOnCloseRequest(event -> {
event.consume();
close();
});
beforeOpen();
// open();
afterOpen();
}
/**
* ウインドウの位置とサイズを設定します。
* @param location ウインドウの位置とサイズ
*/
public void setWindowLocation(WindowLocation location) {
if (location != null) {
boolean intersect = Screen.getScreens()
.stream()
.map(Screen::getVisualBounds)
.anyMatch(r -> r.intersects(
location.getX(), location.getY(), location.getWidth(), location.getHeight()));
if (intersect) {
this.window.setX(location.getX());
this.window.setY(location.getY());
this.window.setWidth(location.getWidth());
this.window.setHeight(location.getHeight());
}
}
}
@FXML
private void showSettings() throws IOException
{
Stage stage = new Stage();
SettingsController settings = new SettingsController(admin,this);
settings.loadConfigFile();
Scene scene = new Scene(settings);
stage.setScene(scene);
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//set Stage boundaries to visible bounds of the main screen
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.initStyle(StageStyle.UNDECORATED);
scene.setFill(null);
stage.initStyle(StageStyle.TRANSPARENT);
stage.show();
}
public ControllerStage(DisplayWindow stage) {
this.displayWindow = stage;
setTitle("Marathon Control Center");
getIcons().add(FXUIUtils.getImageURL("logo16"));
getIcons().add(FXUIUtils.getImageURL("logo32"));
initComponents();
Scene scene = new Scene(content);
content.getStyleClass().add(StyleClassHelper.BACKGROUND);
setScene(scene);
setAlwaysOnTop(true);
setOnShown((e) -> {
Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();
setX(screenBounds.getWidth() - getWidth());
setY(0);
});
sizeToScene();
setResizable(false);
setOnCloseRequest(e -> displayWindow.onStop());
}
private void initWindow() {
stage.setTitle("Proxyee Down");
Rectangle2D bounds = Screen.getPrimary().getVisualBounds();
int width = 1024;
int height = 576;
stage.setX((bounds.getWidth() - width) / 2);
stage.setY((bounds.getHeight() - height) / 2);
stage.setMinWidth(width);
stage.setMinHeight(height);
stage.getIcons().add(new javafx.scene.image.Image(Thread.currentThread().getContextClassLoader().getResourceAsStream(ICON_PATH)));
stage.setResizable(true);
//关闭窗口监听
stage.setOnCloseRequest(event -> {
event.consume();
stage.hide();
});
}
public static Rectangle2D getDesktopSize() {
Rectangle2D rect = Screen.getPrimary().getBounds();
double minX = rect.getMinX(), minY = rect.getMinY();
double maxX = rect.getMaxX(), maxY = rect.getMaxY();
for (Screen screen : Screen.getScreens()) {
Rectangle2D screenRect = screen.getBounds();
if (minX > screenRect.getMinX()) {
minX = screenRect.getMinX();
}
if (minY > screenRect.getMinY()) {
minY = screenRect.getMinY();
}
if (maxX < screenRect.getMaxX()) {
maxX = screenRect.getMaxX();
}
if (maxY < screenRect.getMaxY()) {
maxY = screenRect.getMaxY();
}
}
return new Rectangle2D(minX, minY, maxX - minX, maxY - minY);
}
@FXML
private void viewCashierAccounts()
{
Stage stage = new Stage();
UserAccountController userAccounts = new UserAccountController("cashier",admin);
ArrayList<ArrayList<String>> data = admin.getUserInfo("cashier");
System.out.println(data);
userAccounts.fillUserDetail(data);
Scene scene = new Scene(userAccounts);
stage.setScene(scene);
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//set Stage boundaries to visible bounds of the main screen
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.initStyle(StageStyle.UNDECORATED);
scene.setFill(null);
stage.initStyle(StageStyle.TRANSPARENT);
stage.show();
}
@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();
}
@FXML
private void viewDoctorAccounts()
{
Stage stage = new Stage();
UserAccountController userAccounts = new UserAccountController("doctor",admin);
ArrayList<ArrayList<String>> data = admin.getUserInfo("doctor");
userAccounts.fillUserDetail(data);
Scene scene = new Scene(userAccounts);
stage.setScene(scene);
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//set Stage boundaries to visible bounds of the main screen
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.initStyle(StageStyle.UNDECORATED);
scene.setFill(null);
stage.initStyle(StageStyle.TRANSPARENT);
stage.show();
}
@FXML
public void showSuccessIndicator()
{
Stage stage= new Stage();
SuccessIndicatorController success = new SuccessIndicatorController();
Scene scene = new Scene(success);
stage.setScene(scene);
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//set Stage boundaries to visible bounds of the main screen
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.initStyle(StageStyle.UNDECORATED);
scene.setFill(null);
stage.initStyle(StageStyle.TRANSPARENT);
stage.show();
}
@FXML private void addTimeSlot()
{
Stage stage= new Stage();
NewDoctorTimeSlotController addslot = new NewDoctorTimeSlotController(doc,this);
Scene scene = new Scene(addslot);
stage.setScene(scene);
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//set Stage boundaries to visible bounds of the main screen
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.initStyle(StageStyle.UNDECORATED);
scene.setFill(null);
stage.initStyle(StageStyle.TRANSPARENT);
stage.show();
}
@FXML private void showAppointments()
{
Stage stage= new Stage();
AllAppointmentsController app = new AllAppointmentsController(receptionist);
app.load();
Scene scene = new Scene(app);
stage.setScene(scene);
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//set Stage boundaries to visible bounds of the main screen
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.initStyle(StageStyle.UNDECORATED);
scene.setFill(null);
stage.initStyle(StageStyle.TRANSPARENT);
stage.show();
}
@FXML
public void showSuccessIndicator()
{
Stage stage= new Stage();
SuccessIndicatorController success = new SuccessIndicatorController();
Scene scene = new Scene(success);
stage.setScene(scene);
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//set Stage boundaries to visible bounds of the main screen
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.initStyle(StageStyle.UNDECORATED);
scene.setFill(null);
stage.initStyle(StageStyle.TRANSPARENT);
stage.show();
}
@FXML
public void showRefundTable()
{
Stage stage= new Stage();
RefundController refundTable = new RefundController(this);
refundTable.fillRefundTable();
Scene scene = new Scene(refundTable);
stage.setScene(scene);
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//set Stage boundaries to visible bounds of the main screen
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.initStyle(StageStyle.UNDECORATED);
scene.setFill(null);
stage.initStyle(StageStyle.TRANSPARENT);
stage.show();
}
private double getY() {
double h1 = Screen.getPrimary().getBounds().getWidth();
double h2 = 0;
if (Screen.getScreens().size() == 2) {
h2 = Screen.getScreens().get(1).getBounds().getWidth();
}
// check if mainScene is on primary or secondary and set h0
double m = getMonitor(h2);
double h0 = 0;
if (m == 1)
h0 = h1;
else
h0 = h2;
//System.out.println("height is " + h0);
if (null == stageRef) return calcY( 0.0, h0 );
return calcY(stageRef.getY(), stageRef.getHeight());
}
public void loadDoctor(String username)
{
Stage stage = new Stage();
DoctorController doctor = new DoctorController(username);
doctor.fillAreaChart();
doctor.setAppointments();
doctor.loadProfileData();
doctor.MakeAvailabilityTable();
doctor.loadDrugList();
doctor.loadTestList();
doctor.setPaceholders();
doctor.addFocusListener();
doctor.loadNameList();
stage.setScene(new Scene(doctor));
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//set Stage boundaries to visible bounds of the main screen
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.initStyle(StageStyle.UNDECORATED);
stage.show();
}
public void loadPharmacist(String username)
{
Stage stage = new Stage();
PharmacistController pharmacist = new PharmacistController(username);
pharmacist.loadProfileData();
pharmacist.makeStockTable();
pharmacist.fillBarChart();
pharmacist.fillPieChart();
pharmacist.setPaceholders();
pharmacist.loadNameList();
pharmacist.addFocusListener();
stage.setScene(new Scene(pharmacist));
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//set Stage boundaries to visible bounds of the main screen
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.initStyle(StageStyle.UNDECORATED);
stage.show();
}
public void loadReceptionist(String username)
{
Stage stage = new Stage();
ReceptionistController receptionist = new ReceptionistController(username);
receptionist.loadProfileData();
receptionist.makeSummaryTable();
receptionist.fillLineChart();
receptionist.fillCurrentDoctors();
//receptionist.fillConsultationAreas();
receptionist.setPaceholders();
stage.setScene(new Scene(receptionist));
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//set Stage boundaries to visible bounds of the main screen
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.initStyle(StageStyle.UNDECORATED);
stage.show();
}
@FXML
private void viewReceptionistAccounts()
{
Stage stage = new Stage();
UserAccountController userAccounts = new UserAccountController("receptionist",admin);
ArrayList<ArrayList<String>> data = admin.getUserInfo("receptionist");
userAccounts.fillUserDetail(data);
Scene scene = new Scene(userAccounts);
stage.setScene(scene);
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//set Stage boundaries to visible bounds of the main screen
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.initStyle(StageStyle.UNDECORATED);
scene.setFill(null);
stage.initStyle(StageStyle.TRANSPARENT);
stage.show();
}
@FXML private void showMessage()
{
AllMessages message = (AllMessages)messagesTable.getSelectionModel().getSelectedItem();
//System.out.println(message.getMessage());
Stage stage= new Stage();
ReadMessageController newMessage = new ReadMessageController(message,newSysUser);
newMessage.fillMessage();
Scene scene = new Scene(newMessage);
stage.setScene(scene);
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//set Stage boundaries to visible bounds of the main screen
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.initStyle(StageStyle.UNDECORATED);
scene.setFill(null);
stage.initStyle(StageStyle.TRANSPARENT);
stage.show();
}
public void showSuccessIndicator()
{
Stage stage= new Stage();
SuccessIndicatorController success = new SuccessIndicatorController();
Scene scene = new Scene(success);
stage.setScene(scene);
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//set Stage boundaries to visible bounds of the main screen
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setWidth(primaryScreenBounds.getWidth());
stage.setHeight(primaryScreenBounds.getHeight());
stage.initStyle(StageStyle.UNDECORATED);
scene.setFill(null);
stage.initStyle(StageStyle.TRANSPARENT);
stage.show();
}