Hi all,
I want to find the height of the task bar of the PC desktop screen. It can be on any OS such as Windows, Linux, Mac..
I have done something this. Create a JFrame and maximize it by make setVisible to true. Then get the height of it and dispose it. At the same time find the screen height using Toolkit. Then take the difference of it.
My question is, even in the sudden time that JFrame is appear and dispose, it blink on the screen. I want to avoid it. Anybody can give me a solution for it.
Here is my code.
int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;
final JFrame tempFrame = new JFrame();
tempFrame.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
tempFrame.dispose();
}
public void focusLost(FocusEvent e) {
}
});
tempFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
tempFrame.setVisible(true);
int frameHeight = tempFrame.getHeight();
int taskbarHeight = screenHeight - frameHeight;
tempFrame.dispose();
Thanks.