简单的java课程设计(JAVA课程设计方案)

本文目录
JAVA课程设计方案
图书管理系统、学生选课系统、俄罗斯方块、数独等等,刚开始还是做个简单的点吧,计算器可以的,基本上涉及到了你所学习的知识。
计算器思路:1、初始化布局,数字、符号、文本等组建(布局设计有点小困难的、对比一下别人写的)
2、对按钮添加 监听事件
3、处理各种非正常操作情况,比如被除数为0、输入了多个符号等等
求助:java课程设计 图书基本信息管理,越简单越好
100分想让别人给你单独写一个程序应该是没人给你写的,还是参考一下别人类似的代码吧,我大二的时候写过一个系统:个人财务管理系统你拿去参考下吧
//登录类:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javawork.jdbc.*;
public class Login extends JFrame implements ActionListener{
public static void main(String ary){
new Login("home financial management system");
}
private JButton login=new JButton("登陆");
private JButton register=new JButton("注册");
private JButton cancel=new JButton("取消");
private JPanel panelsouth=new JPanel(new FlowLayout(new FlowLayout().CENTER));
private JPanel paneluser=new JPanel(new FlowLayout(new FlowLayout().CENTER));
private JPanel panelpassword=new JPanel(new FlowLayout(new FlowLayout().CENTER));
private JPanel panelcenter=new JPanel(new GridLayout(2,1));
private JLabel user=new JLabel("用户名: ");
private JLabel title=new JLabel(" 家庭财务管理系统");
private JLabel password=new JLabel("密 码: ");
private JTextField userT=new JTextField(10);
private JPasswordField passwordT=new JPasswordField(10);
public Login(String title){
super(title);
this.setResizable(false);
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){System.exit(0);}
});
this.setBounds(300,250,350,250);
frameLayout();
addListener();
this.setVisible(true);
}
public void frameLayout(){
panelsouth.add(login);
panelsouth.add(register);
panelsouth.add(cancel);
this.getContentPane().add(panelsouth,BorderLayout.SOUTH);
paneluser.add(user);
paneluser.add(userT);
panelpassword.add(password);
panelpassword.add(passwordT);
panelcenter.add(paneluser);
panelcenter.add(panelpassword);
this.getContentPane().add(panelcenter,BorderLayout.CENTER);
title.setFont(new Font("黑体",Font.BOLD,30));
this.getContentPane().add(title,BorderLayout.NORTH);
}
public void addListener(){
login.addActionListener(this);
cancel.addActionListener(this);
register.addActionListener(this);
passwordT.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==login||e.getSource()==passwordT){
String use=userT.getText();
String pass=new String(passwordT.getPassword());
Operate operate=new Operate();
if(operate.login(use, pass)){
new MainFrame(userT.getText());
this.setVisible(false);
}else{
JOptionPane.showMessageDialog(this, "用户名或密码不正确");
}
}
if(e.getSource()==register){
String info="";
String use=userT.getText();
String pass=new String(passwordT.getPassword());
Operate operate=new Operate();
if(operate.register(use, pass)){
info="注册成功";
}else{
info="注册失败";
}
JOptionPane.showMessageDialog(this, info);
}
if(e.getSource()==cancel){
System.exit(0);
}
}
}
//主柜架类:
import java.awt.event.*;
import javawork.bean.SysBean;
import javawork.jdbc.*;
import javax.swing.*;
import java.awt.*;
import java.util.Vector;
public class MainFrame extends JFrame implements ActionListener{
private boolean mode=true;
private JTable tabel=null;
private JPanel south=new JPanel(new FlowLayout(new FlowLayout().CENTER));
private JPanel north=new JPanel(new FlowLayout(new FlowLayout().CENTER));
private JLabel begin=new JLabel("从:");
private JLabel beginyear=new JLabel("年");
private JLabel beginmonth=new JLabel("月");
private JLabel beginday=new JLabel("日");
private JLabel end=new JLabel("到:");
private JLabel endyear=new JLabel("年");
private JLabel endmonth=new JLabel("月");
private JLabel endday=new JLabel("日");
private JComboBox beginyearB=new JComboBox();
private JComboBox beginmonthB=new JComboBox();
private JComboBox begindayB=new JComboBox();
private JComboBox endyearB=new JComboBox();
private JComboBox endmonthB=new JComboBox();
private JComboBox enddayB=new JComboBox();
private JButton add=new JButton("添加记录");
private JButton delete=new JButton("删除记录");
private JButton update=new JButton("更新记录");
private JButton cancel=new JButton("退出系统");
private JButton refresh=new JButton("刷新记录");
private JButton select=new JButton("查询记录");
String info=null;
private String field={"ID","spending","epecificSpending","income","epecificIncome","total","journal","date"};
private String use=null;
public MainFrame(String name){
use=name;
this.setTitle("home financial management system");
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
this.setSize(700,500);
this.setResizable(false);
this.setLocationRelativeTo(null);
frameLayout();
addListener();
this.setVisible(true);
}
public void editnorth(){
for(int i=1950;i《=2050;i++){
beginyearB.addItem(""+i);
endyearB.addItem(""+i);
}
for(int i=1;i《=12;i++){
beginmonthB.addItem(""+i);
endmonthB.addItem(""+i);
}
north.add(begin); north.add(beginyear); north.add(beginyearB);
north.add(beginmonth);north.add(beginmonthB);
north.add(beginday); north.add(begindayB);
north.add(end); north.add(endyear); north.add(endyearB);
north.add(endmonth); north.add(endmonthB);
north.add(endday); north.add(enddayB); north.add(select);
}
Vector《SysBean》 vector=new Operate().select(use);
public void editJTable(){
info=new String;
info{"","","","","","","",""};
for(int i=1;i《vector.size()+1;i++){
info=""+vector.get(i-1).getID();
info=""+vector.get(i-1).getSpending();
info=""+vector.get(i-1).getEpecificSpending();
info=""+vector.get(i-1).getIncome();
info=""+vector.get(i-1).getEpecificIncome();
info=""+vector.get(i-1).getTotal();
info=""+vector.get(i-1).getJournal();
info=""+vector.get(i-1).getDate();
}
}
public void frameLayout(){
south.add(add);
south.add(delete);
south.add(update);
south.add(refresh);
south.add(cancel);
editnorth();
editJTable();
tabel=new JTable(info,field);
tabel.setAutoResizeMode(tabel.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
this.getContentPane().add(new JScrollPane(tabel),BorderLayout.CENTER);
this.getContentPane().add(south,BorderLayout.SOUTH);
this.getContentPane().add(north,BorderLayout.NORTH);
}
public void addListener(){
add.addActionListener(this);
delete.addActionListener(this);
update.addActionListener(this);
cancel.addActionListener(this);
refresh.addActionListener(this);
select.addActionListener(this);
beginmonthB.addActionListener(this);
beginyearB.addActionListener(this);
endyearB.addActionListener(this);
endmonthB.addActionListener(this);
}
public void removeB(){
beginyearB.removeAll();
beginmonthB.removeAll();
begindayB.removeAll();
endyearB.removeAll();
endmonthB.removeAll();
enddayB.removeAll();
}
public void removeListener(){
add.removeActionListener(this);
delete.removeActionListener(this);
update.removeActionListener(this);
cancel.removeActionListener(this);
refresh.removeActionListener(this);
select.removeActionListener(this);
beginmonthB.removeActionListener(this);
endmonthB.removeActionListener(this);
beginyearB.removeActionListener(this);
endyearB.removeActionListener(this);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==add){
addSource();
}if(e.getSource()==delete){
deleteSource();
}if(e.getSource()==update){
updateSource();
}if(e.getSource()==select){
selectSource();
}if(e.getSource()==cancel){
System.exit(0);
}if(e.getSource()==refresh){
refreshSource();
}if(e.getSource()==beginmonthB||e.getSource()==beginyearB){
beginmonthBSource();
}if(e.getSource()==endmonthB||e.getSource()==endyearB){
endmonthBSource();
}
}
public void refreshSource(){
//beginyearB.removeAll();
//beginmonthB.removeAll();
//endyearB.removeAll();
//endmonthB.removeAll();
frameLayout();
this.setVisible(true);
}
public void deleteSource(){
String info="";
try{
int ID=Integer.parseInt(((String)tabel.getValueAt(0, 0)).trim());
if(new Operate().delete(ID, use)){
info="删除成功";
}else{
info="删除失败";
}
}catch(Exception e){
info="请正确输入数据";
}
JOptionPane.showMessageDialog(this,info);
}
public void selectSource(){
String byear=(String)beginyearB.getSelectedItem();
String bmonth=(String)beginmonthB.getSelectedItem();
String bday=(String)begindayB.getSelectedItem();
String eyear=(String)endyearB.getSelectedItem();
String emonth=(String)endmonthB.getSelectedItem();
String eday=(String)enddayB.getSelectedItem();
if("".equals(bday)){
bday="01";
}if("".equals(eday)){
eday="01";
}
String beginDate=byear+"-"+bmonth+"-"+bday;
String endDate=eyear+"-"+emonth+"-"+eday;
vector=new Operate().selectDay(use, java.sql.Date.valueOf(beginDate), java.sql.Date.valueOf(endDate));
refreshSource();
}
public void beginmonthBSource(){
int byear=Integer.parseInt((String)beginyearB.getSelectedItem());
int bmonth=Integer.parseInt((String)beginmonthB.getSelectedItem());
removeB();
boolean yn=false;
if((byear%4==0&&byear%100!=0)||(byear%100==0&&byear%400==0)){
yn=true;
}
for(int i=1;i《=31;i++){
if(bmonth==2){
if(yn){
if(i《=28){
begindayB.addItem(""+i);
}
}else{
if(i《=29){
begindayB.addItem(""+i);
}
}
}else{
if(bmonth==1||bmonth==3||bmonth==5||bmonth==7||bmonth==8||bmonth==10||bmonth==12){
begindayB.addItem(""+i);
}else{
if(i《=30){
begindayB.addItem(""+i);
}
}
}
}
}
public void endmonthBSource(){
int eyear=Integer.parseInt((String)endyearB.getSelectedItem());
int emonth=Integer.parseInt((String)endmonthB.getSelectedItem());
boolean yn=false;
removeB();
if((eyear%4==0&&eyear%100!=0)||(eyear%100==0&&eyear%400==0)){
yn=true;
}
for(int i=1;i《=31;i++){
if(emonth==2){
if(yn){
if(i《=28){
enddayB.addItem(""+i);
}
}
}else{
if(emonth==1||emonth==3||emonth==5||emonth==7||emonth==8||emonth==10||emonth==12){
enddayB.addItem(""+i);
}else{
if(i《=30){
enddayB.addItem(""+i);
}
}
}
}
System.out.print("haah");
}
public void updateSource(){
String info=null;
boolean model=true;
String ID=((String)tabel.getValueAt(0,0)).trim();
String spend=((String)tabel.getValueAt(0,1)).trim();
String epecificSpending=(String)tabel.getValueAt(0, 2);
String come=((String)tabel.getValueAt(0, 3)).trim();
String epecificIncome=(String)tabel.getValueAt(0, 4);
String journal=(String)tabel.getValueAt(0, 6);
try{
int id=Integer.parseInt(ID);
float spending=Float.parseFloat(spend);
float income=Float.parseFloat(come);
tabel.setValueAt(""+(income-spending), 0, 4);
SysBean sysbean=new SysBean();
sysbean.setName(use);
sysbean.setID(id);
sysbean.setSpending(spending);
sysbean.setEpecificSpending(epecificSpending);
sysbean.setIncome(income);
sysbean.setEpecificIncome(epecificIncome);
sysbean.setJournal(journal);
model=new Operate().update(sysbean);
if(model){
info="更新成功!";
tabel.setValueAt("", 0,0);
tabel.setValueAt("", 0,1);
tabel.setValueAt("", 0,2);
tabel.setValueAt("", 0,3);
tabel.setValueAt("", 0,4);
tabel.setValueAt("", 0,5);
tabel.setValueAt("", 0,6);
}else{
info="更新失败!";
}
}catch(Exception o){
info="请正确输入数据!";
}
JOptionPane.showMessageDialog(this, info);
}
public void addSource(){
String info=null;
boolean model=true;
String spend=((String)tabel.getValueAt(0,1)).trim();
String epecificSpending=(String)tabel.getValueAt(0, 2);
String come=((String)tabel.getValueAt(0, 3)).trim();
String epecificIncome=(String)tabel.getValueAt(0, 4);
String journal=(String)tabel.getValueAt(0, 6);
try{
float spending=Float.parseFloat(spend);
float income=Float.parseFloat(come);
tabel.setValueAt(""+(income-spending), 0, 4);
SysBean sysbean=new SysBean();
sysbean.setName(use);
sysbean.setSpending(spending);
sysbean.setEpecificSpending(epecificSpending);
sysbean.setIncome(income);
sysbean.setEpecificIncome(epecificIncome);
sysbean.setJournal(journal);
model=new Operate().add(sysbean);
if(model){
info="添加成功!";
tabel.setValueAt("", 0,0);
tabel.setValueAt("", 0,1);
tabel.setValueAt("", 0,2);
tabel.setValueAt("", 0,3);
tabel.setValueAt("", 0,4);
tabel.setValueAt("", 0,5);
tabel.setValueAt("", 0,6);
}else{
info="添加失败!";
}
}catch(Exception o){
info="请正确输入数据!";
}
JOptionPane.showMessageDialog(this, info);
}
}
操作类:
import java.sql.*;
import java.util.*;
import javawork.bean.*;
public class Operate {
Connection conn=null;
PreparedStatement pstmt=null;
ResultSet rs=null;
String sql=null;
public Vector《SysBean》 selectDay(String name,java.sql.Date beginDate,java.sql.Date endDate){
Vector《SysBean》 vector=new Vector《SysBean》();
System.out.println("selectDay"+" "+beginDate+" "+endDate);
init();
sql="select * from info where name=? and date between ? and ?";
pstmt=DataBaseConnection.getpStmt(conn, sql);
try {
pstmt.setString(1, name);
pstmt.setDate(2, beginDate);
pstmt.setDate(3, endDate);
rs=pstmt.executeQuery();
while(rs.next()){
SysBean sysbean=new SysBean();
sysbean.setID(rs.getInt("ID"));
sysbean.setName(rs.getString("name"));
sysbean.setSpending(rs.getFloat("spending"));
sysbean.setEpecificSpending(rs.getString("epecificSpending"));
sysbean.setIncome(rs.getFloat("income"));
sysbean.setEpecificIncome(rs.getString("epecificIncome"));
sysbean.setTotal(rs.getFloat("total"));
sysbean.setJournal(rs.getString("journal"));
sysbean.setDate(rs.getDate("date"));
sysbean.setID(rs.getInt("ID"));
System.out.println("sysbean.getname= "+sysbean.getDate());
vector.add(sysbean);
}
} catch (SQLException e) {
e.printStackTrace();
}
close();
return vector;
}
public void init(){
conn=DataBaseConnection.getConn();
}
public void close(){
if(rs!=null){
DataBaseConnection.closeRs(rs);
}
DataBaseConnection.closePstmt(pstmt);
DataBaseConnection.closeConn(conn);
}
public boolean login(String user,String password){
init();
boolean login=false;
sql="select * from ruse where name=? and password=?";
pstmt=DataBaseConnection.getpStmt(conn, sql);
try {
pstmt.setString(1, user);
pstmt.setString(2, password);
rs=pstmt.executeQuery();
if(rs.next()){
login=true;
}
} catch (SQLException e) {
e.printStackTrace();
}
close();
return login;
}
public Vector《SysBean》 select(String user){
Vector《SysBean》 vector=new Vector《SysBean》();
init();
sql="select * from info where name=?";
pstmt=DataBaseConnection.getpStmt(conn, sql);
try {
pstmt.setString(1, user);
rs=pstmt.executeQuery();
while(rs.next()){
SysBean sysbean=new SysBean();
sysbean.setID(rs.getInt("ID"));
sysbean.setName(rs.getString("name"));
sysbean.setSpending(rs.getFloat("spending"));
sysbean.setEpecificSpending(rs.getString("epecificSpending"));
sysbean.setIncome(rs.getFloat("income"));
sysbean.setEpecificIncome(rs.getString("epecificIncome"));
sysbean.setTotal(rs.getFloat("total"));
sysbean.setJournal(rs.getString("journal"));
sysbean.setDate(rs.getDate("date"));
sysbean.setID(rs.getInt("ID"));
vector.add(sysbean);
}
} catch (SQLException e) {
e.printStackTrace();
}
close();
return vector;
}
public boolean add(SysBean sysbean){
boolean model=true;
init();
sql="insert into info(name,spending,epecificSpending,income," +
"epecificIncome,journal,date) values(?,?,?,?,?,?,?)";
pstmt=DataBaseConnection.getpStmt(conn, sql);
try {
pstmt.setString(1, sysbean.getName());
pstmt.setFloat(2, sysbean.getSpending());
pstmt.setString(3, sysbean.getEpecificSpending());
pstmt.setFloat(4, sysbean.getIncome());
pstmt.setString(5, sysbean.getEpecificIncome());
pstmt.setString(6, sysbean.getJournal());
pstmt.setDate(7, new java.sql.Date(new java.util.Date().getTime()));
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
model=false;
}
close();
return model;
}
public boolean delete(int ID,String use){
boolean model=true;
sql="delete from info where ID=? and name=?";
init();
pstmt=DataBaseConnection.getpStmt(conn, sql);
try {
pstmt.setInt(1, ID);
pstmt.setString(2, use);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
model=false;
}
close();
return model;
}
public boolean update(SysBean sysbean){
boolean model=true;
sql="update info set spending=?," +
"epecificSpending=?,income=?,epecificIncome=?,journal=? where ID=? and name=?";
init();
pstmt=DataBaseConnection.getpStmt(conn, sql);
try{
pstmt.setFloat(1, sysbean.getSpending());
pstmt.setString(2, sysbean.getEpecificSpending());
pstmt.setFloat(3, sysbean.getIncome());
pstmt.setString(4, sysbean.getEpecificIncome());
pstmt.setString(5, sysbean.getJournal());
pstmt.setInt(6, sysbean.getID());
pstmt.setString(7, sysbean.getName());
pstmt.executeUpdate();
}catch(Exception e){
model=false;
}
return model;
}
public boolean register(String wm,String password){
boolean model=true;
sql="insert into ruse values(?,?)";
init();
pstmt=DataBaseConnection.getpStmt(conn, sql);
try{
pstmt.setString(1,wm);
pstmt.setString(2,password);
pstmt.executeUpdate();
}catch(SQLException e){
model=false;
}
return model;
}
}
//数据库连接类:
import java.sql.*;
public class DataBaseConnection {
static{
//2005
//String DBDRIVER="com.microsoft.jdbc.sqlserver.SQLServerDriver";//2000
}
public static Connection getConn(){
String DBDRIVER="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String DBURL="jdbc:sqlserver://localhost:1433;DatabaseName=cwgl";
Connection conn=null;
try {
Class.forName(DBDRIVER);
conn=DriverManager.getConnection(DBURL,"sa","1");
} catch (Exception e) {
e.printStackTrace();
}
return conn;
}
public static void closeConn(Connection conn){
try {
conn.close();
conn=null;
} catch (SQLException e) {
e.printStackTrace();
}
}
public static Statement getStmt(Connection conn){
Statement stmt=null;
try {
stmt=conn.createStatement();
} catch (SQLException e) {
e.printStackTrace();
}
return stmt;
}
public static void closeStmt(Statement stmt){
try {
stmt.close();
stmt=null;
} catch (SQLException e) {
e.printStackTrace();
}
}
public static PreparedStatement getpStmt(Connection conn,String sql){
PreparedStatement pStmt=null;
try {
pStmt=conn.prepareStatement(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return pStmt;
}
public static void closePstmt(Statement pstmt){
try {
pstmt.close();
pstmt=null;
} catch (SQLException e) {
e.printStackTrace();
}
}
public static ResultSet getRs(Statement stmt,String sql){
ResultSet rs=null;
try {
rs=stmt.executeQuery(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return rs;
}
public static void closeRs(ResultSet rs){
try {
rs.close();
rs=null;
} catch (SQLException e) {
e.printStackTrace();
}
}
}
JAVA课程设计
String name = null; //定义两个属性
int age = 0;
public People(String name,int age) //定义父类的构造函数
{
this.name = name;
this.age = age;
}
}
class Student extends People //子类student继承父类People
{
public Student(String name,int age) //子类的构造函数
{
super(name,age);
}
public void introducing()
{
System.out.println("姓名" + name + "年龄" + age );
}
}
public class StudentTest //主类
{
public static void main(String args)
{
Student st = new Student("张三",20); //创建Studnet类的对象
st.introducing();
}
} //应用价值和功能就是介绍学生的基本情况
java课程设计
很简单
public abstract class Passenger{
private double mileage=0;
public abstact void travel(double d);
public void showResult(double d){
System.out.println("里程为"+mileage+"miles");
}
}
public class GoldPassenger extends Passenger{
public void travel(double d){mileage+=2*d;};
}
public class SilverPassenger extends Passenger{
public void travel(double d){mileage+=1.5*d;};
}
public class NormalPassenger extends Passenger{
public void travel(double d){mileage+=d;};
}
public class Test{
/* 你自己写测试文件吧,FileReader fr=new FileReader("路径");
fr.read***();
然后自己输出结果,很简单的...
*/
}
Java课程设计!急!!!(高分)
我帮你编写了一部分,实现了“输入十个同学的相关信息,并在文本框中显示”(图形界面实现)。
要实现接下去的功能其实也真的不难的,但是真的很麻烦、很浪费时间……我就帮你做到这里了,你自己添加一下代码就可以(或者提高悬赏的话可以考虑考虑啊!哈哈……)代码如下:
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JButton;
import java.awt.Rectangle;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JOptionPane;
public class TongJi extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JButton jButton = null;
private JLabel jLabel = null;
private JScrollPane jScrollPane = null;
private JTextArea jTextArea = null;
/**
* This is the default constructor
*/
public TongJi() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(412, 372);
this.setContentPane(getJContentPane());
this.setTitle("成绩统计");
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
this.setVisible(true);
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(18, 66, 65, 18));
jLabel.setHorizontalAlignment(SwingConstants.CENTER);
jLabel.setText("统计结果:");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJButton(), null);
jContentPane.add(jLabel, null);
jContentPane.add(getJScrollPane(), null);
}
return jContentPane;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setBounds(new Rectangle(18, 16, 86, 28));
jButton.setText("开始统计");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
/////录入成绩信息
String;
for(int i=0;i《10;i++){
String strnum=JOptionPane.showInputDialog(null, "请输入第"+(i+1)+"个学生的学号", "信息录入", JOptionPane.WARNING_MESSAGE);
String strname=JOptionPane.showInputDialog(null, "请输入第"+(i+1)+"个学生的姓名", "信息录入", JOptionPane.WARNING_MESSAGE);
String doublemath=JOptionPane.showInputDialog(null, "请输入第"+(i+1)+"个学生的数学成绩", "信息录入", JOptionPane.WARNING_MESSAGE);
String doubleeng=JOptionPane.showInputDialog(null, "请输入第"+(i+1)+"个学生的英语成绩", "信息录入", JOptionPane.WARNING_MESSAGE);
String doublejava=JOptionPane.showInputDialog(null, "请输入第"+(i+1)+"个学生的JAVA成绩", "信息录入", JOptionPane.WARNING_MESSAGE);
String doublecomp=JOptionPane.showInputDialog(null, "请输入第"+(i+1)+"个学生的计算机成绩", "信息录入", JOptionPane.WARNING_MESSAGE);
mymsg=strnum;
mymsg=strname;
mymsg=doublemath;
mymsg=doubleeng;
mymsg=doublejava;
mymsg=doublecomp;
}
////显示成绩信息
jTextArea.setText("学号 姓名 数学 英语 JAVA 计算机");
for(int i=0;i《10;i++){
jTextArea.setText(jTextArea.getText()+"\r\n");
for(int j=0;j《6;j++){
jTextArea.setText(jTextArea.getText()+mymsg+" ");
}
}
}
});
}
return jButton;
}
/**
* This method initializes jScrollPane
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setBounds(new Rectangle(18, 86, 370, 230));
jScrollPane.setViewportView(getJTextArea());
}
return jScrollPane;
}
/**
* This method initializes jTextArea
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextArea() {
if (jTextArea == null) {
jTextArea = new JTextArea();
jTextArea.setEditable(false);
}
return jTextArea;
}
public static void main(String args){
new TongJi();
}
} // @jve:decl-index=0:visual-constraint="10,10"
效果如下图:
java课程设计(符合要求,别太深奥)
俄罗斯方块没有 有自己做的贪食蛇
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.MouseAdapter;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
public class GameMain extends JFrame implements Runnable {
int runY = 140;
int runX = 120;
int width = 600;
int height = 500;
int W = 10;
int M = 10;
int fangxiang = 0;
int sheshen;
int foodx = 150;
int foody = 150;
int score = 0;
boolean zhuangtai = true;
class UsurKey extends KeyAdapter {
public void keyPressed(KeyEvent e) {
fangxiang = e.getKeyCode();
}
}
class UsurMouse extends MouseAdapter {
public void mouseClicked(MouseEvent e) {
System.out.println(e.getX() + "," + e.getY());
}
}
public GameMain() {
this.setSize(width, height);
this.setVisible(true);
this.addKeyListener(new UsurKey());
this.addMouseListener(new UsurMouse());
new Thread(this).start();
for (int i = 0; i 《 W; i++) {
sheshen = runX + i * W;
sheshen = runY;
}
}
public static void main(String args) {
GameMain g = new GameMain();
}
int count = 0;
public void paint(Graphics g) {
g.fillRect(0, 0, width, height);
g.setColor(new Color(155, 155, 155));
try {
File file1 = new File("img/�0�8�0�8.jpg");
Image image = ImageIO.read(file1);
g.drawImage(image, 150, 100, null);
} catch (IOException e) {
e.printStackTrace();
}
g.drawRect(20, 50, width - 40, height - 100);
g.setColor(new Color(133, 195, 95));
for (int i = 0; i 《 W; i++) {
g.fillRect(sheshen, 10, 10);
}
g.setColor(new Color(255,255,0));
count++;
if(count%2==0){
g.fillRect(foodx, foody, M, M);
}
}
public void updata() {
if (fangxiang == KeyEvent.VK_UP) {
runY = runY - 10;
}
if (fangxiang == KeyEvent.VK_DOWN) {
runY = runY + 10;
}
if (fangxiang == KeyEvent.VK_RIGHT) {
runX = runX + 10;
}
if (fangxiang == KeyEvent.VK_LEFT) {
runX = runX - 10;
}
for (int i = W - 1; i 》 0; i--) {
sheshen;
sheshen;
}
sheshen = runX;
sheshen = runY;
if (sheshen + W 》= 580) {
zhuangtai = false;
}
if (sheshen + W 》= 450) {
zhuangtai = false;
}
Random rand= new Random();
if(sheshen==foody){
W++;
while(true){
foodx = Math.abs((rand.nextInt()%(50 + width-100 -10))/10*10);
foody = Math.abs((rand.nextInt()%(50 + height-100 -10))/10*10);
if(foodx》60&&foody》60){
boolean flag=true;
for(int i=0;i《W;i++){
if(sheshen == foody){
flag=false;
}
}
if(flag){
break;
}
}
}
}
}
public void run() {
while (zhuangtai) {
try {
updata();
this.repaint();
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}

更多文章:
html注册界面表单验证代码(html,js表单的验证,下面代码是想实现当输入6个字符以上用户名通过,少于时报错,但执行不了,求改错)
2025年6月23日 16:15
kali linux基础(变身滚动发行版,Kali Linux 2.0特性知多少)
2026年9月9日 23:45
access如何用查询值给一维数组赋值(如何用vb读取access表中数据,并赋值给另一变量然后进行计算判断 急!)
2025年9月7日 11:00
tp5666路由器(Tplink6500无线路由器怎么设置上网最流畅)
2025年11月18日 15:45
normal tanks第7关密码(请问normal tanks第五关以后的密码是多少诚挚谢谢!!)
2026年9月9日 02:00
编写webservice通讯接口(webservice接口怎么写)
2025年6月7日 15:45
尿常规中conduct是啥意思(尿常规报告单.请大家帮忙解读分析一下.)
2026年3月31日 19:30
简述php脚本程序工作流程(PHP脚本程序主要是由哪几部分组成)
2026年3月4日 15:15
java字符串截取后两位(JAVA截取所有指定字符后面的字符串)
2025年12月5日 23:15
告别php源码(apache 解析一个错误的php文件时,会直接显示php的源码,如何让他不显示源码)
2026年1月28日 18:00














