62,616
社区成员
发帖
与我相关
我的任务
分享
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Test
{
public static void main(String[] args)
{
final JFrame frame = new JFrame();
frame.setSize(800, 600);
JButton btn = new JButton("弹出对话框");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
JDialog dialog = new JDialog(frame, "弹出对话框", true);
dialog.setSize(400, 300);
dialog.setIconImage(new ImageIcon("MS.JPG").getImage());
dialog.setVisible(true);
}
});
frame.add(btn, BorderLayout.SOUTH);
frame.setVisible(true);
}
}