📄 miukono9.java
字号:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.io.*;
import java.awt.datatransfer.*;//用于打开文件和保存文件的一个类
import java.applet.Applet;
import java.awt.geom.*;
import sun.audio.*;
import java.sql.*;
import java.util.Date;
class miukoNO9 extends Frame implements ActionListener
{
private Image img,i1,i2;
static TextField t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14;
private Label g1,g2,g3,g4,g5,g6,g7,g8,g9,g10,g11,g12,g13,g14,g15,g16;
private Button b1,b2,b3,b4;
Toolkit tool;
private Connection con;//定义一个能连接数据库的变量
private Statement stmt;
private ResultSet rs;
int n=0,h1=0;
Date da;
String str1,str2,str3,str4,str5,str6,str7;
String sw;
int x1=0,x2=0,x3=0,x4=0,x5=0,x6=0;
miukoNO9()
{
super("~NO.9~~单词积累");
tool = getToolkit();
img = tool.getImage("Bingo.jpg");
i1 = tool.getImage("Box2.jpg");
i2 = tool.getImage("Box3.jpg");
Color c1 = new Color(155,235,30);
setBackground(c1);
da=new Date();
sw=da.toLocaleString();
setSize(520,405);
setIconImage(img);
setVisible(true);
setLayout(null);
setLocation(250,100);
t0=new TextField();
t0.setBackground(new Color(32,203,243));
t0.setBounds(0,30,520,20);
t0.setForeground(Color.green);
add(t0);
t1=new TextField("");
t1.setBackground(Color.orange);
t1.setBounds(65,120,150,20);
t1.setForeground(Color.green);
add(t1);
t2=new TextField("");
t2.setBackground(Color.orange);
t2.setBounds(65,155,150,20);
t2.setForeground(Color.green);
add(t2);
t3=new TextField("");
t3.setBackground(Color.orange);
t3.setBounds(65,190,150,20);
t3.setForeground(Color.green);
add(t3);
t4=new TextField("");
t4.setBackground(Color.orange);
t4.setBounds(65,225,150,20);
t4.setForeground(Color.green);
add(t4);
t5=new TextField("");
t5.setBackground(Color.orange);
t5.setBounds(65,260,150,20);
t5.setForeground(Color.green);
add(t5);
t6=new TextField("");
t6.setBackground(Color.orange);
t6.setBounds(65,295,150,20);
t6.setForeground(Color.green);
add(t6);
t7=new TextField();
t7.setBackground(Color.orange);
t7.setBounds(326,120,150,20);
t7.setForeground(Color.green);
add(t7);
t8=new TextField();
t8.setBackground(Color.orange);
t8.setBounds(326,155,150,20);
t8.setForeground(Color.green);
add(t8);
t9=new TextField();
t9.setBackground(Color.orange);
t9.setBounds(326,190,150,20);
t9.setForeground(Color.green);
add(t9);
t10=new TextField();
t10.setBackground(Color.orange);
t10.setBounds(326,225,150,20);
t10.setForeground(Color.green);
add(t10);
t11=new TextField();
t11.setBackground(Color.orange);
t11.setBounds(326,260,150,20);
t11.setForeground(Color.green);
add(t11);
t12=new TextField();
t12.setBackground(Color.orange);
t12.setBounds(326,295,150,20);
t12.setForeground(Color.green);
add(t12);
b1=new Button("查看我的积累库");
b1.setBounds(50,335,100,20);
b1.setBackground(new Color(0,128,193));
b1.setForeground(Color.orange);
add(b1);
b2=new Button("提交积累单词");
b2.setBounds(151,335,100,20);
b2.setBackground(new Color(0,128,193));
b2.setForeground(Color.orange);
add(b2);
b3=new Button("返回到主页");
b3.setBounds(310,335,100,20);
b3.setBackground(new Color(0,128,193));
b3.setForeground(Color.orange);
add(b3);
b4=new Button("退出该软件");
b4.setBounds(411,335,100,20);
b4.setBackground(new Color(0,128,193));
b4.setForeground(Color.orange);
add(b4);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:miukou");
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT * FROM miuko8");
while(rs.next())
{
h1++;
}
rs.close();
}
catch(Exception eeee){}
t0.setText("你已经积累了"+h1+"个单词!");
}
public void paint(Graphics g)
{
g.drawImage(i1,0,51,260,350,this);
g.drawImage(i2,260,51,260,350,this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b2)
{
if(t1.getText().trim().equals("")&&t7.getText().trim().equals(""))
{
ok o=new ok("提交单词前,请填写单词");
o.setBackground(new Color(0,128,193));
o.b1.setBackground(new Color(0,128,193));
o.setLocation(390,260);
o.setVisible(true);
}
else if(!t1.getText().trim().equals("")&&t7.getText().trim().equals(""))
{
if(t2.getText().trim().equals(""))
{
ok o=new ok("单词一必需有一个意思");
o.setBackground(new Color(0,128,193));
o.b1.setBackground(new Color(0,128,193));
o.setLocation(390,260);
o.setVisible(true);
}
else
{
try
{
str1="'"+t1.getText().trim()+"'";
str2="'"+t2.getText().trim()+"'";
if(t3.getText().trim().equals(""))
str3="'"+"-"+"'";
else
str3="'"+t3.getText().trim()+"'";
if(t4.getText().trim().equals(""))
str4="'"+"-"+"'";
else
str4="'"+t4.getText().trim()+"'";
if(t5.getText().trim().equals(""))
str5="'"+"-"+"'";
else
str5="'"+t5.getText().trim()+"'";
if(t6.getText().trim().equals(""))
str6="'"+"-"+"'";
else
str6="'"+t6.getText().trim()+"'";
String strInc = "INSERT INTO miuko8(word,mean1,mean2,mean3,mean4,mean5,mean6) Values("
+str1+","+str2+","+str3+","+str4+","+str5+","+str6+",'"+sw+"')";
stmt.executeUpdate(strInc);
ok o=new ok("单词一积累成功");
o.setLocation(390,260);
o.setVisible(true);
}
catch(Exception eeee)
{
ok o=new ok("单词一积累失败");
o.setLocation(390,260);
o.setVisible(true);
}
}
}
else if(!t7.getText().trim().equals("")&&t1.getText().trim().equals(""))
{
if(t8.getText().trim().equals(""))
{
ok o=new ok("单词二必需有一个意思");
o.setBackground(new Color(0,128,193));
o.b1.setBackground(new Color(0,128,193));
o.setLocation(390,260);
o.setVisible(true);
}
else
{
try
{
str1="'"+t7.getText().trim()+"'";
str2="'"+t8.getText().trim()+"'";
if(t9.getText().trim().equals(""))
str3="'"+"-"+"'";
else
str3="'"+t9.getText().trim()+"'";
if(t10.getText().trim().equals(""))
str4="'"+"-"+"'";
else
str4="'"+t10.getText().trim()+"'";
if(t11.getText().trim().equals(""))
str5="'"+"-"+"'";
else
str5="'"+t11.getText().trim()+"'";
if(t12.getText().trim().equals(""))
str6="'"+"-"+"'";
else
str6="'"+t12.getText().trim()+"'";
String strInc = "INSERT INTO miuko8(word,mean1,mean2,mean3,mean4,mean5,mean6) Values("
+str1+","+str2+","+str3+","+str4+","+str5+","+str6+",'"+sw+"')";
stmt.executeUpdate(strInc);
ok o=new ok("单词二积累成功");
o.setLocation(390,260);
o.setVisible(true);
}
catch(Exception eeee)
{
ok o=new ok("单词二积累失败");
o.setLocation(390,260);
o.setVisible(true);
}
}
}
else if(!t7.getText().trim().equals("")&&!t1.getText().trim().equals(""))
{
if(t8.getText().trim().equals(""))
{
ok o=new ok("单词二必需有一个意思");
o.setBackground(new Color(0,128,193));
o.b1.setBackground(new Color(0,128,193));
o.setLocation(390,260);
o.setVisible(true);
}
if(t2.getText().trim().equals(""))
{
ok o=new ok("单词一必需有一个意思");
o.setBackground(new Color(0,128,193));
o.b1.setBackground(new Color(0,128,193));
o.setLocation(390,260);
o.setVisible(true);
}
if( !t2.getText().trim().equals("")&&!t8.getText().trim().equals(""))
{
try
{
str1="'"+t7.getText().trim()+"'";
str2="'"+t8.getText().trim()+"'";
if(t9.getText().trim().equals(""))
str3="'"+"-"+"'";
else
str3="'"+t9.getText().trim()+"'";
if(t10.getText().trim().equals(""))
str4="'"+"-"+"'";
else
str4="'"+t10.getText().trim()+"'";
if(t11.getText().trim().equals(""))
str5="'"+"-"+"'";
else
str5="'"+t11.getText().trim()+"'";
if(t12.getText().trim().equals(""))
str6="'"+"-"+"'";
else
str6="'"+t12.getText().trim()+"'";
String strInc = "INSERT INTO miuko8(word,mean1,mean2,mean3,mean4,mean5,mean6) Values("
+str1+","+str2+","+str3+","+str4+","+str5+","+str6+",'"+sw+"')";
str1="'"+t1.getText().trim()+"'";
str2="'"+t2.getText().trim()+"'";
if(t3.getText().trim().equals(""))
str3="'"+"-"+"'";
else
str3="'"+t3.getText().trim()+"'";
if(t4.getText().trim().equals(""))
str4="'"+"-"+"'";
else
str4="'"+t4.getText().trim()+"'";
if(t5.getText().trim().equals(""))
str5="'"+"-"+"'";
else
str5="'"+t5.getText().trim()+"'";
if(t6.getText().trim().equals(""))
str6="'"+"-"+"'";
else
str6="'"+t6.getText().trim()+"'";
String strInc1 = "INSERT INTO miuko8(word,mean1,mean2,mean3,mean4,mean5,mean6) Values("
+str1+","+str2+","+str3+","+str4+","+str5+","+str6+",'"+sw+"')";
stmt.executeUpdate(strInc1);
ok o=new ok("单词一、二积累成功");
o.setLocation(390,260);
o.setVisible(true);
}
catch(Exception eeee)
{
ok o=new ok("单词一、二积累失败");
o.setLocation(390,260);
o.setVisible(true);
}
}
}
}
if(e.getSource()==b1)
{
miukoNO91 f = new miukoNO91();
f.setVisible(true);
setVisible(false);
}
if(e.getSource()==b3)
{
miuko0 f = new miuko0();
f.setVisible(true);
setVisible(false);
}
if(e.getSource()==b4)
{
miukook y=new miukook("确定要推出吗");
y.setBackground(new Color(0,128,193));
y.b1.setBackground(new Color(0,128,193));
y.b2.setBackground(new Color(0,128,193));
y.setLocation(380,280);
y.setVisible(true);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -