一,采用的是model2三层模型开发
一个为主界面,index ,一个为登录界面UserLogin
1、
package com.mol.view;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import javax.swing.JPanel;
import javax.swing.JWindow;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class Index extends JWindow implements Runnable{
//定义为成员变量,将应用类型嵌入到Window窗口中!
paint p;
public static void main(String[] args) {
try {
// 将当前窗体外观设置为所在操作系统的外观
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
Index index = new Index();
Thread t = new Thread(index);
t.start();
}
//构造方法用来初始化变量和方法
public Index() {
// 创建P
p = new paint();
this.add(p);
this.setSize(400, 250);
// 确定Jwindow初始位置
this.setLocationRelativeTo(null);
this.setVisible(true);
}
//线程方法,跳出登录页面
public void run() {
while(true) {
try {
Thread.sleep(29*500);
} catch (Exception e) {
e.printStackTrace();
}
this.dispose();
//跳转到登录页面
new UserLogin();
break;
}
}
}
//定义一个闪屏类方法
class paint extends JPanel implements Runnable{// 可以自动刷新Panel
Thread t;
int x = 10;
int i = 0, j = 40, u = 10;
String gg[] = { “系”, “统”, “正”, “在”, “加”, “载”, “请”, “稍”, “侯” };
int k = 0, tt = 0;
String shi[] = { “满”, “汉”, “楼”, “融”, “满”, “汉”, “精”, “华”, “做”, “天”, “下”,
“美”, “味”, “招”, “八”, “方”, “食”, “客”, “结”, “四”, “海”, “良”, “朋”,
“满”, “汉”, “楼”, “程”, “序”, “演”, “示” };
Font f = new Font(“隶书”, Font.PLAIN, 18);
boolean ifok = true;
int width = 180;
int height = 0;
int dian = 0;
paint() {
t = new Thread(this);
t.start();
}
public void run() {
while (true) {
if (x <= 380);
repaint();
try {
Thread.sleep(70);
i++;// i=0
j = j - 6;// j=40