- 博客(0)
- 资源 (1)
- 收藏
- 关注
java+通讯录
java 通讯录 可以用来做课程设计
代码
import java.awt.*;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import java.awt.event.*;
import java.sql.*;
import java.util.Vector;
import java.sql.ResultSet;
//******************************定义主窗口********************************
class Interface extends JFrame
{
JLabel txl=new JLabel("通讯录记录如下:");
JButton bc=new JButton("保存");
JButton sx=new JButton("刷新");
JButton tc=new JButton("退出");
JButton tj=new JButton("添加");
JButton sc=new JButton("删除");
JButton cz=new JButton("查找");
JMenuBar bar=new JMenuBar();
JMenu wj=new JMenu("文件");
JMenu bj=new JMenu("编辑");
JMenu bz=new JMenu("帮助");
JMenuItem barbc = new JMenuItem("保存");
JMenuItem bartc = new JMenuItem("退出");
JMenuItem bartj = new JMenuItem("添加");
JMenuItem barsy = new JMenuItem("如何使用?");
JMenuItem bargy = new JMenuItem("关于");
JMenuItem barsc = new JMenuItem("删除");
JMenuItem barcz = new JMenuItem("查找");
JMenuItem barlj = new JMenuItem("测试与数据库连接");
JMenu barpx = new JMenu("排序");
JMenuItem barpxid = new JMenuItem("按序号排序");
JMenuItem barpxxm = new JMenuItem("按姓名排序");
TableColumn column=new TableColumn();
static Object PersonInfo[][]={};
static String head[] = {"ID","姓名","性别","电话","QQ","家庭住址"};
static DefaultTableModel model = new DefaultTableModel(PersonInfo,head);
static JTable table=new JTable(model);
//****************************初始化主窗口*******************************
public Interface()
{
setLayout(null);
wj.add(barbc);
wj.addSeparator();
wj.add(barlj);
wj.addSeparator();
wj.add(barcz);
wj.addSeparator();
wj.add(bartc);
bj.add(bartj);
bj.add(barsc);
bj.addSeparator();
bj.add(barpx);
barpx.add(barpxid);
barpx.add(barpxxm);
bz.add(barsy);
bz.addSeparator();
bz.add(bargy);
bar.add(wj);
bar.add(bj);
bar.add(bz);
this.setJMenuBar(bar);
txl.setForeground(Color.BLUE);
this.add(txl);
txl.setFont(new Font("华文彩云",Font.BOLD,30));
txl.setBounds(new Rectangle(180,10,350,40));
//**************************添加网格******************************
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setGridColor(Color.CYAN);
table.setSelectionBackground(Color.YELLOW);
table.setForeground(Color.RED);
JScrollPane jsp=new JScrollPane(table);
jsp.setBounds(new Rectangle(45,60,500,405));
this.add(jsp);
2014-06-30
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人