您好,现在是想做一个有界面的应用程序,再利用输入输出流实现对数据的读写,从而实现对小型数据库中数据进行增删改查功能,目前界面已做好,问题是在程序怎样导入小型数据库并且实现功能。有程序示例就更好啦,非常感谢!
我做的是学生公寓信息管理系统,以下是我界面的程序,可以看一下
package gtt;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.event.*;
import java.awt.event.*;
import java.io.*;
public class g extends JFrame{
JButton b1=new JButton();
JButton b2=new JButton();
JButton b3=new JButton();
JButton b4=new JButton();
JLabel l1=new JLabel();
JLabel l2=new JLabel();
JLabel l3=new JLabel();
JLabel l4=new JLabel();
JLabel l5=new JLabel();
JLabel l6=new JLabel();
JLabel l7=new JLabel();
JLabel l8=new JLabel();
JLabel l9=new JLabel();
JTextField t1=new JTextField(" "
+ " ");
JTextField t2=new JTextField();
JTextField t3=new JTextField(" ");
JPanel p1=new JPanel();
JPanel p2=new JPanel();
JPanel p3=new JPanel();
JPanel p4=new JPanel();
public g()
{
super("学生公寓信息管理");
setSize(500,660);
Container cp=getContentPane();
cp.setLayout(new GridLayout(2,1));
//p1.setBounds(10, 10, 460, 330);
p1.setBackground(Color. pink);
p1.setBorder(new TitledBorder("查询:"));
cp.add(p1);
p1.add(b1);
b1.setLabel("查找");
p1.add(p3);
p1.add(l4);
//p2.setBounds(10, 380, 460, 330);
p2.setBackground(Color.green);
p2.setBorder(new TitledBorder("学生公寓清单:"));
cp.add(p2);
p2.add(b2);
b2.setLabel("添加");
p2.add(b3);
b3.setLabel("删除");
p2.add(b4);
b4.setLabel("修改");
p2.add(p4);
//p4.setLayout(new GridLayout(2,1));
//p4.setBounds(10, 380, 460, 230);
//p4.add(t3);
p3.setLayout(new GridLayout(3,1));
l1.setText("楼号:");
p3.add(l1);
p3.add(t1);
l2.setText("宿舍号:");
p3.add(l2);
p3.add(t2);
l3.setText("男/女生公寓:");
p3.add(l3);
Choice ch1=new Choice();
ch1.add("男生");
ch1.add("女生");
p3.add(ch1);
//p4.setLayout(new GridLayout(1,1));
//p4.setBounds(10, 380, 460, 230);
p4.add(t3);
b1.addMouseListener(new aa());
b2.addMouseListener(new bb());
b3.addMouseListener(new cc());
b4.addMouseListener(new dd());
setVisible(true);
}
class aa extends MouseAdapter
{
public void mouseClicked(MouseEvent e)
{
l4.setText("OK!成功!");
}
}
class bb extends MouseAdapter
{
public void mouseClicked(MouseEvent e)
{
l5.setText("OK!成功!");
}
}
class cc extends MouseAdapter
{
public void mouseClicked(MouseEvent e)
{
l6.setText("OK!成功!");
}
}
class dd extends MouseAdapter
{
public void mouseClicked(MouseEvent e)
{
l7.setText("OK!成功!");
}
}
public static void main(String[] args)
{
new g();
}
}
运行之后就是这样子