| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 531 人关注过本帖
标题:求助:帮我修改下这个程序,明天要用,谢谢了!!
只看楼主 加入收藏
Limifan
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2009-12-17
结帖率:100%
收藏
 问题点数:0 回复次数:0 
求助:帮我修改下这个程序,明天要用,谢谢了!!
帮我这个程序加上班级和学号,并把他们的布局排列好,优化一下,最好全部加上注释,谢谢了!
package com.hpjianhua.swing;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;



class RunFrame extends JFrame {

    private JLabel name_label, sex_label, pro_label, lev_label;//声明标签
    private TextField field;   //声明文字栏
    private JCheckBox manButton, womanButton;//声明复选框
    private JComboBox proList, levList;//声明组合框
    private JTextArea mainText;//申明文本域
    private JButton confirmButton, cancelButton;//声明按钮
    private JPanel panel1, panel2, panel3, panel4, panel5, panel6, panel1_2,
            panel3_4, panel5_6;
   

    public RunFrame() {
        // this.setLayout(new GridLayout());
        this.setTitle("08电信学院个人简历");//设置窗口标题
        this.setSize(300, 400);//设置窗口大小
        this.setLocation(200, 200);
        panel1 = new JPanel();
        panel2 = new JPanel();
        panel3 = new JPanel();
        panel4 = new JPanel();
        panel5 = new JPanel();
        panel6 = new JPanel();
        panel1_2 = new JPanel();
        panel3_4 = new JPanel();
        panel5_6 = new JPanel();
        
        /*各窗口的布局*/
        panel1.setLayout(new FlowLayout());
        name_label = new JLabel("姓名");
    //    num_label = new JLabel("学号");
        panel1.add(name_label);
    //    panel1.add(num_label);
        field = new TextField(6);
        
        panel1.add(field);
        panel2.setLayout(new FlowLayout());
        sex_label = new JLabel("性别");
        panel2.add(sex_label);
        manButton = new JCheckBox("男");
        panel2.add(manButton);
        womanButton = new JCheckBox("女");
        panel2.add(womanButton);

        panel3.setLayout(new FlowLayout());
        pro_label = new JLabel("专业");
        panel3.add(pro_label);
        //选择列表内容
        String[] listValue1 = new String[] { "计算机网络技术", "计算机应用技术", "医疗电子技术" ,"计算机信息管理","软件技术","电子信息工程技术","电子工艺与管理","信息安全技术","微电子","通信技术","移动通信技术"};
        String[] listValue2 = new String[] { "1985","1986","1987", "1988", "1989", "1990","1991","1992"};
        proList = new JComboBox(listValue1);
        panel3.add(proList);

        panel4.setLayout(new FlowLayout());
        lev_label = new JLabel("出生年月");
        panel4.add(lev_label);
        levList = new JComboBox(listValue2);
        panel4.add(levList);

        confimButtonAction cofaction = new confimButtonAction();//调用confimButtonAction()
        cancelButtonAction canaction = new cancelButtonAction();//调用cancelButtonAction()
        panel5.setLayout(new FlowLayout());
        confirmButton = new JButton("提交");
        confirmButton.addActionListener(cofaction);
        panel5.add(confirmButton);
        cancelButton = new JButton("取消");
        cancelButton.addActionListener(canaction);
        panel5.add(cancelButton);

        panel6.setLayout(new FlowLayout());
        mainText = new JTextArea();
        mainText.setColumns(20);
        mainText.setRows(10);
        panel6.add(mainText);
        panel1_2.add(panel1, BorderLayout.WEST);//麻烦这里加上注释
        panel1_2.add(panel2, BorderLayout.EAST);
        panel3_4.add(panel3, BorderLayout.WEST);
        panel3_4.add(panel4, BorderLayout.EAST);
        panel3_4.add(panel5, BorderLayout.SOUTH);
        panel5_6.add(panel6, BorderLayout.SOUTH);
        this.getContentPane().add(panel1_2, BorderLayout.NORTH);
        // this.getContentPane().add(panel2,BorderLayout.EAST);
        this.getContentPane().add(panel3_4, BorderLayout.CENTER);
        this.getContentPane().add(panel5_6, BorderLayout.SOUTH);

        this.addWindowListener(new WindowAdapter() {        //添加窗口监听功能
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        this.setVisible(true);

    }

    class confimButtonAction implements ActionListener {     //提交按钮功能

        public void actionPerformed(ActionEvent e) {
            String sex ="";
            if(manButton.isSelected()){
                sex="男";
            
            }else {
                sex="女";
            }
            mainText.setText("姓名:" + field.getText() +"\n" + "性别:" + sex
                    + "\n" + "专业:" + (String) proList.getSelectedItem() + "\n"
                    + "出生年月:" + (String) levList.getSelectedItem() + "\n");
        }
    }

    class cancelButtonAction implements ActionListener {   //取消按钮功能

        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    }
}
public class limi {                     //主函数

    public static void main(String[] args) {
        new RunFrame();
    }
}

[ 本帖最后由 Limifan 于 2009-12-24 23:23 编辑 ]
搜索更多相关主题的帖子: 优化 package import 最好 
2009-12-24 23:03
快速回复:求助:帮我修改下这个程序,明天要用,谢谢了!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018099 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved