这是我写的一个程序的一部分:
public enum Location {
TOP, RIGHT, BOTTOM, LEFT;
}
private static final class Taskbar {
public final Location location;
public final int width, height;
private Taskbar(Location location, int width, int height) {
this.location = location;
this.width = width;
this.height = height;
}
public static Taskbar getTaskbar() {
Rectangle other = GraphicsEnvironment.getLocalGraphicsEnvironment()
.getMaximumWindowBounds();
return new Taskbar(other.x != 0 ? Location.TOP
: (other.y != 0 ? Location.LEFT
: (other.width == IFrame.width ? Location.BOTTOM
: Location.RIGHT)), IFrame.width
- other.width, IFrame.height - other.height);
}
}
本质上,主叫Taskbar.getTaskbar()
将得到含有在其位置(TOP
,RIGHT
,BOTTOM
,LEFT
),它的宽度,而其高度信息的任务栏。
你使用Jframe/frame吗? – Pratik
对不起,我正在使用JFrame – mastaH