B4J Question Fullscreen with OSX

madru

Active Member
Licensed User
Longtime User
Hi,

any advise how to deal with fullscreen forms in OSX ?

In Linux and Win you can have a fullscreen Form and a decorated standart form in front. OSX will zoom every decorated form to fullscreen if the main form is set to fullscreen. Using any decoration will repaint the fullscreen main window to black and the new non fullscreen form will not be correctly shown.

Any change to consume the "Fullscreen event" ?

THX
 
Last edited:

madru

Active Member
Licensed User
Longtime User
Ok, I give up.

I have no idea how to deal with Fullscreen in OSX.

How are you guys doing it????

If the main Form is in fullscreen all other opening forms are in fullscreen as well, or you set decoration of the new form to "Utility", but then the screen goes black and the form will only be shown half.....

advice please

THX
 
Upvote 0

madru

Active Member
Licensed User
Longtime User
I have to bring this up again....

this Java test does work correctly, you can bring the MainForm to fullscreen and open a nother form with the correct size

B4X:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package WindowTest;

//import java.awt.Insets;
import java.awt.Color;
import javafx.geometry.Insets;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author M
 */
public class WindowTest extends Application {

    @Override
    public void start(Stage primaryStage) {

        GridPane grid = new GridPane();
        grid.setAlignment(Pos.CENTER);
        grid.setHgap(10);
        grid.setVgap(10);
        grid.setPadding(new Insets(25, 25, 25, 25));

        Button btn = new Button("create frame");
        HBox hbBtn = new HBox(10);
        hbBtn.getChildren().add(btn);
        grid.add(hbBtn, 1, 4);

        final Text actiontarget = new Text();
        grid.add(actiontarget, 1, 6);

        btn.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent e) {
                /*
                JFrame frame = new JFrame();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.pack();
                frame.setSize(400, 300);
                frame.setLocationRelativeTo(null);
                frame.setVisible(true);
                 */

                JFrame frame = new JFrame("new JFrame");
                // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setLocationRelativeTo(null);
                frame.setSize(400, 300);

                JPanel panel = new JPanel();

                JLabel label = new JLabel("a label");
                panel.add(label);

                JTextField tfName = new JTextField("some text", 15);
                tfName.setForeground(Color.RED);
                tfName.setBackground(Color.YELLOW);
                panel.add(tfName);

                JButton buttonOK = new JButton("aha");
                panel.add(buttonOK);

                frame.add(panel);
                frame.setVisible(true);

            }
        });

        Scene scene = new Scene(grid, 300, 300);
        primaryStage.setScene(scene);

        primaryStage.show();
    }

    public void windowClosing(WindowEvent e) {

        System.exit(0);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }

}

this B4J code does not, bring the MainForm to fullscreen and all other forms will appear in fullscreen as well and that is not the correct behaviour in OSX

B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private Button1 As Button
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Form1") 'Load the layout file.
    MainForm.Show
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub


Sub Button1_Action
    Dim newForm As Form
    newForm.Initialize("newForm", 300,300)
    newForm.RootPane.LoadLayout("newWnd")
    newForm.Show
End Sub

THX

M
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
To be fair, your example code above, opens a javafx window, then opens a swing window.
The b4j code cannot open a swing window unless you use javaobject to create the swing window, as any window opened by b4j using Form will be a javafx window.
 
Upvote 0

madru

Active Member
Licensed User
Longtime User
mmh, you are correct

this code shows the same behaviour, I guess I have to live with it until Or**** will change that behaviour


B4X:
package fxwindow;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;


public class FXWindow extends Application {
   
    @Override
    public void start(final Stage mainWindow) {
        Button btn = new Button();
        btn.setText("New Window");
        btn.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
               
                Label secondLabel = new Label("Hello");
               
                StackPane secondaryLayout = new StackPane();
                secondaryLayout.getChildren().add(secondLabel);
               
                Scene secondScene = new Scene(secondaryLayout, 200, 100);

                Stage newWindow = new Stage();
                newWindow.setTitle("new Window");
                newWindow.setScene(secondScene);
               
                //Set position of second window, related to primary window.
                newWindow.setX(mainWindow.getX() + 250);
                newWindow.setY(mainWindow.getY() + 100);
                newWindow.show();
            }
        });
       
        StackPane root = new StackPane();
        root.getChildren().add(btn);
       
        Scene scene = new Scene(root, 300, 250);
       
        mainWindow.setTitle("title");
        mainWindow.setScene(scene);
        mainWindow.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
 
Last edited:
Upvote 0
Top