You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support "setFullScreen()" and "maximizeWindow()" #32
package com.sinvon.api.utils;
import com.sun.jna.platform.win32.WinDef;
import com.sun.jna.platform.win32.User32;
public class SetFullScreenUtil {
public static void setFullScreen(String windowTitle) {
if (windowTitle == null || windowTitle.isEmpty()) {
System.out.println("The provided window title is null or empty; unable to set the window to full screen.");
return;
}
User32 user32 = User32.INSTANCE;
// Find window handle
WinDef.HWND hWnd = user32.FindWindow(null, windowTitle);
if (hWnd == null) {
System.out.println("Failed to retrieve the window handle; unable to set the window to full screen.");
return;
}
// Get the screen dimensions
WinDef.RECT rect = new WinDef.RECT();
user32.GetWindowRect(hWnd, rect);
// Get screen width and height
int screenWidth = User32.INSTANCE.GetSystemMetrics(User32.SM_CXSCREEN);
int screenHeight = User32.INSTANCE.GetSystemMetrics(User32.SM_CYSCREEN);
// Set the window to cover the entire screen
user32.SetWindowLong(hWnd, User32.GWL_STYLE, user32.GetWindowLong(hWnd, User32.GWL_STYLE) & ~User32.WS_OVERLAPPEDWINDOW);
user32.SetWindowPos(hWnd, null, 0, 0, screenWidth, screenHeight, User32.SWP_NOZORDER | User32.SWP_SHOWWINDOW);
System.out.println("The window has been set to full screen.");
}
use the utils.
public static void main(String[] args) {
SpringApplication.run(ApiApplication.class, args);
Webview wv = new Webview(false);
String windowTitle = "gale-app";
wv.setTitle(windowTitle);
// Full screen coverage
SetFullScreenUtil.setFullScreen(windowTitle);
wv.loadURL("https://promisesaplus.com/");
wv.run();
wv.close();
}
the results show
the.result.of.full.screen.show.mp4
There are some problem.The transition animations of "webview_java" are not very smooth. I would prefer it to directly display the size I want, such as full screen or a small-sized window, instead of having a process of the window size changing. This might feel rather jarring.
@NotJustAnna Thank you so much for providing the code! 🙌
This issue has been open for over six months, and your code contribution is incredibly helpful. I really appreciate your time and expertise in tackling this problem. It means a lot to me and the project!
Activity
isinvon commentedon Oct 30, 2024
I wrote an "SetFullScreenUtil" that makes the app window full screen covering the screen.
depandency
SetFullScreenUtil
use the utils.
the results show
the.result.of.full.screen.show.mp4
There are some problem.The transition animations of "webview_java" are not very smooth. I would prefer it to directly display the size I want, such as full screen or a small-sized window, instead of having a process of the window size changing. This might feel rather jarring.
isinvon commentedon Oct 30, 2024
I wrote a "maximizeWindow()" that maximizes the app window, but for now I've only tested it on the window, and it works successfully
depandency
WindowUtils
main.java
Look at the result
Maximize.the.window.mp4
[-]Hope suport "setFullScreen()" and "maximizeWindow()"[/-][+]Support "setFullScreen()" and "maximizeWindow()"[/+]NotJustAnna commentedon Apr 8, 2025
Code works! Both implemented in NotJustAnna/webview_java@f7e7114
isinvon commentedon Apr 16, 2025
@NotJustAnna
Thank you so much for providing the code! 🙌
This issue has been open for over six months, and your code contribution is incredibly helpful. I really appreciate your time and expertise in tackling this problem. It means a lot to me and the project!