本文整理匯總了Java中java.awt.Window.getSize方法的典型用法代碼示例。如果您正苦於以下問題:Java Window.getSize方法的具體用法?Java Window.getSize怎麽用?Java Window.getSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.Window
的用法示例。
在下文中一共展示了Window.getSize方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getGUISnapshots
import java.awt.Window; //導入方法依賴的package包/類
static Snapshot[] getGUISnapshots() {
List snapshots = new ArrayList(); //System.err.println("gGUI: thread = "+Thread.currentThread());
Window[] windows = Window.getWindows(); //System.err.println("gGUI: windows = "+windows.length);
for (int wi = 0; wi < windows.length; wi++) {
Window w = windows[wi]; //System.err.println("gGUI: w["+wi+"] = "+w+", is visible = "+w.isVisible());
if (!w.isVisible()) {
continue;
}
Dimension d = w.getSize(); //System.err.println("gGUI: size = "+d);
if (d.width == 0 || d.height == 0) {
continue;
}
BufferedImage bi = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = bi.createGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT);
w.paint(g);
Raster raster = bi.getData();
Object data = raster.getDataElements(0, 0, d.width, d.height, null);
int[] dataArr; //System.err.println("gGUI: data = "+data);
if (data instanceof int[]) {
dataArr = (int[]) data;
} else {
continue;
}
String title = null;
if (w instanceof Frame) {
title = ((Frame) w).getTitle();
} else if (w instanceof Dialog) {
title = ((Dialog) w).getTitle();
} //System.err.println("gGUI: title = "+title);
snapshots.add(new Snapshot(w, title, d.width, d.height, dataArr));
}
Snapshot[] snapshotArr = (Snapshot[]) snapshots.toArray(new Snapshot[] {});
lastGUISnapshots = snapshotArr;
return snapshotArr;
}
示例2: makeDialogWider
import java.awt.Window; //導入方法依賴的package包/類
private void makeDialogWider(int delta) {
Window w = SwingUtilities.getWindowAncestor(this);
if (w != null) {
Dimension size = w.getSize();
size.width += delta;
w.setSize(size);
}
}
示例3: removeNotify
import java.awt.Window; //導入方法依賴的package包/類
public void removeNotify () {
// save dialog size on click at [x] in titlebar
Window dlg = SwingUtilities.getWindowAncestor(this);
if( null != dlg )
getDefault().previousDialogSize = dlg.getSize();
super.removeNotify();
explorer.removePropertyChangeListener(this);
}
示例4: centre
import java.awt.Window; //導入方法依賴的package包/類
public static void centre(Window w) {
Dimension us = w.getSize();
Dimension them = Toolkit.getDefaultToolkit().getScreenSize();
int newX = (them.width - us.width) / 2;
int newY = (them.height - us.height) / 2;
w.setLocation(newX, newY);
}
示例5: setExpanded
import java.awt.Window; //導入方法依賴的package包/類
public void setExpanded(boolean expanded) {
final Window w = SwingUtilities.getWindowAncestor(expander);
final Dimension ws = w.getSize();
if (!expander.isVisible()) {
setText(hideText);
setIcon(expandedIcon);
expander.setVisible(true);
ws.height += eh;
if (!expander.isPreferredSizeSet()) {
expander.setSize(buddy.getWidth(), 300);
}
}
else {
setText(showText);
setIcon(collapsedIcon);
eh = expander.getHeight();
expander.setVisible(false);
ws.height -= eh;
}
fixSize(w);
w.setSize(ws);
w.doLayout();
}
示例6: getTitlePoint
import java.awt.Window; //導入方法依賴的package包/類
public static Point getTitlePoint(Window decoratedWindow) {
Point p = decoratedWindow.getLocationOnScreen();
Dimension d = decoratedWindow.getSize();
return new Point(p.x + (int)(d.getWidth()/2),
p.y + (int)(decoratedWindow.getInsets().top/2));
}
示例7: main
import java.awt.Window; //導入方法依賴的package包/類
public static void main(final String[] args) {
final GraphicsEnvironment ge = GraphicsEnvironment
.getLocalGraphicsEnvironment();
final GraphicsDevice[] devices = ge.getScreenDevices();
final Window wGreen = new Frame();
wGreen.setBackground(Color.GREEN);
wGreen.setSize(300, 300);
wGreen.setVisible(true);
sleep();
final Insets iGreen = wGreen.getInsets();
final Dimension sGreen = wGreen.getSize();
final Window wRed = new Frame();
wRed.setBackground(Color.RED);
wRed.setSize(300, 300);
wRed.setVisible(true);
sleep();
final Insets iRed = wGreen.getInsets();
final Dimension sRed = wGreen.getSize();
for (final GraphicsDevice device : devices) {
if (!device.isFullScreenSupported()) {
continue;
}
device.setFullScreenWindow(wGreen);
sleep();
testWindowBounds(device.getDisplayMode(), wGreen);
testColor(wGreen, Color.GREEN);
device.setFullScreenWindow(wRed);
sleep();
testWindowBounds(device.getDisplayMode(), wRed);
testColor(wRed, Color.RED);
device.setFullScreenWindow(null);
sleep();
testInsets(wGreen.getInsets(), iGreen);
testInsets(wRed.getInsets(), iRed);
testSize(wGreen.getSize(), sGreen);
testSize(wRed.getSize(), sRed);
}
wGreen.dispose();
wRed.dispose();
if (!passed) {
throw new RuntimeException("Test failed");
}
}