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


Java Dialog.getBounds方法代码示例

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


在下文中一共展示了Dialog.getBounds方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runTest

import java.awt.Dialog; //导入方法依赖的package包/类
private static void runTest(Dialog dialog, Frame frame) {
    try {
        Robot robot = new Robot();
        robot.setAutoDelay(50);
        robot.mouseMove(300, 300);

        while (!dialog.isVisible()) {
            sleep();
        }

        Rectangle dialogBounds = dialog.getBounds();
        Rectangle frameBounds = frame.getBounds();

        int y1 = dialogBounds.y + dialogBounds.height;
        int y2 = frameBounds.y + frameBounds.height;

        int clickX = frameBounds.x + frameBounds.width / 2;
        int clickY = y1 + (y2 - y1) / 2;

        robot.mouseMove(clickX, clickY);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        sleep();

        int colorX = dialogBounds.x + dialogBounds.width / 2;
        int colorY = dialogBounds.y + dialogBounds.height / 2;

        Color color = robot.getPixelColor(colorX, colorY);

        dialog.dispose();
        frame.dispose();

        if (!DIALOG_COLOR.equals(color)) {
            throw new RuntimeException("The frame is on top"
                    + " of the modal dialog!");
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:41,代码来源:ModalDialogOrderingTest.java

示例2: selectDependencies

import java.awt.Dialog; //导入方法依赖的package包/类
/**
 * 
 * @param props
 * @param initialFilterText initial filter text or null if not given
 * @return 
 */
public static ModuleDependency[] selectDependencies(final SingleModuleProperties props, final String initialFilterText) {
    final AddModulePanel addPanel;
    if (null != initialFilterText) {
        // init dialog with filter text
        addPanel = new AddModulePanel(props, initialFilterText);
    }
    else{
        // keep backwards compatibility
        addPanel = new AddModulePanel(props);
    }
    final DialogDescriptor descriptor = new DialogDescriptor(addPanel,
            getMessage("CTL_AddModuleDependencyTitle"));
    descriptor.setHelpCtx(new HelpCtx("org.netbeans.modules.apisupport.project.ui.customizer.AddModulePanel"));
    descriptor.setClosingOptions(new Object[0]);
    final Dialog d = DialogDisplayer.getDefault().createDialog(descriptor);
    descriptor.setButtonListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (DialogDescriptor.OK_OPTION.equals(e.getSource()) && addPanel.getSelectedDependencies().length == 0) {
                return;
            }
            d.setVisible(false);
            d.dispose();
        }
    });
    if (lastSize != null) {
        d.setBounds(lastSize);
    }
    d.setVisible(true);
    lastSize = d.getBounds();
    d.dispose();
    if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
        return addPanel.getSelectedDependencies();
    } else {
        return new ModuleDependency[0]; // #114932
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:43,代码来源:AddModulePanel.java

示例3: runTest

import java.awt.Dialog; //导入方法依赖的package包/类
private static void runTest(Dialog dialog, Frame frame) {
    try {
        ExtendedRobot robot = new ExtendedRobot();
        robot.setAutoDelay(50);
        robot.mouseMove(300, 300);

        while (!dialog.isVisible()) {
            robot.waitForIdle(1000);
        }

        Rectangle dialogBounds = dialog.getBounds();
        Rectangle frameBounds = frame.getBounds();

        int y1 = dialogBounds.y + dialogBounds.height;
        int y2 = frameBounds.y + frameBounds.height;

        int clickX = frameBounds.x + frameBounds.width / 2;
        int clickY = y1 + (y2 - y1) / 2;

        robot.mouseMove(clickX, clickY);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        robot.waitForIdle(1000);

        int colorX = dialogBounds.x + dialogBounds.width / 2;
        int colorY = dialogBounds.y + dialogBounds.height / 2;

        Color color = robot.getPixelColor(colorX, colorY);


        if (!DIALOG_COLOR.equals(color)) {
            throw new RuntimeException("The frame is on top"
                    + " of the modal dialog!");
        }else{
            frame.dispose();
            dialog.dispose();
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:42,代码来源:ModalDialogOrderingTest.java


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