Java Code Examples for java.awt.Frame#getHeight()

The following examples show how to use java.awt.Frame#getHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProgressDialog.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 2
Source File: ProgressDialog.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void createDialog(String title) {
    pHandle = ProgressHandleFactory.createHandle(title);
    JPanel panel = new ProgressPanel(pHandle);

    DialogDescriptor descriptor = new DialogDescriptor(
            panel, title); // NOI18N

    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);
}
 
Example 3
Source File: MaximizedToUnmaximized.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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();
    }
}
 
Example 4
Source File: JPEGsNotAcceleratedTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
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);
}
 
Example 5
Source File: JPEGsNotAcceleratedTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
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);
}
 
Example 6
Source File: ChartBaseCanvas.java    From RipplePower with Apache License 2.0 4 votes vote down vote up
public ChartBaseCanvas(Frame frame) {
	this(frame.getWidth(), frame.getHeight());
}