作者zo6al (我书读得少 你不要骗我)
看板java
标题Re: [J2SE] SWT视窗传值问题...
时间Fri Mar 12 13:24:21 2010
public class A extends JFrame implements ActionListener
{
private JLabel lbl = new JLabel("1");
private JButton btn = new JButton("传值");
public A()
{
super("A视窗");
getContentPane().add(lbl, BorderLayout.NORTH);
getContentPane().add(btn, BorderLayout.SOUTH);
btn.addActionListener(this);
pack();
setVisible(true);
this.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e)
{
new B(lbl.getText());
}
public static void main(String[] args)
{
new A();
}
}
======================================================================
public class B extends JFrame
{
private JLabel lbl = new JLabel("1");
public B(String s)
{
super("B视窗");
lbl.setText(s);
getContentPane().add(lbl, BorderLayout.NORTH);
pack();
setVisible(true);
this.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
}
希望对你有帮助 ^_^
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 124.219.25.61