⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 miukono91.java

📁 查看效果之前。连接一下数据源。数据源名称为"miukou"。后效果会更佳。 解压密码www.21codes.com,一定升级到最新版[WinRAR3.5]才能正常解压
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import java.sql.*;
import java.awt.geom.*;

class miukoNO91 extends Frame implements ActionListener
{
	private Image img;
	private Label g1[],g2[],g3[],g4,g5,g6,g7;
	private Button b,b1,b2,b3,b4;
	Toolkit tool;
	private TextField t1,t2;
	private Connection con;//定义一个能连接数据库的变量
	private Statement stmt; 
	private ResultSet rs;
	private String s1[],s2[],s3[];
	int n=0,f=0,w=65,y=1,o=0,u=0;
	String str1,str2,str3,str4,str5;
	miukoNO91()
	{
		super("~随心~我的单词库");

		 tool = getToolkit();
				img  = tool.getImage("Bingo.jpg");
		
		Color	c1 = new Color(255,135,230);
		Color	c2 = new Color(255,235,130);
		setBackground(c1);

		setSize(510,405);
		setIconImage(img);
		setVisible(true);
		setLayout(null);

		setLocation(250,100);

		t1=new TextField();
		t1.setBounds(212,360,100,20);
		t1.setBackground(new Color(0,128,193));
		t1.setVisible(true);
		add(t1);

		t2=new TextField();
		t2.setBounds(112,381,288,20);
		t2.setBackground(new Color(0,128,193));
		t2.setVisible(true);
		add(t2);

		g7=new Label("输入要转向的页数:");
		g7.setBounds(112,360,99,20);
		g7.setBackground(Color.orange);
		add(g7);

		b=new Button("转向指定页");
		b.setBounds(313,360,86,20);
		b.setBackground(new Color(0,128,193));
		b.setForeground(Color.orange);
		add(b);

		g4=new Label("*******单词*******");
		g4.setBounds(10,30,99,20);
		g4.setBackground(c2);
		g4.setForeground(Color.pink);
		add(g4);

		g5=new Label("                  *******单词意思*******                ");
		g5.setBounds(111,30,250,20);
		g5.setBackground(c2);
		g5.setForeground(Color.pink);
		add(g5);

		g6=new Label("**单词积累时间**");
		g6.setBounds(363,30,138,20);
		g6.setBackground(c2);
		g6.setForeground(Color.pink);
		add(g6);

		b1=new Button("上一页");
		b1.setBounds(10,360,100,20);
		b1.setBackground(new Color(0,128,193));
		b1.setForeground(Color.orange);
		add(b1);

		b2=new Button("下一页");
		b2.setBounds(10,381,100,20);
		b2.setBackground(new Color(0,128,193));
		b2.setForeground(Color.orange);
		add(b2);

		b3=new Button("单词积累");
		b3.setBounds(400,360,100,20);
		b3.setBackground(new Color(0,128,193));
		b3.setForeground(Color.orange);
		add(b3);

		b4=new Button("返回主页");
		b4.setBounds(400,381,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);
		b.addActionListener(this);

		try
		{
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			con = DriverManager.getConnection("jdbc:odbc:miukou");
			stmt = con.createStatement();
			rs = stmt.executeQuery("SELECT * FROM miuko8");
			try
			{
				while(rs.next())
				{
					n++;
				}
				rs.close();
			}
			catch(Exception e9){}
		}
		catch(Exception eeee){}

			g1=new Label[n];
			g2=new Label[n];
			g3=new Label[n];
			s1=new String[n];
			s2=new String[n];
			s3=new String[n];
			try
			{
				rs = stmt.executeQuery("SELECT * FROM miuko8");
				while(rs.next())
				{
					s1[f]=rs.getString("word");
						str1=rs.getString("mean1");
						str2=rs.getString("mean2");
						str3=rs.getString("mean3");
						str4=rs.getString("mean4");
						str5=rs.getString("mean5");
						if(str2.equals("-"))
						{
						s2[f]=str1;
						}
						else if(str3.equals("-"))
						{
						s2[f]=str1+","+str2;
						}
						else if(str4.equals("-"))
						{
						s2[f]=str1+","+str2+","+str3;
						}
						else if(str5.equals("-"))
						{
						s2[f]=str1+","+str2+","+str3+","+str4;
						}
						else if(!str5.equals("-"))
						{
						s2[f]=str1+","+str2+","+str3+","+str4+","+str5;
						}
					s3[f]=rs.getString("mean6");
					f++;
				}
				rs.close();
			}
				catch(Exception e9){}
		for(int i=0;i<n;i++)
		{
			g1[i]=new Label();
			g2[i]=new Label();
			g3[i]=new Label();
			g1[i].setBounds(10,w,99,20);
			g2[i].setBounds(111,w,250,20);
			g3[i].setBounds(363,w,138,20);
			if(i%3==0)
			{
				g1[i].setBackground(Color.green);
				g2[i].setBackground(Color.orange);
				g3[i].setBackground(new Color(0,128,193));
			}
			if(i%3==2)
			{
				g2[i].setBackground(Color.green);
				g3[i].setBackground(Color.orange);
				g1[i].setBackground(new Color(0,128,193));
			}
			if(i%3==1)
			{
				g3[i].setBackground(Color.green);
				g1[i].setBackground(Color.orange);
				g2[i].setBackground(new Color(0,128,193));
			}
			g1[i].setText(s1[i]);
			g2[i].setText(s2[i]);
			g3[i].setText(s3[i]);
			if(i<14)
			{
			g1[i].setVisible(true);
			g2[i].setVisible(true);
			g3[i].setVisible(true);
			}
			else
			{
			g1[i].setVisible(false);
			g2[i].setVisible(false);
			g3[i].setVisible(false);
			}
			if(w>330)
			{
				w=65;
				y+=1;
			}
			else
				w+=21;
			add(g1[i]);
			add(g2[i]);
			add(g3[i]);
		}
		t2.setText("您积累的单词共有"+y+"页");
	}
	public void paint(Graphics g)
	{
		Graphics2D gg=(Graphics2D)g;
		GradientPaint grd2=new GradientPaint(50,45,Color.white,100,55,new Color(0,128,193),true);
		gg.setPaint(grd2);
		Rectangle2D obj3=new Rectangle2D.Double(10,51,490,13);
		gg.fill(obj3);
	}
	public void actionPerformed(ActionEvent e)
	{
		if(e.getSource()==b)
		{
			int h=0;
				h=Integer.parseInt(t1.getText().trim())-1;
				for(int i=0;i<n;i++)
				{
					g1[i].setVisible(false);
					g2[i].setVisible(false);
					g3[i].setVisible(false);
				}
				for(int i=h*14;i<h*14+14;i++)
				{
					g1[i].setVisible(true);
					g2[i].setVisible(true);
					g3[i].setVisible(true);
				}
		}
		if(e.getSource()==b1)
		{
			for(int i=0;i<n;i++)
			{
				g1[i].setVisible(false);
				g2[i].setVisible(false);
				g3[i].setVisible(false);
			}
			if(u<=0)
				u=0;
			else
				u-=1;
			if(u==0)
			{
				for(int i=0;i<14;i++)
				{
					g1[i].setVisible(true);
					g2[i].setVisible(true);
					g3[i].setVisible(true);
				}
			}
			else
			{
				for(int i=u*14;i<u*14+14;i++)
				{
					g1[i].setVisible(true);
					g2[i].setVisible(true);
					g3[i].setVisible(true);
				}
			}
			o=u;
		}
		if(e.getSource()==b2)
		{
			for(int i=0;i<n;i++)
			{
				g1[i].setVisible(false);
				g2[i].setVisible(false);
				g3[i].setVisible(false);
			}
			if(o>=y-1)
				o=y-1;
			else
				o+=1;
			if(o==y-1)
			{
				for(int i=o*14;i<n;i++)
				{
					g1[i].setVisible(true);
					g2[i].setVisible(true);
					g3[i].setVisible(true);
				}
			}
			else
			{
				for(int i=o*14;i<o*14+14;i++)
				{
					g1[i].setVisible(true);
					g2[i].setVisible(true);
					g3[i].setVisible(true);
				}
			}
			u=o;
		}
		if(e.getSource()==b4)
		{
			miuko0 f = new miuko0();
			f.setVisible(true);
			setVisible(false);
		}
		if(e.getSource()==b3)
		{
			miukoNO9 f = new miukoNO9();
			f.setVisible(true);
			setVisible(false);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -