import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class t extends JFrame
{ JDialog jd=new JDialog();
JButton jb,jb0,jb01,jb1;
public t()
{
super("asdf");
JPanel jp;
jp=new JPanel();
jp.setBackground(Color.LIGHT_GRAY);
jb=new JButton("设置");
//jb.addActionListener(this);
jp.add(jb);
jb0=new JButton("获取JDialog");
jp.add(jb0);
jb01=new JButton("reset");
jp.add(jb01);
//jb1.addActionListener(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
add(jp);
this.setSize(400,300);
//set Frame in the center window
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
final int screenHeight = screenSize.height;
final int screenWidth = screenSize.width;
int frameW=this.getWidth();
int frameH=this.getHeight();
setLocation((screenWidth-frameW) / 2, (screenHeight-frameH) / 2);
this.setVisible(true);
jb1=new JButton("jdialog");
jd.setTitle("jdialog");
jd.setSize(200,100);
//jd.setModal(true);
jd.add(jb1);
jb.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
jd.setLocation(getX()+(getWidth()-jd.getWidth())/2,getY()+(getHeight()-jd.getHeight())/2);
jd.setVisible(true);
}
});
jb1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
//jb.setText(jb1.getText());
jd.dispose();
}
});
jb0.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
jb.setText(jb1.getText());
}
});
jb01.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
jb.setText(getX()+"/"+getY());
}
});
}
public static void main(String args[])
{
new t();
}
}
1514

被折叠的 条评论
为什么被折叠?



