4

I am troubling at GUI position of my application. That means in Linux (Centos 6) it's appear correctly from above task bar but in windows 8.1 it's appearing behind the task bar from the bottom of screen. What may would be the issue ?

I am using following code for set dimensions. (I have attached screens below)

UiConfig.getInstance().bottomRightUI(dispalyWidth, displayeHeight);

setBounds(UiConfig.getInstance().getX(), UiConfig.getInstance().getY(),
dispalyWidth, displayeHeight);

Following class used for obtain dynamic dimension from current screen

public class UiConfig {

private static final UiConfig instance = new UiConfig();

public static UiConfig getInstance() {
    return instance;
}

public void bottomRightUI(int width, int height) {
    x = (int) ((screen_width - width));
    y = (int) ((screen_height - height));
}

public int getX() {
    return this.x;
}

public int getY() {
    return this.y;
}

}

On Linux

GUI on Linux

On Windows

GUI on Windows

Chaminda Bandara
  • 2,067
  • 2
  • 28
  • 31
  • Isn't there a windows setting to keep the taskbar in the front at all times? Doesn't seem related to Java to me. – Thomas Feb 05 '16 at 09:36
  • @Thomas ; Other applications working on windows fine (means normally ). – Chaminda Bandara Feb 05 '16 at 09:41
  • 3
    Its a standard behaviour for windows to render the taskbar over everything except borderless windows (like games with a borderless window feature, but they are commonly rendered with DirectX). I don't think its possible to render a window in front of it. @ChamindaBandara So other applications will be rendered overthe Taskbar? – AntiHeadshot Feb 05 '16 at 09:42
  • 2
    Yes, that would be expected behavior for the OS. I would calculate the "safe" region on the screen and set the location of the window within it. Maybe something like [this](http://stackoverflow.com/questions/14189057/determine-height-of-screen-in-java/14189143#14189143) – MadProgrammer Feb 05 '16 at 09:42
  • TaskBar returns integer value (pixels) by using GraphicsEnviroment, now out of idea in the case if is TaskBar hidable – mKorbel Feb 05 '16 at 11:00
  • @AntiHeadshot So how can I avoid the task-bar ? I mean how we can push to top of the screen from bottom. Is there are any possibility to get dimensions of task-bar and if it's why its working properly on Linux ? – Chaminda Bandara Feb 05 '16 at 11:03
  • @mKorbel after trying MadProgrammer and your suggestions may give feedback soon – Chaminda Bandara Feb 05 '16 at 11:07

1 Answers1

1

To achieve task bar transparency on Windows, it needs to report the desktop size as "without the taskbar" to have pixels to mix with the alpha channel of the taskbar. When you set the task bar to be non-transparent, you'll get the behavior you desire.

Swing / Java is being fed the numbers on the screen dimensions by the operating system, and if it is fed a set of numbers, it will use them as it's been instructed.

The only fix for this would be to write custom "operating system" detecting code, custom "task bar" detecting code for the problematic operating systems, and write swing reconfiguration routines to "adjust" the dimensions to a smaller footprint despite what the operating system is reporting the footprint is. This kind of code is highly non-portable, and certainly wasn't needed when Swing was created, so it's not in Swing natively.

Edwin Buck
  • 69,361
  • 7
  • 100
  • 138