我是java的初学者,可是感觉自己老入不了门。说学java最好能做个小项目。我照着书上自己写了个小程序,可是用jbuilder自动生成的代码,不知道为什么大部分都看不懂啊。希望有高手可以大致地给我讲解一下!好的话我再多送20分!呵呵,当然相信大家不会为了分数才答得啊!
public class Frame1 extends JFrame {
static int count=0;
JPanel contentPane;
XYLayout xYLayout1 = new XYLayout();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JTextField jTextField1 = new JTextField();
JScrollPane jScrollPane1 = new JScrollPane();
JTextArea jTextArea1 = new JTextArea();
Construct the frame
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);//这个是什么?
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception{
contentPane = (JPanel) this.getContentPane();
jButton1.setFont(new java.awt.Font("Dialog", 0, 11));
jButton1.setActionCommand("文件选择");//??我看不懂这个
jButton1.setText("文件选择");
jButton1.addActionListener(new Frame1_jButton1_actionAdapter(this));
contentPane.setEnabled(false);
contentPane.setLayout(xYLayout1);
this.setSize(new Dimension(400, 300));//这个是什么意思?Dimension?
this.setTitle("example");
jButton2.setText("选择背景颜色");
jButton2.addActionListener(new Frame1_jButton2_actionAdapter(this));
jLabel1.setText("选择的文件列表");
jLabel2.setText("显示文件数目");
jTextField1.setEditable(false);
jTextField1.setText("");
jTextArea1.setText("");
contentPane.add(jLabel2, new XYConstraints(21, 241, 94, 17));
contentPane.add(jTextField1, new XYConstraints(6, 273, 276, 17));
contentPane.add(jScrollPane1,new XYConstraints(11, 49, 248, 174));
contentPane.add(jButton2, new XYConstraints(275, 153, 113, 26));
contentPane.add(jButton1, new XYConstraints(304, 100, -1, 27));
contentPane.add(jLabel1, new XYConstraints(18, 18, 100, 23));
jScrollPane1.getViewport().add(jTextArea1, null);
}
|