import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
class myjd extends JDialog
{
public myjd(cre fra)
{
super(fra,"第一个jddialog窗体",true);
Container container =getContentPane();
container.add(new JLabel("这是一个对话框"));
setBounds(120,120,100,100);
}
}
public class cre extends JFrame{
/**
* @param args
*/
public void creat(String title)
{
JFrame jf = new JFrame();
Container container=jf.getContentPane();
container.setLayout(null);
JLabel jl=new JLabel(title);
jl.setHorizontalAlignment(SwingConstants.CENTER);
container.add(jl);
container.setBackground(Color.blue);
jf.setVisible(true);
jf.setSize(400,400);
JButton bl =new JButton("弹出对话框");
bl.setBounds(10,10,100,21);
bl.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
new myjd(cre.this).setVisible(true);
}
});
container.add(bl);
//container.setVisible(true);
}
public static void main(String[] args) {
new cre().creat("hellow world");
}
}
java鼠标弹窗处理
最新推荐文章于 2022-10-09 23:17:25 发布