這是我寫的一個程序的一部分:
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