java.awt.Dialog#setSize ( )源码实例Demo

下面列出了java.awt.Dialog#setSize ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk8u-jdk   文件: MultiResolutionSplashTest.java
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];
    }
 
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);
    }
 
源代码3 项目: jdk8u_jdk   文件: HiDPIPropertiesWindowsTest.java
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);
    }
 
源代码4 项目: openjdk-jdk9   文件: HiDPIPropertiesWindowsTest.java
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);
    }
 
源代码5 项目: TencentKona-8   文件: FocusTransitionTest.java
@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();
    }
}
 
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);
    }
 
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);
    }
 
源代码8 项目: jdk8u60   文件: MultiResolutionSplashTest.java
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];
    }
 
源代码9 项目: hottub   文件: MissingEventsOnModalDialogTest.java
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);
    }
 
源代码10 项目: openjdk-jdk8u   文件: FocusTransitionTest.java
@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();
    }
}
 
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);
    }
 
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];
    }
 
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);
    }
 
源代码14 项目: hottub   文件: ModalDialogOrderingTest.java
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);
    }
 
源代码15 项目: openjdk-jdk9   文件: MultiResolutionSplashTest.java
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];
    }
 
源代码16 项目: netbeans   文件: PageFlowController.java
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());
    }
}
 
源代码17 项目: jdk8u_jdk   文件: ScaledTransform.java
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();
    }
}
 
源代码18 项目: openjdk-jdk9   文件: ScaledTransform.java
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();
    }
}
 
源代码19 项目: openjdk-jdk9   文件: ChildDialogProperties.java
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");
        }

    }
 
源代码20 项目: netbeans   文件: HttpServerSettings.java
/** 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
}