可以自己用Swing编些小工具玩玩。
要么就直接接项目做,呵呵。
要么就直接接项目做,呵呵。
解决方案 »
- java io基础
- 用java生成gif动画怎么做?
- JAVA 中 怎样判定控制台输入的是字符
- 救命啊~JNI问题~用了很多时间了,还是搞不好~
- table,CellEdit的问题,为什么我改变comboBox的内容,而表格的内容不变呢?代码如下:
- 请问在苹果的OSX系统上也能够安装JDK1.4以上的版本吗?请高手指教
- 紧急求助---java本地化问题
- jar是否可以解压到指定的路径(盘与盘之间),是否可以压缩到指定的路径?
- htmlconvernter怎么用?
- java 中文utf-8 转成中文GBK
- 如何在applet 中显示eps 图形文件
- NUllpointerException 错误
能给个例子吗?
Java版QQ,包括文档及源代码下载~不错的学习项目
%jdk_home%\demo\jfc\java2d\先运行一下看看,够综合吗?
源码在*.jar里
数据库自己解决吧。
import java.lang.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import java.sql.*;
import java.util.*;
//主函数、主要类
public class JCTX{
public static void main(String []args)
{
new Frm_Main();
}
}
//实现类
class Frm_Main implements ActionListener //throws IOException
{
public JFrame frame;
public Container c;
public JMenuBar menuBar;
public JMenu mainMenu1;
public JMenu mainMenu2;
public JMenu mainMenu3;
public JMenuItem subMenu1[] = new JMenuItem[5];
public JMenuItem subMenu2[] = new JMenuItem[7];
public JMenuItem subMenu3[] = new JMenuItem[2];
JButton toolBarButton[] = new JButton[8];
public JToolBar toolBar;
//////////////////////////////////////////////
String strTip[] = {"查询您要找的学生记录...","添加学生记录...","删除已有的学生记录","修改学生记录...","使您修改的学生记录生效...","使您添加的学生记录生效...","确认删除当前记录...","退出本系统:)"};
//////////////////////////////////////////////
String id = new String();
String name = new String();
String number = new String();
String classs = new String();
String kechen = new String();
String scoree1 = new String();
float scoree=0;
//////////////////////////////////////////////
Connection con;
ResultSet rs=null,rs1;
Statement st;///////////////////////////////////////////////
public JLabel idL = new JLabel("ID:");
public JLabel nameL = new JLabel("姓名:");
public JLabel numberL = new JLabel("学号:");
public JLabel classsL = new JLabel("班级:");
public JLabel kechenL= new JLabel("课程:");
public JLabel scoreeL = new JLabel("成绩:");
public JTextField idT = new JTextField();
public JTextField nameT = new JTextField();
public JTextField numberT = new JTextField();
public JTextField classsT = new JTextField();
public JTextField scoreeT = new JTextField();
public JTextField kechenT = new JTextField();
////////////////////////////////////////////////////////////////////////////////////////////
public Frm_Main()
{
/////////////////////////////////////////////////
frame = new JFrame("学生成绩信息管理系统");
c = frame.getContentPane();
c.setLayout(null);
menuBar = new JMenuBar();
toolBar = new JToolBar();
toolBar.setFloatable(false);
frame.setJMenuBar(menuBar);
frame.setResizable(false);
////////////////////////////////////////////////
mainMenu1 = new JMenu("管理");
String str1[] = {"添加用户","删除用户","查询用户"," ","退出"};
for(int i=0;i<5;i++)
{
if(i==3)
mainMenu1.addSeparator();
else
{
subMenu1[i] = new JMenuItem(str1[i]);
subMenu1[i].addActionListener(this);
mainMenu1.add(subMenu1[i]);
}
}
menuBar.add(mainMenu1);
/////////////////////////////////////////////////
mainMenu2 = new JMenu("学生成绩排序");
//******************************************************
String str2[] = {"最高分","最低分","平均分","排序"}; //******************************************************
for(int i=0;i<4;i++)
{
subMenu2[i] = new JMenuItem(str2[i]);
subMenu2[i].addActionListener(this);
mainMenu2.add(subMenu2[i]);
}
menuBar.add(mainMenu2);
/////////////////////////////////////////////////
mainMenu3 = new JMenu("帮助");
String str3[] = {"帮助...","关于..."};
for(int i=0;i<2;i++)
{
subMenu3[i] = new JMenuItem(str3[i]);
subMenu3[i].addActionListener(this);
mainMenu3.add(subMenu3[i]);
}
menuBar.add(mainMenu3);
////////////////////////////////////////////////
String strToolBar[] ={"查询","添加","删除","修改","提交修改","提交添加","确认删除","查看全部成绩信息"}; for(int i=0;i<8;i++)
{ toolBarButton[i] = new JButton(strToolBar[i]);
toolBarButton[i].setToolTipText(strTip[i]);
toolBarButton[i].addActionListener(this);
toolBar.add(toolBarButton[i]); }
toolBar.setLocation(0,0);
toolBar.setSize(460,40);
c.add(toolBar);
////////////////////////////////////////////////
idL.setLocation(35,40);
idL.setSize(40,20);
//idL.setFont(new Font("宋体",Font.BOLD,12));
c.add(idL); idT.setLocation(90,40);
idT.setSize(200,20);
//idT.setEnabled(false);
c.add(idT); nameL.setLocation(35,70);
nameL.setSize(40,20);
c.add(nameL); nameT.setLocation(90,70);
nameT.setSize(200,20);
c.add(nameT); numberL.setLocation(35,100);
numberL.setSize(40,20);
c.add(numberL); numberT.setLocation(90,100);
numberT.setSize(200,20);
c.add(numberT); classsL.setLocation(35,130);
classsL.setSize(40,20);
c.add(classsL); classsT.setLocation(90,130);
classsT.setSize(200,20);
c.add(classsT); scoreeL.setLocation(35,190);
scoreeL.setSize(40,20);
c.add(scoreeL); scoreeT.setLocation(90,190);
scoreeT.setSize(200,20);
c.add(scoreeT); kechenL.setLocation(35,160);
kechenL.setSize(40,20);
c.add(kechenL); kechenT.setLocation(90,160);
kechenT.setSize(200,20);
c.add(kechenT);
///////////////////////////////////////////////// JLabel information = new JLabel("-JAVA课程设计-徐砚如-");
information.setFont(new Font("宋体",Font.BOLD,35));
information.setSize(460,140);
information.setLocation(10,210);
c.add(information);
////////////////////////////////////////////////
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(460,400);
frame.setLocation(200,200);
frame.setVisible(true);
//调用连接数据库
conDB();
} //以上是设置数据库面版、框架
public void conDB()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); }
catch(ClassNotFoundException e)
{
JOptionPane.showMessageDialog(null,"您数据库加载失败了!");
}
try
{
con = DriverManager.getConnection("jdbc:odbc:gzwjava","sa","");
st = con.createStatement();
} //ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE
catch(SQLException e)
{
JOptionPane.showMessageDialog(null,"您数据库连接失败了!");
} }
//以下是针对数据库的各种操作
public void actionPerformed(ActionEvent e)
{
//////////////////////////////////////////////////////////////////////////////////////
// if(e.getSource()==subMenu3[1] ||e.getSource()==toolBarButton[7])
if(e.getSource()==subMenu3[1])
//关于
//********************************************************
{
final ImageFrame about=new ImageFrame();
about.locate(400,400);
about.show();
}
//********************************************************
//JOptionPane.showMessageDialog(null,"本软件的程序由徐砚如编凑而成!");
//*********************************
if (e.getSource()==toolBarButton[7])
{
final student app = new student();
app.addWindowListener(
new WindowAdapter()
{
public void windowClosing( WindowEvent e )
{
app.shutDown();
// System.exit( 0 );
}
} );
}
if(e.getSource()==subMenu3[0])
JOptionPane.showMessageDialog(null,"不好意思还没有帮助");
//*********************************
///////////////////////////////////////////////////////////////////////////////////
if(e.getSource()==subMenu1[0] || e.getSource()==subMenu1[1] || e.getSource()==subMenu1[2] )
JOptionPane.showMessageDialog(null,"本功能不打算实现了,因为时间和能力有限有机会再添加上去吧!");
//***************
// if(e.getSource()==subMenu1[4])
// System.exit(1);
//****************
///////////////////////////////////////////////////////////////////////////////////// //查找功能的实现
//if(e.getSource()==subMenu2[0]||e.getSource()==toolBarButton[0])
if(e.getSource()==toolBarButton[0])
{
String idid = JOptionPane.showInputDialog("请输入要查找的学生学号");
if(idid.trim()!="")
{
String strSQL = "select * from score where 学号='"+idid+"'";
try
{
rs = st.executeQuery(strSQL);
int count = 0;
// boolean a=true;
while(rs.next())
{
//***********************************
id=rs.getString("id");
name = rs.getString("姓名");
// number=rs.getString("学号");
// System.out.println("66666666666666"+number);
classs = rs.getString("班级");
kechen = rs.getString("课程");
scoree = rs.getFloat("成绩");
scoree1=scoree1+scoree;
++count;
//************************************
}
if(count==0)
JOptionPane.showMessageDialog(null,"对不起,没有您要查找的学生!");
else
{
idT.setText(id);
nameT.setText(name);
numberT.setText(idid);
kechenT.setText(kechen);
classsT.setText(classs);
scoreeT.setText(scoree1);
}
}
catch(SQLException ex)
{
ex.printStackTrace();
JOptionPane.showMessageDialog(null,"抱歉,程序出现异常!");
} }
}
//***************************************************
if(e.getSource()==subMenu2[0])
{
try{
String strSQL = "select * from scoremax";
rs = st.executeQuery(strSQL);
rs.next();
JOptionPane.showMessageDialog(null,"最高分:"+rs.getString("最高分"));
}
catch(SQLException ex)
{
//ex.printStackTrace();
JOptionPane.showMessageDialog(null,"抱歉,程序出现异常!");
}
}
//***************************************************
////////////////////////////////////////////////////////////////////////////////////
if(e.getSource()==subMenu1[4])
{
closeDB();
System.exit(1); //退出程序
}
//查找添加的实现
/////////////////////////////////////////////////////////////////////////////////////
//if(e.getSource()==subMenu2[1] || e.getSource()==toolBarButton[1]) if(e.getSource()==toolBarButton[1])
{
JOptionPane.showMessageDialog(null,"请输入要添加的学生信息");
idT.setEnabled(true);
idT.setText("");
nameT.setText("");
numberT.setText("");
kechenT.setText("");
classsT.setText("");
scoreeT.setText("");
numberT.setEnabled(true);
}
//最低分的实现
//***************************************************
if(e.getSource()==subMenu2[1])
{
try{
String strSQL = "select * from scoremin";
rs = st.executeQuery(strSQL);
rs.next();
JOptionPane.showMessageDialog(null,"最低分:"+rs.getString("最低分"));
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,"抱歉,程序出现异常!");
}
}
//***************************************************
//提交功能的实现
//////////////////////////////////////////////////////////////////////////////////////
// if(e.getSource()==toolBarButton[5] || e.getSource()==subMenu2[5])
if(e.getSource()==toolBarButton[5])
{
if((nameT.getText().trim()).equals("") || (numberT.getText().trim()).equals("") || (kechenT.getText().trim()).equals("") ||(classsT.getText().trim()).equals("") || (scoreeT.getText().trim()).equals(""))
JOptionPane.showMessageDialog(null,"请输入信息再点击提交添加!");
else
{
id = idT.getText();
name = nameT.getText();
number = numberT.getText();
kechen = kechenT.getText();
classs = classsT.getText();
scoree = Float.parseFloat(scoreeT.getText());
String strSQL ="insert into score(id,姓名,学号,课程,班级,成绩) values('" + id + "','" + name + "','" + number + "','" + kechen + "','" + classs + "'," + scoree + ")";
try
{
st.executeUpdate(strSQL);
}
catch(Exception exx)
{
JOptionPane.showMessageDialog(null,"数据库中已经存在您要添加的学生的学号!");
/*idT.setText("");
nameT.setText("");
numberT.setText("");
kechenT.setText("");
classsT.setText("");
scoreeT.setText("");*/
return;
}
JOptionPane.showMessageDialog(null,"恭喜您,添加成功了!");
//**************************************
idT.setText("");
nameT.setText("");
numberT.setText("");
kechenT.setText("");
classsT.setText("");
scoreeT.setText("");
//*************************************
}
}