javafx.stage.Window Java Examples

The following examples show how to use javafx.stage.Window. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResponsiveHandler.java    From ResponsiveFX with Apache License 2.0 6 votes vote down vote up
public static void addResponsiveToWindow(Window window) {
    StringProperty stylesheet = new SimpleStringProperty(getCurrentResponsiveStylesheet(window));
    Util.bindStyleSheetToWindow(window, stylesheet);

    updatePseudoClassesForAllChildren(window);
    //TODO: Falsch! Hier muss der ursprünglich gesetzte Wert gespeichert werden! managed müsste eine styledProperty sein
    updateManagedPropertyForAllChildren(window);

    Util.registerRecursiveChildObserver(window, n -> removeAllPseudoClasses(n), n -> updatePseudoClasses(n, getTypeForWindow(window)));

    window.widthProperty().addListener(e -> {
        stylesheet.setValue(getCurrentResponsiveStylesheet(window));
        updatePseudoClassesForAllChildren(window);
        updateManagedPropertyForAllChildren(window);
    });
    window.getScene().getRoot().layout();
}
 
Example #2
Source File: NicePopup.java    From Open-Lowcode with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * creates a Nice popup
 * 
 * @param parentnode      parent node
 * @param popupnode       popup node
 * @param parentwindow    parent window
 * @param allowscroll     if true, scroll is allowed
 * @param showunderwidget true for a lightweight component, false for a
 *                        heavyweigth component
 * @param shownow         if true, show now, if false, show later
 */
public NicePopup(
		Node parentnode,
		Node popupnode,
		Window parentwindow,
		boolean allowscroll,
		boolean showunderwidget,
		boolean shownow) {
	this.parentnode = parentnode;
	this.popupnode = popupnode;
	this.parentwindow = parentwindow;
	this.allowscroll = allowscroll;
	this.showunderwidget = showunderwidget;
	if (shownow)
		show();
}
 
Example #3
Source File: BrokerConfigGuiActionsHandler.java    From kafka-message-tool with MIT License 6 votes vote down vote up
public BrokerConfigGuiActionsHandler(TabPaneSelectionInformer tabSelectionInformer,
                                     ListViewActionsHandler<KafkaBrokerConfig> listViewActionsHandler,
                                     UserInteractor interactor,
                                     ModelDataProxy modelDataProxy,
                                     ControllerProvider controllerProvider,
                                     AnchorPane parentPane,
                                     Window parentWindow) {
    super(tabSelectionInformer, listViewActionsHandler);

    this.listViewActionsHandler = listViewActionsHandler;
    this.interactor = interactor;
    this.modelDataProxy = modelDataProxy;
    this.controllerProvider = controllerProvider;
    this.parentWindow = parentWindow;
    this.parentPane = parentPane;
    this.fromPojoConverter = new FromPojoConverter(modelDataProxy);

}
 
Example #4
Source File: NewPurchaseMethodDialogController.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
@FXML
private void onOk(final ActionEvent actionEvent)
{
	// possibly replace with ControlsFX validation framework

	if (getEnteredName().isEmpty())
	{
		Alert alert = new Alert(Alert.AlertType.ERROR);
		alert.setTitle(Constants.APPLICATION_NAME);
		// todo: i18n
		alert.setContentText("Please enter a name for this method.");
		alert.initOwner(newPurchaseDialog.getWindow());
		alert.showAndWait();
		return;
	}

	model.setCancelled(false);
	Platform.runLater(() -> {
		Window window = newPurchaseDialog.getWindow();
		window.hide();
	});
}
 
Example #5
Source File: Overlay.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
protected void cleanup() {
    if (centerTime != null)
        centerTime.stop();

    if (owner == null)
        owner = MainView.getRootContainer();
    Scene rootScene = owner.getScene();
    if (rootScene != null) {
        Window window = rootScene.getWindow();
        if (window != null && positionListener != null) {
            window.xProperty().removeListener(positionListener);
            window.yProperty().removeListener(positionListener);
            window.widthProperty().removeListener(positionListener);
        }
    }
}
 
Example #6
Source File: InfiniteCanvasViewer.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
private void onSceneChanged(Scene oldScene, Scene newScene) {
	Window oldWindow = null;
	Window newWindow = null;
	Node oldFocusOwner = null;
	Node newFocusOwner = null;
	if (oldScene != null) {
		oldWindow = oldScene.windowProperty().get();
		oldScene.windowProperty().removeListener(windowObserver);
		oldFocusOwner = oldScene.focusOwnerProperty().get();
		oldScene.focusOwnerProperty().removeListener(focusOwnerObserver);
	}
	if (newScene != null) {
		newWindow = newScene.windowProperty().get();
		newScene.windowProperty().addListener(windowObserver);
		newFocusOwner = newScene.focusOwnerProperty().get();
		newScene.focusOwnerProperty().addListener(focusOwnerObserver);
	}
	onWindowChanged(oldWindow, newWindow);
	onFocusOwnerChanged(oldFocusOwner, newFocusOwner);
}
 
Example #7
Source File: CCollapsibleBand.java    From Open-Lowcode with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Node getNode(
		PageActionManager actionmanager,
		CPageData inputdata,
		Window parentwindow,
		TabPane[] parenttabpanes,
		CollapsibleNode nodetocollapsewhenactiontriggered) {
	Node payloadnode = payload.getNode(actionmanager, inputdata, parentwindow, parenttabpanes,
			(closewheninlineactioninside ? this : null));
	collapsiblepane = new TitledPane(this.title, payloadnode);
	collapsiblepane.setCollapsible(true);
	collapsiblepane.setExpanded(this.openbydefault);
	collapsiblepane.setBorder(Border.EMPTY);
	collapsiblepane.setAnimated(false);

	return collapsiblepane;
}
 
Example #8
Source File: Tools.java    From logbook-kai with MIT License 6 votes vote down vote up
/**
 * テーブルの内容をCSVファイルとして出力します
 *
 * @param table テーブル
 * @param title タイトル及びファイル名
 * @param own 親ウインドウ
 */
public static void store(TableView<?> table, String title, Window own) throws IOException {
    String body = table.getItems()
            .stream()
            .map(Object::toString)
            .collect(Collectors.joining(CSV_NL))
            .replaceAll(SEPARATOR, CSV_SEPARATOR);
    String content = new StringJoiner(CSV_NL)
            .add(tableHeader(table, CSV_SEPARATOR))
            .add(body)
            .toString();

    FileChooser chooser = new FileChooser();
    chooser.setTitle(title + "の保存");
    chooser.setInitialFileName(title + ".csv");
    chooser.getExtensionFilters().addAll(
            new ExtensionFilter("CSV Files", "*.csv"));
    File f = chooser.showSaveDialog(own);
    if (f != null) {
        Files.write(f.toPath(), content.getBytes(LogWriter.DEFAULT_CHARSET));
    }
}
 
Example #9
Source File: WindowChecker.java    From scenic-view with GNU General Public License v3.0 6 votes vote down vote up
@Override public void run() {
    // Keep iterating until we have a any windows.
    // If we past the maximum wait time, we'll exit
    long currentWait = -1;
    List<Window> windows = getValidWindows(filter);
    while (running) {
        onWindowsFound(windows);
        try {
            // Logger.print("No JavaFX window found - sleeping for " + sleepTime / 1000 + " seconds");
            Thread.sleep(sleepTime);
            if (maxWaitTime != -1) {
                currentWait += sleepTime;
            }

            if (currentWait > maxWaitTime) {
                finish();
            }
        } catch (final InterruptedException ex) {
            if (running) {
                ExceptionLogger.submitException(ex);
            }
        }

        windows = getValidWindows(filter);
    }
}
 
Example #10
Source File: DefaultControllerProvider.java    From kafka-message-tool with MIT License 6 votes vote down vote up
@Override
public BrokerConfigView getBrokerConfigGuiController(KafkaBrokerConfig config,
                                                     AnchorPane parentPane,
                                                     Runnable refeshCallback,
                                                     UserInteractor guiInteractor,
                                                     Window parentWindow) {
    return getControllerFor(config, brokerControllers, () -> {
        try {
            return new BrokerConfigView(config,
                                        parentPane,
                                        guiInformer,
                                        parentWindow,
                                        refeshCallback,
                                        guiInteractor,
                                        statusChecker,
                                        kafkaClusterProxies);
        } catch (IOException e) {
            Logger.error(e);
            return null;
        }
    });
}
 
Example #11
Source File: StageUtils.java    From NSMenuFX with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void updateStages() {
	List<Stage> currentStages = new LinkedList<>();
	for (Window w : windows) {
		if (w instanceof Stage) {
			currentStages.add((Stage)w);
		}
	}

	// Remove no-longer existing stages
	stages.removeIf(stage -> !currentStages.contains(stage));

	// Add any new stages
	currentStages.stream()
			.filter(currentStage -> !stages.contains(currentStage))
			.forEach(newStage -> stages.add(newStage));
}
 
Example #12
Source File: JavaFXTargetLocator.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
private List<Window> getContextMenu() {
    List<Window> contextMenus = new ArrayList<>();
    new Wait("Unable to context menu") {
        @Override
        public boolean until() {
            Iterator<Window> windows = JavaCompatibility.getWindows();
            while (windows.hasNext()) {
                Window window = windows.next();
                if (window instanceof ContextMenu) {
                    contextMenus.add(window);
                }
            }
            return contextMenus.size() > 0;
        }
    };
    ;
    return contextMenus;
}
 
Example #13
Source File: InfiniteCanvasViewer.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
private void onWindowChanged(Window oldValue, Window newValue) {
	if (oldValue != null) {
		oldValue.focusedProperty().removeListener(windowFocusedObserver);
	}
	if (newValue != null) {
		newValue.focusedProperty().addListener(windowFocusedObserver);
		// check if window is focused
		if (Boolean.TRUE.equals(newValue.focusedProperty().get())) {
			isWindowFocused = true;
			viewerFocusedPropertyBinding.invalidate();
		}
	} else {
		// window unfocused
		isInitialized = false;
		isWindowFocused = false;
		viewerFocusedPropertyBinding.invalidate();
	}
}
 
Example #14
Source File: SelectRootPathUtils.java    From PeerWasp with MIT License 6 votes vote down vote up
public static String showDirectoryChooser(String pathAsString, Window toOpenDialog) {
	DirectoryChooser chooser = new DirectoryChooser();
	chooser.setTitle("Choose your root directory");

	// if parent of given directory does exist, we open chooser with that location.
	// otherwise, take the user home as fallback.
	File path = new File(pathAsString).getParentFile();
	if(path.getParentFile().exists()) {
		chooser.setInitialDirectory(path.getParentFile());
	} else {
		chooser.setInitialDirectory(FileUtils.getUserDirectory());
	}

	try {
		File selectedDirectory = chooser.showDialog(toOpenDialog);
		if (selectedDirectory != null) {
			return selectedDirectory.getAbsolutePath();
		}
	} catch (IllegalArgumentException e) {
		SelectRootPathUtils.showInvalidDirectoryChooserEntryInformation();
		return pathAsString;
	}
	return pathAsString;
}
 
Example #15
Source File: CardPlayedToken.java    From metastone with GNU General Public License v2.0 6 votes vote down vote up
public CardPlayedToken(GameBoardView boardView, Card card) {
	Window parent = boardView.getScene().getWindow();
	this.cardToken = new CardTooltip();

	popup = new Popup();
	popup.getContent().setAll(cardToken);
	popup.setX(parent.getX() + 40);
	popup.show(parent);
	popup.setY(parent.getY() + parent.getHeight() * 0.5 - cardToken.getHeight() * 0.5);

	cardToken.setCard(card);

	NotificationProxy.sendNotification(GameNotification.ANIMATION_STARTED);
	FadeTransition animation = new FadeTransition(Duration.seconds(1.2), cardToken);
	animation.setDelay(Duration.seconds(0.6f));
	animation.setOnFinished(this::onComplete);
	animation.setFromValue(1);
	animation.setToValue(0);
	animation.play();
}
 
Example #16
Source File: FilesController.java    From AudioBookConverter with GNU General Public License v2.0 6 votes vote down vote up
public void selectFolderDialog() {
    Window window = ConverterApplication.getEnv().getWindow();
    DirectoryChooser directoryChooser = new DirectoryChooser();
    String sourceFolder = AppProperties.getProperty("source.folder");
    directoryChooser.setInitialDirectory(Utils.getInitialDirecotory(sourceFolder));

    StringJoiner filetypes = new StringJoiner("/");

    Arrays.stream(FILE_EXTENSIONS).map(String::toUpperCase).forEach(filetypes::add);

    directoryChooser.setTitle("Select folder with " + filetypes.toString() + " files for conversion");
    File selectedDirectory = directoryChooser.showDialog(window);
    if (selectedDirectory != null) {
        processFiles(Collections.singleton(selectedDirectory));
        AppProperties.setProperty("source.folder", selectedDirectory.getAbsolutePath());
        if (!chaptersMode.get()) {
            filesChapters.getTabs().add(filesTab);
            filesChapters.getSelectionModel().select(filesTab);
        }
    }
}
 
Example #17
Source File: CMultipleChoiceField.java    From Open-Lowcode with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Node getNode(
		PageActionManager actionmanager,
		CPageData inputdata,
		Window parentwindow,
		TabPane[] parenttabpanes,
		CollapsibleNode nodetocollapsewhenactiontriggered) {
	CChoiceFieldValue[] currentchoice = null;
	ArrayList<String> restrictedvalues = null;
	if (this.multipledefaultvaluecode != null) {
		currentchoice = new CChoiceFieldValue[multipledefaultvaluecode.length];
		for (int i = 0; i < this.multipledefaultvaluecode.length; i++) {
			currentchoice[i] = findChoiceFromStoredValue(multipledefaultvaluecode[i]);
		}
	}
	if (this.multipledefaultvaluecode==null) if (this.preselectedvalues.size()>0) {
		currentchoice = new CChoiceFieldValue[this.preselectedvalues.size()];
		for (int i=0;i<this.preselectedvalues.size();i++) currentchoice[i] = this.preselectedvalues.get(i);
	}
	choicefield = new ChoiceField(actionmanager, compactshow, twolines, label, helper, isactive, iseditable, false,
			values, currentchoice, restrictedvalues);
	Node node = choicefield.getNode();
	this.checkboxpanel = choicefield.getCheckBoxList();
	return node;
}
 
Example #18
Source File: dashController.java    From gramophy with GNU General Public License v3.0 6 votes vote down vote up
@FXML
public void selectMusicLibraryFolderButtonClicked(ActionEvent event)
{
    Node e = (Node) event.getSource();
    Window ps = e.getScene().getWindow();
    DirectoryChooser directoryChooser = new DirectoryChooser();
    File newMusicFolder = directoryChooser.showDialog(ps);
    File presentFolder = new File(config.get("music_lib_path"));

    if(newMusicFolder == null) return;

    if(!newMusicFolder.getAbsolutePath().equals(presentFolder.getAbsolutePath()))
    {
        selectMusicLibraryField.setText(newMusicFolder.getAbsolutePath());
    }
}
 
Example #19
Source File: MainMenuController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@FXML
protected void closeOtherWindows(ActionEvent event) {
    List<Window> windows = new ArrayList<>();
    windows.addAll(Window.getWindows());
    for (Window window : windows) {
        if (parentController != null) {
            if (!window.equals(parentController.getMyStage())) {
                window.hide();
            }
        } else {
            if (!window.equals(myStage)) {
                window.hide();
            }
        }
    }
}
 
Example #20
Source File: EdmConverterApplication.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public AppInstance create(final URI resource)
{
    final Window window = DockPane.getActiveDockPane().getScene().getWindow();

    // Check colors.list
    if (ConverterPreferences.colors_list.isBlank())
    {
        ExceptionDetailsErrorDialog.openError("EDM Converter",
            "EDM colors.list is not defined.\nConfigure it in the converter settings.",
            new Exception("Need colors.list"));
        return null;
    }

    // Perform actual conversion in background thread
    JobManager.schedule("Convert " + resource, monitor ->
    {
        try
        {
            // Convert file
            final File input = ModelResourceUtil.getFile(resource);
            final File output = new File(input.getAbsolutePath().replace(".edl", ".bob"));
            logger.log(Level.INFO, "Converting " + input + " to " + output);
            EdmModel.reloadEdmColorFile(ConverterPreferences.colors_list, ModelResourceUtil.openResourceStream(ConverterPreferences.colors_list));
            new EdmConverter(input, null).write(output);

            // On success, open in display editor, runtime, other editor
            Platform.runLater(() ->
                ApplicationLauncherService.openFile(output, true, (Stage)window));
        }
        catch (Exception ex)
        {
            ExceptionDetailsErrorDialog.openError(DISPLAY_NAME, "Failed to convert " + resource, ex);
        }
    });
    return null;
}
 
Example #21
Source File: RefImplToolBar.java    From FXMaps with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Initializes the control for choosing/creating maps
 */
public void initRouteSelector() {
    routeCombo = new CheckComboBox<>();
    // Make sure window resizes with combo box size changes due to display additions
    routeCombo.layoutBoundsProperty().addListener((v, o, n) -> {
        Window w = routeFlyout.getFlyoutContainer().getScene().getWindow();
        if(w != null) {
            w.setWidth(w.getWidth() + (n.getWidth() - o.getWidth()));
        }
    });
    
    //routeCombo.setEditable(true);
    //routeCombo.setPromptText("Type route name...");
    //routeCombo.valueProperty().addListener(getRouteSelectionListener());
}
 
Example #22
Source File: SubWindowChecker.java    From scenic-view with GNU General Public License v3.0 5 votes vote down vote up
@Override protected void onWindowsFound(final List<Window> tempPopups) {
    tree.clear();
    windows.clear();

    for (final Window popupWindow : tempPopups) {
        final Map<PopupWindow, Map> pos = valid((PopupWindow) popupWindow, tree);
        if (pos != null) {
            pos.put((PopupWindow) popupWindow, new HashMap<PopupWindow, Map>());
            windows.add((PopupWindow) popupWindow);
        }
    }
    if (!tree.equals(previousTree)) {
        previousTree.clear();
        previousTree.putAll(tree);
        final List<PopupWindow> actualWindows = new ArrayList<>(windows);
        Platform.runLater(new Runnable() {

            @Override public void run() {
                // No need for synchronization here
                model.popupWindows.clear();
                model.popupWindows.addAll(actualWindows);
                model.update();

            }
        });

    }

}
 
Example #23
Source File: SubWindowChecker.java    From scenic-view with GNU General Public License v3.0 5 votes vote down vote up
public SubWindowChecker(final StageControllerImpl model) {
    super(new WindowFilter() {
        @Override public boolean accept(final Window window) {
            return window instanceof PopupWindow;
        }
    }, model.getID().toString());
    this.model = model;
}
 
Example #24
Source File: HelpDialogController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
@FXML
public void close(ActionEvent evt) {

    //
    // For some reason, this.getScene() which is on the fx:root returns null
    //

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
Example #25
Source File: HideOnEscapeHandlerTest.java    From pdfsam with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test
public void notShowingNoMatch() {
    Window window = spy(new Window() {
    });
    HideOnEscapeHandler victim = new HideOnEscapeHandler(window);
    victim.handle(
            new KeyEvent(KeyEvent.KEY_RELEASED, KeyCode.A.toString(), "", KeyCode.A, false, false, false, false));
    verify(window, never()).hide();
}
 
Example #26
Source File: FX.java    From FxDock with Apache License 2.0 5 votes vote down vote up
public static FxWindow getWindow(Node n)
{
	Scene sc = n.getScene();
	if(sc != null)
	{
		Window w = sc.getWindow();
		if(w instanceof FxWindow)
		{
			return (FxWindow)w;
		}
	}
	return null;
}
 
Example #27
Source File: Util.java    From ResponsiveFX with Apache License 2.0 5 votes vote down vote up
public static void registerRecursiveChildObserver(Window window, Consumer<Node> onRemove, Consumer<Node> onAdd) {
    List<Node> allNodes = getAllNodesInWindow(window);
    ListChangeListener<Node> listener = createRecursiveChildObserver(onRemove, onAdd);
    for (Node child : allNodes) {
        if (child instanceof Parent) {
            Parent parent = (Parent) child;
            parent.getChildrenUnmodifiable().addListener(listener);
        }
    }
}
 
Example #28
Source File: RFXComponent.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private Stage getStage(Window window) {
    if (window instanceof Stage) {
        return (Stage) window;
    }
    if (window instanceof PopupWindow) {
        Node ownerNode = ((PopupWindow) window).getOwnerNode();
        ownerNode.getScene().getWindow();
        return getStage(ownerNode.getScene().getWindow());
    }
    return null;
}
 
Example #29
Source File: Dialog.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Show warning dialog box as parentStage child
 * <p/>
 * @param title dialog title
 * @param message dialog message
 * @param owner parent window
 */
public static void showWarning(String title, String message, Window owner) {
    new Builder()
            .create()
            .setOwner(owner)
            .setTitle(title)
            .setWarningIcon()
            .setMessage(message)
            .addOkButton()
            .build()
            .show();
}
 
Example #30
Source File: DockStage.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** @return All currently open dock stages (safe copy) */
public static List<Stage> getDockStages()
{
    final List<Stage> dock_windows = new ArrayList<>();
    // Having a KEY_ID property implies that the Window
    // is a Stage that was configured as a DockStage
    for (Window window : Window.getWindows())
        if (window.getProperties().containsKey(KEY_ID))
            dock_windows.add((Stage) window);

    return dock_windows;
}