波斯猫怎么养:谁能帮我挑挑这个java程序

来源:百度文库 编辑:高考问答 时间:2024/04/30 11:57:58
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.io.*;

public class SimpleFrame extends JFrame{
public SimpleFrame(int width,int height){
setSize(width,height);
setTitle("ͨѶ¼");
Dimension screenSize=kit.getScreenSize();
int x=(screenSize.width-width)/2;
int y=(screenSize.height-height)/2;
setLocation(x,y);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
try{
jbInit();
}
catch(Exception e){
e.printStackTrace();
}
private void jbInit() throws Exception{
Container contentPane=getContentPane();
contentPane.setLayout(new FlowLayout());
JButton1 jb=new JButton1();
JButton1.setActionCommand("Ôö¼Ó");
JButton1.addActionListener(this);
contentPane.add(JButton1,new XYConstraints(350,260,20,10));
JButton2=new JButton2();
JButton2.setActionCommand("ɾ³ý");
JButton2.addActionListener(this);
contentPane.add(JButton2,new XYConstraints(350,230,20,10));
JButton3=new JButton3();
JButton3.setActionCommand("ÐÞ¸Ä");
JButton3.addActionListener(this);
contentPane.add(JButton3,new XYConstraints(350,200,20,10));
JButton4=new JButton();
JButton4.setActionCommand("ÉýÐò");
JButton4.addActionListener(this);
contentPane.add(JButton4,new XYConstraints(350,170,20,10));
JButton5=new JButton();
JButton5.setActionCommand("½µÐò");
JButton5.addActionListener(this);
contentPane.add(JButton5,new XYConstraints(350,140,20,10));
JButton6=new JButton();
JButton6.setActionCommand("Í˳ö");
JButton6.addActionListener(this);
contentPane.add(JButton6,new XYConstraints(350,110,20,10));
Container contentPane=getContentPane();
ImageIcon ii=new ImageIcon("");
JLabel1 jl=new JLabel1("µç»°",ii,JLabel.CENTER);
contentPane.add(JLabel1, new XYConstraints(40,80,120,10));
Container contentPane=getContentPane();
ImageIcon ii=new ImageIcon("");
JLabel2 jl=new JLabel2("µØÖ·",ii,JLabel.CENTER);
contentPane.add(JLabel2,new XYConstraints(40,50,20,10));
Container contentPane=getContentPane();
contentPane.setLayout(new FlowLayout());
jtf=new JTextField(15);
contentPane.add(jtf);
}

public static void main(String args[]){
SimpleFrame frame=new SimpleFrame(400,300);
frame.setVisible(true);
}
}

1。。。
try{
jbInit();
}
catch(Exception e){
e.printStackTrace();
}
没有写在方法里面
2。。。还有个 就是上面的朋友提到的
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 改成这样
3。。。
jbutton定义错误
jlable 定义错误

Dimension screenSize=kit.getScreenSize();
如果没有漏看,这里就是错的。
Toolkit.getDefaultToolkit().getScreenSize()

觉得没有什么错的啊
怎么了,那里不对吗?