Java Code Examples for java.awt.Dialog#setSize()

The following examples show how to use java.awt.Dialog#setSize() . 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: MissingEventsOnModalDialogTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void showModalDialog(Frame targetFrame) {

        Dialog dialog = new Dialog(targetFrame, true);

        dialog.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                passed = true;
                dialog.dispose();
            }
        });

        dialog.setSize(400, 300);
        dialog.setTitle("Modal Dialog!");

        clickOnModalDialog(dialog);
        dialog.setVisible(true);
    }
 
Example 2
Source File: PageFlowController.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void ifNecessaryShowNoWebFolderDialog() {
    if (isShowNoWebFolderDialog()) {

        final NotWebFolder panel = new NotWebFolder(NO_WEB_FOLDER_WARNING);
        DialogDescriptor descriptor = new DialogDescriptor(panel, NO_WEB_FOLDER_TITLE, true, NotifyDescriptor.PLAIN_MESSAGE, NotifyDescriptor.YES_OPTION, null);
        JButton okButton = new JButton(
                NbBundle.getMessage(PageFlowController.class, "MSG_OkButtonText")); //NOI18N
        descriptor.setOptions(new Object[]{okButton});
        descriptor.setMessageType(NotifyDescriptor.PLAIN_MESSAGE);
        descriptor.setClosingOptions(new Object[]{okButton});
        descriptor.setOptionsAlign(DialogDescriptor.BOTTOM_ALIGN);
        final Dialog d = DialogDisplayer.getDefault().createDialog(descriptor);
        d.setSize(400, 200);
        d.setVisible(true);

        setShowNoWebFolderDialog(panel.getShowDialog());
    }
}
 
Example 3
Source File: MultiResolutionSplashTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static float getScaleFactor() {

        final Dialog dialog = new Dialog((Window) null);
        dialog.setSize(100, 100);
        dialog.setModal(true);
        final float[] scaleFactors = new float[1];
        Panel panel = new Panel() {

            @Override
            public void paint(Graphics g) {
                float scaleFactor = 1;
                if (g instanceof SunGraphics2D) {
                    scaleFactor = getScreenScaleFactor();
                }
                scaleFactors[0] = scaleFactor;
                dialog.setVisible(false);
            }
        };

        dialog.add(panel);
        dialog.setVisible(true);
        dialog.dispose();

        return scaleFactors[0];
    }
 
Example 4
Source File: ModalDialogOrderingTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {

        final Frame frame = new Frame("Test");
        frame.setSize(400, 400);
        frame.setBackground(FRAME_COLOR);
        frame.setVisible(true);

        final Dialog modalDialog = new Dialog(null, true);
        modalDialog.setTitle("Modal Dialog");
        modalDialog.setSize(400, 200);
        modalDialog.setBackground(DIALOG_COLOR);
        modalDialog.setModal(true);

        new Thread(new Runnable() {

            @Override
            public void run() {
                runTest(modalDialog, frame);
            }
        }).start();

        modalDialog.setVisible(true);
    }
 
Example 5
Source File: MissingEventsOnModalDialogTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void showModalDialog(Frame targetFrame) {

        Dialog dialog = new Dialog(targetFrame, true);

        dialog.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                passed = true;
                dialog.dispose();
            }
        });

        dialog.setSize(400, 300);
        dialog.setTitle("Modal Dialog!");

        clickOnModalDialog(dialog);
        dialog.setVisible(true);
    }
 
Example 6
Source File: MultiResolutionSplashTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
static float getScaleFactor() {

        final Dialog dialog = new Dialog((Window) null);
        dialog.setSize(100, 100);
        dialog.setModal(true);
        final float[] scaleFactors = new float[1];
        Panel panel = new Panel() {

            @Override
            public void paint(Graphics g) {
                float scaleFactor = 1;
                if (g instanceof SunGraphics2D) {
                    scaleFactor = ((SunGraphics2D) g).surfaceData.getDefaultScale();
                }
                scaleFactors[0] = scaleFactor;
                dialog.setVisible(false);
            }
        };

        dialog.add(panel);
        dialog.setVisible(true);
        dialog.dispose();

        return scaleFactors[0];
    }
 
Example 7
Source File: MissingEventsOnModalDialogTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void showModalDialog(Frame targetFrame) {

        Dialog dialog = new Dialog(targetFrame, true);

        dialog.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                passed = true;
                dialog.dispose();
            }
        });

        dialog.setSize(400, 300);
        dialog.setTitle("Modal Dialog!");

        clickOnModalDialog(dialog);
        dialog.setVisible(true);
    }
 
Example 8
Source File: FocusTransitionTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void run() {
    Dialog dialog = new Dialog(frame);
    dialog.setSize(300, 100);
    dialog.setVisible(true);

    try {
        sleep(delay);
    } catch (InterruptedException ie) {
        ie.printStackTrace();
    }

    dialog.setVisible(false);
    dialog.dispose();

    synchronized (frame) {
        frame.notify();
    }
}
 
Example 9
Source File: MissingEventsOnModalDialogTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static void showModalDialog(Frame targetFrame) {

        Dialog dialog = new Dialog(targetFrame, true);

        dialog.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                passed = true;
                dialog.dispose();
            }
        });

        dialog.setSize(400, 300);
        dialog.setTitle("Modal Dialog!");

        clickOnModalDialog(dialog);
        dialog.setVisible(true);
    }
 
Example 10
Source File: MultiResolutionSplashTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static float getScaleFactor() {

        final Dialog dialog = new Dialog((Window) null);
        dialog.setSize(100, 100);
        dialog.setModal(true);
        final float[] scaleFactors = new float[1];
        Panel panel = new Panel() {

            @Override
            public void paint(Graphics g) {
                float scaleFactor = 1;
                if (g instanceof SunGraphics2D) {
                    scaleFactor = ((SunGraphics2D) g).surfaceData.getDefaultScale();
                }
                scaleFactors[0] = scaleFactor;
                dialog.setVisible(false);
            }
        };

        dialog.add(panel);
        dialog.setVisible(true);
        dialog.dispose();

        return scaleFactors[0];
    }
 
Example 11
Source File: ModalDialogOrderingTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {

        final Frame frame = new Frame("Test");
        frame.setSize(400, 400);
        frame.setBackground(FRAME_COLOR);
        frame.setVisible(true);

        final Dialog modalDialog = new Dialog(null, true);
        modalDialog.setTitle("Modal Dialog");
        modalDialog.setSize(400, 200);
        modalDialog.setBackground(DIALOG_COLOR);
        modalDialog.setModal(true);

        new Thread(new Runnable() {

            @Override
            public void run() {
                runTest(modalDialog, frame);
            }
        }).start();

        modalDialog.setVisible(true);
    }
 
Example 12
Source File: MissingEventsOnModalDialogTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void showModalDialog(Frame targetFrame) {

        Dialog dialog = new Dialog(targetFrame, true);

        dialog.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                passed = true;
                dialog.dispose();
            }
        });

        dialog.setSize(400, 300);
        dialog.setTitle("Modal Dialog!");

        clickOnModalDialog(dialog);
        dialog.setVisible(true);
    }
 
Example 13
Source File: FocusTransitionTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void run() {
    Dialog dialog = new Dialog(frame);
    dialog.setSize(300, 100);
    dialog.setVisible(true);

    try {
        sleep(delay);
    } catch (InterruptedException ie) {
        ie.printStackTrace();
    }

    dialog.setVisible(false);
    dialog.dispose();

    synchronized (frame) {
        frame.notify();
    }
}
 
Example 14
Source File: HiDPIPropertiesWindowsTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void testScale(double scaleX, double scaleY) {

        Dialog dialog = new Dialog((Frame) null, true) {

            @Override
            public void paint(Graphics g) {
                super.paint(g);
                AffineTransform tx = ((Graphics2D) g).getTransform();
                dispose();
                if (scaleX != tx.getScaleX() || scaleY != tx.getScaleY()) {
                    throw new RuntimeException(String.format("Wrong scale:"
                            + "[%f, %f] instead of [%f, %f].",
                            tx.getScaleX(), tx.getScaleY(), scaleX, scaleY));
                }
            }
        };
        dialog.setSize(200, 300);
        dialog.setVisible(true);
    }
 
Example 15
Source File: HiDPIPropertiesWindowsTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void testScale(double scaleX, double scaleY) {

        Dialog dialog = new Dialog((Frame) null, true) {

            @Override
            public void paint(Graphics g) {
                super.paint(g);
                AffineTransform tx = ((Graphics2D) g).getTransform();
                dispose();
                if (scaleX != tx.getScaleX() || scaleY != tx.getScaleY()) {
                    throw new RuntimeException(String.format("Wrong scale:"
                            + "[%f, %f] instead of [%f, %f].",
                            tx.getScaleX(), tx.getScaleY(), scaleX, scaleY));
                }
            }
        };
        dialog.setSize(200, 300);
        dialog.setVisible(true);
    }
 
Example 16
Source File: MultiResolutionSplashTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static float getScaleFactor() {

        final Dialog dialog = new Dialog((Window) null);
        dialog.setSize(100, 100);
        dialog.setModal(true);
        final float[] scaleFactors = new float[1];
        Panel panel = new Panel() {

            @Override
            public void paint(Graphics g) {
                float scaleFactor = 1;
                if (g instanceof SunGraphics2D) {
                    scaleFactor = ((SunGraphics2D) g).surfaceData.getDefaultScale();
                }
                scaleFactors[0] = scaleFactor;
                dialog.setVisible(false);
            }
        };

        dialog.add(panel);
        dialog.setVisible(true);
        dialog.dispose();

        return scaleFactors[0];
    }
 
Example 17
Source File: ScaledTransform.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void testScaleFactor(final GraphicsConfiguration gc) {
    final Dialog dialog = new Dialog((Frame) null, "Test", true, gc);

    try {
        dialog.setSize(100, 100);
        Panel panel = new Panel() {

            @Override
            public void paint(Graphics g) {
                if (g instanceof Graphics2D) {
                    AffineTransform gcTx = gc.getDefaultTransform();
                    AffineTransform gTx
                            = ((Graphics2D) g).getTransform();
                    passed = gcTx.getScaleX() == gTx.getScaleX()
                            && gcTx.getScaleY() == gTx.getScaleY();
                } else {
                    passed = true;
                }
                dialog.setVisible(false);
            }
        };
        dialog.add(panel);
        dialog.setVisible(true);

        if (!passed) {
            throw new RuntimeException("Transform is not scaled!");
        }
    } finally {
        dialog.dispose();
    }
}
 
Example 18
Source File: ScaledTransform.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void testScaleFactor(final GraphicsConfiguration gc) {
    final Dialog dialog = new Dialog((Frame) null, "Test", true, gc);

    try {
        dialog.setSize(100, 100);
        Panel panel = new Panel() {

            @Override
            public void paint(Graphics g) {
                if (g instanceof Graphics2D) {
                    AffineTransform gcTx = gc.getDefaultTransform();
                    AffineTransform gTx
                            = ((Graphics2D) g).getTransform();
                    passed = gcTx.getScaleX() == gTx.getScaleX()
                            && gcTx.getScaleY() == gTx.getScaleY();
                } else {
                    passed = true;
                }
                dialog.setVisible(false);
            }
        };
        dialog.add(panel);
        dialog.setVisible(true);

        if (!passed) {
            throw new RuntimeException("Transform is not scaled!");
        }
    } finally {
        dialog.dispose();
    }
}
 
Example 19
Source File: ChildDialogProperties.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void testChildPropertiesWithDialogAsParent() {

        parentDialog = new Dialog((Dialog) null, "parent Dialog");
        parentDialog.setSize(WIDTH, HEIGHT);
        parentDialog.setLocation(100, 100);
        parentDialog.setBackground(Color.RED);

        parentLabel = new Label("ParentForegroundAndFont");
        parentFont = new Font("Courier New", Font.ITALIC, 15);
        parentDialog.setForeground(Color.BLUE);
        parentDialog.setFont(parentFont);

        parentDialog.add(parentLabel);
        parentDialog.setVisible(true);

        dialogChild = new Dialog(parentDialog, "Dialog's child");
        dialogChild.setSize(WIDTH, HEIGHT);
        dialogChild.setLocation(WIDTH + 200, 100);
        childLabel = new Label("ChildForegroundAndFont");
        dialogChild.add(childLabel);

        dialogChild.setVisible(true);

        if (parentDialog.getBackground() == dialogChild.getBackground()) {
            dispose();
            throw new RuntimeException("Child Dialog Should NOT Inherit "
                    + "Parent Dialog's Background Color");
        }

        if (parentDialog.getForeground() == dialogChild.getForeground()) {
            dispose();
            throw new RuntimeException("Child Dialog Should NOT Inherit "
                    + "Parent Dialog's Foreground Color");
        }

        if (parentDialog.getFont() == dialogChild.getFont()) {
            dispose();
            throw new RuntimeException("Child Dialog Should NOT Inherit "
                    + "Parent Dialog's Font Style/Color");
        }

    }
 
Example 20
Source File: HttpServerSettings.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Requests access for address addr. If necessary asks the user. Returns true it the access
* has been granted. */  
boolean allowAccess(InetAddress addr, String requestPath) {
    if (accessAllowedNow(addr, requestPath))
        return true;

    Thread askThread = null;
    synchronized (whoAsking) {
        // one more test in the synchronized block
        if (accessAllowedNow(addr, requestPath))
            return true;

        askThread = (Thread)whoAsking.get(addr);
        if (askThread == null) {
            askThread = Thread.currentThread();
            whoAsking.put(addr, askThread);
        }
    }

    // now ask the user
    synchronized (HttpServerSettings.class) {
        if (askThread != Thread.currentThread()) {
            return accessAllowedNow(addr, requestPath);
        }

        try {
            if (!isShowGrantAccessDialog ())
                return false;
            
            String msg = NbBundle.getMessage (HttpServerSettings.class, "MSG_AddAddress", addr.getHostAddress ());
            
            final GrantAccessPanel panel = new GrantAccessPanel (msg);
            DialogDescriptor descriptor = new DialogDescriptor (
                panel,
                NbBundle.getMessage (HttpServerSettings.class, "CTL_GrantAccessTitle"),
                true,
                NotifyDescriptor.YES_NO_OPTION,
                NotifyDescriptor.NO_OPTION,
                null
            );
            descriptor.setMessageType (NotifyDescriptor.QUESTION_MESSAGE);
            // descriptor.setOptionsAlign (DialogDescriptor.BOTTOM_ALIGN);
            final Dialog d  = DialogDisplayer.getDefault ().createDialog (descriptor);
            d.setSize (580, 180);
            d.setVisible(true);

            setShowGrantAccessDialog (panel.getShowDialog ());
            if (NotifyDescriptor.YES_OPTION.equals(descriptor.getValue ())) {
                appendAddressToGranted(addr.getHostAddress());
                return true;
            }
            else
                return false;
        }
        finally {
            whoAsking.remove(addr);
        }
    } // end synchronized
}