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

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

        <bdo id='cCjHt'></bdo><ul id='cCjHt'></ul>
    2. <legend id='cCjHt'><style id='cCjHt'><dir id='cCjHt'><q id='cCjHt'></q></dir></style></legend>

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

        时间:2023-09-28

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

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

          • <legend id='GgKtV'><style id='GgKtV'><dir id='GgKtV'><q id='GgKtV'></q></dir></style></legend>

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

                  本文介绍了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 内部框架作为对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

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

                  相关文章

                  最新文章

                • <small id='MQChI'></small><noframes id='MQChI'>

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

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