當前位置: 首頁>>代碼示例>>Java>>正文


Java Frame.getHeight方法代碼示例

本文整理匯總了Java中java.awt.Frame.getHeight方法的典型用法代碼示例。如果您正苦於以下問題:Java Frame.getHeight方法的具體用法?Java Frame.getHeight怎麽用?Java Frame.getHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.Frame的用法示例。


在下文中一共展示了Frame.getHeight方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createDialog

import java.awt.Frame; //導入方法依賴的package包/類
private void createDialog(String title) {
    pHandle = ProgressHandleFactory.createHandle(title);
    JPanel panel = new ProgressPanel(pHandle);
    
    DialogDescriptor descriptor = new DialogDescriptor(
            panel, title
    );
    
    final Object[] OPTIONS = new Object[0];
    descriptor.setOptions(OPTIONS);
    descriptor.setClosingOptions(OPTIONS);
    descriptor.setModal(true);
    descriptor.setOptionsAlign(DialogDescriptor.BOTTOM_ALIGN);
    
    dialog = DialogDisplayer.getDefault().createDialog(descriptor);
    
    Frame mainWindow = WindowManager.getDefault().getMainWindow();
    int windowWidth = mainWindow.getWidth();
    int windowHeight = mainWindow.getHeight();
    int dialogWidth = dialog.getWidth();
    int dialogHeight = dialog.getHeight();
    int dialogX = (int)(windowWidth/2.0) - (int)(dialogWidth/2.0);
    int dialogY = (int)(windowHeight/2.0) - (int)(dialogHeight/2.0);
    
    dialog.setLocation(dialogX, dialogY);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:ProgressDialog.java

示例2: center

import java.awt.Frame; //導入方法依賴的package包/類
/**
 * Center {@link Frame} relative to monitor.
 *
 * @param frame
 *            the frame
 */
private void center(Frame frame) {
	Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
	int x = (int) ((dimension.getWidth() - frame.getWidth()) / 2);
	int y = (int) ((dimension.getHeight() - frame.getHeight()) / 2);
	frame.setLocation(x, y);
}
 
開發者ID:rekit-group,項目名稱:rekit-game,代碼行數:13,代碼來源:GameView.java

示例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(); }
}
 
開發者ID:kristian,項目名稱:JDigitalSimulator,代碼行數:9,代碼來源:Guitilities.java

示例4: testFrame

import java.awt.Frame; //導入方法依賴的package包/類
static void testFrame(boolean isUndecorated) throws Exception {
    Frame frame = new Frame();
    try {
        Robot robot = new Robot();
        robot.setAutoDelay(100);

        frame.setUndecorated(isUndecorated);
        GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment()
                .getDefaultScreenDevice().getDefaultConfiguration();
        Rectangle bounds = gc.getBounds();
        Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
        int x = bounds.x + insets.left;
        int y = bounds.y + insets.top;
        int width = bounds.width - insets.left - insets.right;
        int height = bounds.height - insets.top - insets.bottom;
        Rectangle rect = new Rectangle(x, y, width, height);
        frame.pack();
        frame.setBounds(rect);
        frame.setVisible(true);
        robot.waitForIdle();
        robot.delay(500);

        if (frame.getWidth() <= width / 2
                || frame.getHeight() <= height / 2) {
            throw new RuntimeException("Frame size is small!");
        }

        if (!isUndecorated && frame.getExtendedState() != Frame.MAXIMIZED_BOTH) {
            throw new RuntimeException("Frame state does not equal"
                    + " MAXIMIZED_BOTH!");
        }
    } finally {
        frame.dispose();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:36,代碼來源:MaximizedToUnmaximized.java

示例5: showRes

import java.awt.Frame; //導入方法依賴的package包/類
private static void showRes(String desc, final BufferedImage src) {
    final int w = src.getWidth();
    final int h = src.getHeight();

    Frame f = new Frame(desc+": dbl-click to exit");
    Component c;
    f.add(c = new Component() {
        public Dimension getPreferredSize() {
            return new Dimension(w,h);
        }

        public void paint(Graphics g) {
            g.clearRect(0, 0, getWidth(), getHeight());
            g.drawImage(src, 0,0, null);
        }
    });
    c.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() > 1) {
                System.exit(0);
            }
        }
    });
    f.pack();
    synchronized (JPEGsNotAcceleratedTest.class) {
        f.setLocation(frameX, frameY);
        frameX += f.getWidth();
        if ((frameX + f.getWidth()) >
            f.getGraphicsConfiguration().getBounds().width)
        {
            frameY += TEST_H;
            if ((frameY + f.getHeight()) >
                f.getGraphicsConfiguration().getBounds().height)
            {
                startY += 30;
                startX += 30;
                frameY = startY;
            }
            frameX = startX;
        }
    };
    f.setVisible(true);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:44,代碼來源:JPEGsNotAcceleratedTest.java


注:本文中的java.awt.Frame.getHeight方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。