当前位置: 首页>>代码示例>>Java>>正文


Java Frame.getWidth方法代码示例

本文整理汇总了Java中java.awt.Frame.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java Frame.getWidth方法的具体用法?Java Frame.getWidth怎么用?Java Frame.getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Frame的用法示例。


在下文中一共展示了Frame.getWidth方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: test

import java.awt.Frame; //导入方法依赖的package包/类
private static void test(final Point tmp) throws Exception {
    Choice choice = new Choice();
    for (int i = 1; i < 7; i++) {
        choice.add("Long-long-long-long-long text in the item-" + i);
    }
    Frame frame = new Frame();
    try {
        frame.setAlwaysOnTop(true);
        frame.setLayout(new FlowLayout());
        frame.add(choice);
        frame.pack();
        frameWidth = frame.getWidth();
        frame.setSize(frameWidth, SIZE);
        frame.setVisible(true);
        frame.setLocation(tmp.x, tmp.y);
        openPopup(choice);
    } finally {
        frame.dispose();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:ChoicePopupLocation.java

示例6: 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.getWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。