简体   繁体   English

如何在黄连之前显示Jframe

[英]how to show Jframe before Joptiopane

I tried one code in JoptionPane. 我在JoptionPane中尝试了一个代码。 I want to show Jframe then need show popup dialog.. I done some research but not get proper answer. 我想显示Jframe,然后需要显示弹出对话框。。我做了一些研究,但没有得到正确的答案。 major code is as follows 主要代码如下

here the code : 这里的代码:

Package javaapplication1;

import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JOptionPane;

public class home extends javax.swing.JFrame {

    public home() {
        initComponents();

        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
        this.setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2);
        JOptionPane.showMessageDialog(rootPane,"welcome");
        // JOptionPane.showMessageDialog(rootPane,"welcome");
    }
}

Simply call setVisible(true) on the JFrame before displaying the JOptionPane. 显示JOptionPane 之前,只需在JFrame上调用setVisible(true) That's it. 而已。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM