主题:请大家帮忙看看啊,谢谢啦!
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
public class xj{
static final int h=200;
static final int w=300;
static JTextField jt = new JTextField(20);
public static void main(String args[])
{
JFrame jf = new JFrame("");
jf.setSize(h,w);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setVisible(true);
JPanel contentPane = new JPanel();
contentPane.setLayout (new BorderLayout());
jf.setContentPane(contentPane);
JLabel jl = new JLabel("");
JButton jb = new JButton("");
contentPane.add(jl,"North");
contentPane.add(jt,"Center");
contentPane.add(jb,"South");
ActionListener ac = new ActionliHandler();
jb.addActionListener(ac);
}
class ActionHandler implements ActionListener
{
public void actionPerformed(ActionEvent e){
xj t= new xj();
int sum=0;
for (int i=0;i<=50;i=i+1)
sum=sum+i*i;
t.jt.setText(""+sum);
}
}
}
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
public class xj{
static final int h=200;
static final int w=300;
static JTextField jt = new JTextField(20);
public static void main(String args[])
{
JFrame jf = new JFrame("");
jf.setSize(h,w);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setVisible(true);
JPanel contentPane = new JPanel();
contentPane.setLayout (new BorderLayout());
jf.setContentPane(contentPane);
JLabel jl = new JLabel("");
JButton jb = new JButton("");
contentPane.add(jl,"North");
contentPane.add(jt,"Center");
contentPane.add(jb,"South");
ActionListener ac = new ActionliHandler();
jb.addActionListener(ac);
}
class ActionHandler implements ActionListener
{
public void actionPerformed(ActionEvent e){
xj t= new xj();
int sum=0;
for (int i=0;i<=50;i=i+1)
sum=sum+i*i;
t.jt.setText(""+sum);
}
}
}