jajuk-team / jajuk

Advanded jukebox for users with large or scattered music collections
49 stars 19 forks source link

Jajuk Window no more visible when unmaximalizing #2044

Closed bflorat closed 3 years ago

bflorat commented 4 years ago

Ubuntu / openjdk 13 : when unmaximalizing the window, no more window is displayed at all.

gkerdal commented 4 years ago

Same problem with openjdk 11 and oracle Jdk 11. It seems that the restore works only if Jajuk is not launch previously with maximum size. If the jajuk window opens in fullscreen, the restore size doesn't exist and the window gets a 1*1 size. If you click on Alt+Space you can maximize or enlarge the window to get back to a visible size.

I found a workaround, it is to handle the resize event of the JajukMainWindow, if the height or width is below 10 (10 is probably not the best choice) I set the minimum size with the constants :+1:

Here is the code to put in initUI method of JajukMainWindow

addComponentListener(new ComponentAdapter() {
  public void componentResized(ComponentEvent componentEvent) {
    if (getSize().getHeight() < 10 || getSize().getHeight() < 10) {
      setSize(FRAME_MIN_WIDTH_PX, FRAME_MIN_HEIGHT_PX);
    }
  }
});

Another solution is to get the size which is stored in the conf.properties file if it exists.

gkerdal commented 4 years ago

I finally put the following code in maximalize() method :

    if (getSize().getHeight() <= 1 || getSize().getHeight() <= 1) {
      // Prevents the main window to be restored with a size of 1*1, after opening Jajuk with maximal size 
      setSize(new Dimension(FRAME_MIN_WIDTH_PX, FRAME_MIN_HEIGHT_PX));
    }