<tfoot id='Ye1mD'></tfoot>
<legend id='Ye1mD'><style id='Ye1mD'><dir id='Ye1mD'><q id='Ye1mD'></q></dir></style></legend>

<small id='Ye1mD'></small><noframes id='Ye1mD'>

    <bdo id='Ye1mD'></bdo><ul id='Ye1mD'></ul>

      <i id='Ye1mD'><tr id='Ye1mD'><dt id='Ye1mD'><q id='Ye1mD'><span id='Ye1mD'><b id='Ye1mD'><form id='Ye1mD'><ins id='Ye1mD'></ins><ul id='Ye1mD'></ul><sub id='Ye1mD'></sub></form><legend id='Ye1mD'></legend><bdo id='Ye1mD'><pre id='Ye1mD'><center id='Ye1mD'></center></pre></bdo></b><th id='Ye1mD'></th></span></q></dt></tr></i><div id='Ye1mD'><tfoot id='Ye1mD'></tfoot><dl id='Ye1mD'><fieldset id='Ye1mD'></fieldset></dl></div>

    1. Java Swing 内部框架作为对话框

      时间:2023-06-27

      1. <i id='b8PWj'><tr id='b8PWj'><dt id='b8PWj'><q id='b8PWj'><span id='b8PWj'><b id='b8PWj'><form id='b8PWj'><ins id='b8PWj'></ins><ul id='b8PWj'></ul><sub id='b8PWj'></sub></form><legend id='b8PWj'></legend><bdo id='b8PWj'><pre id='b8PWj'><center id='b8PWj'></center></pre></bdo></b><th id='b8PWj'></th></span></q></dt></tr></i><div id='b8PWj'><tfoot id='b8PWj'></tfoot><dl id='b8PWj'><fieldset id='b8PWj'></fieldset></dl></div>
        <tfoot id='b8PWj'></tfoot>

        <legend id='b8PWj'><style id='b8PWj'><dir id='b8PWj'><q id='b8PWj'></q></dir></style></legend>
              <tbody id='b8PWj'></tbody>
              <bdo id='b8PWj'></bdo><ul id='b8PWj'></ul>
              • <small id='b8PWj'></small><noframes id='b8PWj'>

                本文介绍了Java Swing 内部框架作为对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我在 netbeans 中创建了一个项目.我有一个内部框架,我想将其显示为对话框.请帮我.注意:我使用的是 windows 外观.

                I have created one project in netbeans. I have one internal frame, which I want to be displayed as dialog. Please help me. Note:I have used windows look and feel.

                推荐答案

                不要使用 java.awt.Dialogjavax.swing.JDialog.而是查看 JOptionPaneshowInternal..' 开头的 code> 方法.例如

                Don't use a java.awt.Dialog or javax.swing.JDialog. Instead look to the JOptionPane methods that start with 'showInternal..'. E.G.

                import java.awt.*;
                import java.awt.event.*;
                import javax.swing.*;
                import javax.swing.border.EmptyBorder;
                
                public class InternalDialog {
                
                    public static void main(String[] args) throws Exception {
                        Runnable r = new Runnable() {
                
                            @Override
                            public void run() {
                                // the GUI as seen by the user (without frame)
                                JPanel gui = new JPanel(new BorderLayout());
                                gui.setBorder(new EmptyBorder(2, 3, 2, 3));
                
                                JDesktopPane dtp = new JDesktopPane();
                                gui.add(dtp);
                
                                ActionListener listener = new ActionListener() {
                
                                    @Override
                                    public void actionPerformed(ActionEvent e) {
                                        Component c= (Component)e.getSource();
                                        JOptionPane.showInternalMessageDialog(c, "Message");
                                    }
                                };
                                for (int ii=0; ii<3; ii++) {
                                    JInternalFrame jif = new JInternalFrame();
                                    dtp.add(jif);
                                    jif.setLocation(new Point(ii*30, ii*20));
                                    jif.setSize(200,50);
                                    jif.setVisible(true);
                
                                    JButton b = new JButton("Click me!");
                                    b.addActionListener(listener);
                                    jif.add(b);
                                }
                
                                // TODO!
                                gui.setPreferredSize(new Dimension(280, 150));
                                gui.setBackground(Color.WHITE);
                
                                JFrame f = new JFrame("Demo");
                                f.add(gui);
                                // Ensures JVM closes after frame(s) closed and
                                // all non-daemon threads are finished
                                f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                                // See http://stackoverflow.com/a/7143398/418556 for demo.
                                f.setLocationByPlatform(true);
                
                                // ensures the frame is the minimum size it needs to be
                                // in order display the components within it
                                f.pack();
                                // should be done last, to avoid flickering, moving,
                                // resizing artifacts.
                                f.setVisible(true);
                            }
                        };
                        // Swing GUIs should be created and updated on the EDT
                        // http://docs.oracle.com/javase/tutorial/uiswing/concurrency/initial.html
                        SwingUtilities.invokeLater(r);
                    }
                }
                

                这篇关于Java Swing 内部框架作为对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何在android中创建上述自定义对话框? 下一篇:如何制作“打开方式"对话框?

                相关文章

                1. <tfoot id='KahYx'></tfoot>
                  • <bdo id='KahYx'></bdo><ul id='KahYx'></ul>

                  <legend id='KahYx'><style id='KahYx'><dir id='KahYx'><q id='KahYx'></q></dir></style></legend>
                  <i id='KahYx'><tr id='KahYx'><dt id='KahYx'><q id='KahYx'><span id='KahYx'><b id='KahYx'><form id='KahYx'><ins id='KahYx'></ins><ul id='KahYx'></ul><sub id='KahYx'></sub></form><legend id='KahYx'></legend><bdo id='KahYx'><pre id='KahYx'><center id='KahYx'></center></pre></bdo></b><th id='KahYx'></th></span></q></dt></tr></i><div id='KahYx'><tfoot id='KahYx'></tfoot><dl id='KahYx'><fieldset id='KahYx'></fieldset></dl></div>

                  <small id='KahYx'></small><noframes id='KahYx'>