本文整理汇总了Java中java.awt.Frame.getSize方法的典型用法代码示例。如果您正苦于以下问题:Java Frame.getSize方法的具体用法?Java Frame.getSize怎么用?Java Frame.getSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Frame
的用法示例。
在下文中一共展示了Frame.getSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.awt.Frame; //导入方法依赖的package包/类
public static void main(final String[] args) {
final Frame frame = new Frame();
final TextArea ta = new TextArea();
frame.add(ta);
frame.pack();
frame.setVisible(true);
sleep();
final Dimension before = frame.getSize();
frame.pack();
final Dimension after = frame.getSize();
if (!after.equals(before)) {
throw new RuntimeException(
"Expected size: " + before + ", actual size: " + after);
}
frame.dispose();
}
示例2: main
import java.awt.Frame; //导入方法依赖的package包/类
public static void main(final String[] args) {
final Dimension expected = new Dimension(300, 300);
final Frame frame = new Frame();
final ScrollPane sp = new ScrollPane();
sp.setSize(expected);
frame.add(sp);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
sleep();
final Dimension size = frame.getSize();
if (size.width < expected.width || size.height < expected.height) {
throw new RuntimeException(
"Expected size: >= " + expected + ", actual size: " + size);
}
frame.dispose();
}
示例3: getActualSize
import java.awt.Frame; //导入方法依赖的package包/类
public static Dimension getActualSize(Frame frame) {
try {
int extendedState = frame.getExtendedState();
java.awt.Rectangle bounds = frame.getMaximizedBounds(), systemBounds = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
return new Dimension((extendedState&Frame.MAXIMIZED_HORIZ)==Frame.MAXIMIZED_HORIZ?(bounds!=null&&bounds.width !=Integer.MAX_VALUE?bounds.width :systemBounds.width ):frame.getWidth(),
(extendedState&Frame.MAXIMIZED_VERT) ==Frame.MAXIMIZED_VERT ?(bounds!=null&&bounds.height!=Integer.MAX_VALUE?bounds.height:systemBounds.height):frame.getHeight());
} catch(HeadlessException e) { return frame.getSize(); }
}