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


Java Dialog.setSize方法代码示例

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


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

示例1: displayAlert

import java.awt.Dialog; //导入方法依赖的package包/类
/**
 * Just show the dialog but do not do anything about it.
 */
private boolean displayAlert(String projectDisplayName) {
    String title = NbBundle.getMessage(UnboundTargetAlert.class, "UTA_TITLE", label, projectDisplayName);
    final DialogDescriptor d = new DialogDescriptor(this, title);
    d.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION);
    d.setMessageType(NotifyDescriptor.ERROR_MESSAGE);
    d.setValid(false);
    selectCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            d.setValid(((String) selectCombo.getSelectedItem()).trim().length() > 0);
        }
    });
    Dialog dlg = DialogDisplayer.getDefault().createDialog(d);
    selectCombo.requestFocusInWindow();
    // XXX combo box gets cut off at the bottom unless you do something - why??
    Dimension sz = dlg.getSize();
    dlg.setSize(sz.width, sz.height + 30);
    dlg.setVisible(true);
    return d.getValue() == NotifyDescriptor.OK_OPTION;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:UnboundTargetAlert.java

示例2: main

import java.awt.Dialog; //导入方法依赖的package包/类
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);
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:ModalDialogOrderingTest.java

示例3: showModalDialog

import java.awt.Dialog; //导入方法依赖的package包/类
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);
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:MissingEventsOnModalDialogTest.java

示例4: getScaleFactor

import java.awt.Dialog; //导入方法依赖的package包/类
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];
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:MultiResolutionSplashTest.java

示例5: testScale

import java.awt.Dialog; //导入方法依赖的package包/类
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);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:HiDPIPropertiesWindowsTest.java

示例6: testChildPropertiesWithDialogAsParent

import java.awt.Dialog; //导入方法依赖的package包/类
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);

        windowChild = new Window(parentDialog);
        windowChild.setSize(WIDTH, HEIGHT);
        windowChild.setLocation(WIDTH + 200, 100);
        childLabel = new Label("ChildForegroundAndFont");
        windowChild.add(childLabel);
        windowChild.setVisible(true);

        if (parentDialog.getBackground() == windowChild.getBackground()) {
            dispose();
            throw new RuntimeException("Child Window Should NOT Inherit "
                    + "Parent Dialog's Background Color");
        }
        if (parentDialog.getForeground() == windowChild.getForeground()) {
            dispose();
            throw new RuntimeException("Child Window Should NOT Inherit "
                    + "Parent Dialog's Foreground Color");
        }
        if (parentDialog.getFont() == windowChild.getFont()) {
            dispose();
            throw new RuntimeException("Child Window Should NOT Inherit "
                    + "Parent Dialog's Font Color");
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:ChildWindowProperties.java

示例7: getScaleFactor

import java.awt.Dialog; //导入方法依赖的package包/类
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];
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:MultiResolutionSplashTest.java

示例8: getScaleFactor

import java.awt.Dialog; //导入方法依赖的package包/类
static float getScaleFactor() {

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

            @Override
            public void paint(Graphics g) {
                String scaleStr = System.getenv("GDK_SCALE");
                if (scaleStr != null && !scaleStr.equals("")) {
                    try {
                        scaleFactors[0] = Float.valueOf(scaleStr);
                    } catch (NumberFormatException ex) {
                        scaleFactors[0] = 1.0f;
                    }
                }
                dialog.setVisible(false);
            }
        };
        dialog.add(panel);
        dialog.setVisible(true);
        dialog.dispose();
        return scaleFactors[0];
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:UnixMultiResolutionSplashTest.java

示例9: showDocumentsDialog

import java.awt.Dialog; //导入方法依赖的package包/类
public static void showDocumentsDialog() {
    DocumentsDlg documentsPanel = getDefault();
    DialogDescriptor dlgDesc = new DialogDescriptor(
        documentsPanel,
        NbBundle.getMessage(DocumentsDlg.class, "CTL_DocumentsTitle"),
        true, // is modal!!
        new Object[0],
        // make "switcch to document" button default
        getDefault().jButtonActivate,
        DialogDescriptor.DEFAULT_ALIGN,
        null,
        null
    );
    dlgDesc.setHelpCtx( null ); //hide the default Help button
    final Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);
    dlg.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(DocumentsDlg.class, "ACSD_DocumentsDialog"));
    if( dlg instanceof JDialog ) {
        HelpCtx.setHelpIDString(((JDialog)dlg).getRootPane(), documentsPanel.getHelpCtx().getHelpID());
    }
    getDefault().updateNodes();
    
    if (getDefault().previousDialogSize != null) {
        dlg.setSize(getDefault().previousDialogSize);
        dlg.setLocationRelativeTo(null);
    }

    dlg.setVisible(true);
    getDefault().clearNodes();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:DocumentsDlg.java

示例10: testScaleFactor

import java.awt.Dialog; //导入方法依赖的package包/类
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();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:ScaledTransform.java

示例11: testChildPropertiesWithFrameAsParent

import java.awt.Dialog; //导入方法依赖的package包/类
public void testChildPropertiesWithFrameAsParent() {

        parentFrame = new Frame("parent Frame");
        parentFrame.setSize(WIDTH, HEIGHT);
        parentFrame.setLocation(100, 400);
        parentFrame.setBackground(Color.BLUE);
        parentLabel = new Label("ParentForegroundAndFont");
        parentFont = new Font("Courier New", Font.ITALIC, 15);
        parentFrame.setForeground(Color.RED);
        parentFrame.setFont(parentFont);
        parentFrame.add(parentLabel);
        parentFrame.setVisible(true);

        frameChildDialog = new Dialog(parentFrame, "Frame's child");
        frameChildDialog.setSize(WIDTH, HEIGHT);
        frameChildDialog.setLocation(WIDTH + 200, 400);
        childLabel = new Label("ChildForegroundAndFont");
        frameChildDialog.add(childLabel);
        frameChildDialog.setVisible(true);

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

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

        if (parentFrame.getFont() == frameChildDialog.getFont()) {
            dispose();
            throw new RuntimeException("Child Dialog Should NOT Inherit "
                    + "Parent Frame's Font Style/Color");
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:ChildDialogProperties.java

示例12: formattersAddButtonActionPerformed

import java.awt.Dialog; //导入方法依赖的package包/类
private void formattersAddButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_formattersAddButtonActionPerformed
    VariablesFormatter f = new VariablesFormatter("");
    final VariableFormatterEditPanel fPanel = new VariableFormatterEditPanel();
    fPanel.load(f);

    fPanel.setFormatterNames(getFormatterNames());
    final Dialog[] dlgPtr = new Dialog[] { null };
    DialogDescriptor formatterEditDescriptor = new DialogDescriptor(
            fPanel,
            NbBundle.getMessage(CategoryPanelFormatters.class, "TTL_AddFormatter"),
            true,
            NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.OK_OPTION,
            new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    if (e.getSource() == NotifyDescriptor.OK_OPTION) {
                        boolean valid = fPanel.checkValidInput();
                        if (valid) {
                            dlgPtr[0].setVisible(false);
                        }
                    } else {
                        dlgPtr[0].setVisible(false);
                    }
                }
            });
    formatterEditDescriptor.setClosingOptions(new Object[] {});
    NotificationLineSupport notificationSupport = formatterEditDescriptor.createNotificationLineSupport();
    fPanel.setValidityObjects(formatterEditDescriptor, notificationSupport, false);
    //formatterEditDescriptor.setValid(false);
    Dialog dlg = DialogDisplayer.getDefault().createDialog(formatterEditDescriptor);
    Properties p = Properties.getDefault().getProperties("debugger.options.JPDA");   // NOI18N
    int w = p.getInt("VariableFormatters_AddEdit_WIDTH", -1);                        // NOI18N
    int h = p.getInt("VariableFormatters_AddEdit_HEIGHT", -1);                       // NOI18N
    if (w > 0 && h > 0) {
        dlg.setSize(new Dimension(w, h));
    }
    dlgPtr[0] = dlg;
    dlg.setVisible(true);
    Dimension dim = dlg.getSize();
    p.setInt("VariableFormatters_AddEdit_WIDTH", dim.width);                         // NOI18N
    p.setInt("VariableFormatters_AddEdit_HEIGHT", dim.height);                       // NOI18N
    if (NotifyDescriptor.OK_OPTION.equals(formatterEditDescriptor.getValue())) {
        fPanel.store(f);
        ((DefaultListModel) formattersList.getModel()).addElement(f);
        formattersList.setSelectedValue(f, true);
    }

    /*
    NotifyDescriptor.InputLine nd = new NotifyDescriptor.InputLine(
            NbBundle.getMessage(CategoryPanelFormatters.class, "CategoryPanelFormatters.addDLG.nameLabel"),
            NbBundle.getMessage(CategoryPanelFormatters.class, "CategoryPanelFormatters.addDLG.title"));
    DialogDisplayer.getDefault().notify(nd);
    VariablesFormatter f = new VariablesFormatter(nd.getInputText());
    ((DefaultListModel) formattersList.getModel()).addElement(f);
    formattersList.setSelectedValue(f, true);
    //JCheckBox cb = new JCheckBox(nd.getInputText());
    //cb.setSelected(true);
    //filterClassesList.add(cb);
    //filterClassesList.repaint();
    */
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:61,代码来源:CategoryPanelFormatters.java

示例13: editButtonActionPerformed

import java.awt.Dialog; //导入方法依赖的package包/类
private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButtonActionPerformed
    int index = formattersList.getSelectedIndex();
    if (index < 0) return ;
    DefaultListModel model = (DefaultListModel) formattersList.getModel();
    VariablesFormatter f = (VariablesFormatter) model.getElementAt(index);

    VariableFormatterEditPanel fPanel = new VariableFormatterEditPanel();
    fPanel.load(f);

    Set<String> formatterNames = getFormatterNames();
    formatterNames.remove(f.getName());
    fPanel.setFormatterNames(formatterNames);

    DialogDescriptor formatterEditDescriptor = new DialogDescriptor(
            fPanel,
            NbBundle.getMessage(CategoryPanelFormatters.class, "TTL_EditFormatter"),
            true,
            NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.OK_OPTION,
            null);
    NotificationLineSupport notificationSupport = formatterEditDescriptor.createNotificationLineSupport();
    fPanel.setValidityObjects(formatterEditDescriptor, notificationSupport, true);
    //formatterEditDescriptor.setValid(false);
    Dialog dlg = DialogDisplayer.getDefault().createDialog(formatterEditDescriptor);
    Properties p = Properties.getDefault().getProperties("debugger.options.JPDA"); // NOI18N
    int w = p.getInt("VariableFormatters_AddEdit_WIDTH", -1);                      // NOI18N
    int h = p.getInt("VariableFormatters_AddEdit_HEIGHT", -1);                     // NOI18N
    if (w > 0 && h > 0) {
        dlg.setSize(new Dimension(w, h));
    }
    dlg.setVisible(true);
    Dimension dim = dlg.getSize();
    p.setInt("VariableFormatters_AddEdit_WIDTH", dim.width);                       // NOI18N
    p.setInt("VariableFormatters_AddEdit_HEIGHT", dim.height);                     // NOI18N
    if (NotifyDescriptor.OK_OPTION.equals(formatterEditDescriptor.getValue())) {
        fPanel.store(f);
        checkBoxComponents.put(f, new JCheckBox(f.getName(), f.isEnabled()));
        ((DefaultListModel) formattersList.getModel()).setElementAt(f, index);
        //formattersList.repaint();
        formattersList.setSelectedValue(f, true);
        loadSelectedFormatter(f);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:43,代码来源:CategoryPanelFormatters.java

示例14: allowAccess

import java.awt.Dialog; //导入方法依赖的package包/类
/** 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
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:60,代码来源:HttpServerSettings.java

示例15: testChildPropertiesWithDialogAsParent

import java.awt.Dialog; //导入方法依赖的package包/类
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");
        }

    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:43,代码来源:ChildDialogProperties.java


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