'How to get the window size in R with rJava?

In regard to that answer, I do not want the screen size but the window size, i.e. it is supposed to get smaller when the user changes the size of the window;

Almost the solution

I tried to use the answer given here ending up with the following code but cannot make it work;

library(rJava)
.jinit()
toolkit <- J("java.awt.Toolkit")
default_toolkit <- .jrcall(toolkit, "getDefaultToolkit")
dim <- .jrcall(default_toolkit, "getWindowSize")
height <- .jcall(dim, "D", "getHeight")
width <- .jcall(dim, "D", "getWidth")


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source