java程式啟動畫面
阿新 • • 發佈:2019-01-07
java 程式碼/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package test;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.SplashScreen;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;
import javax.swing.JFrame;
/**
*
* @author root
*/
public class SplashTest {
public static void main(String[] args) {
new Thread() {
public void run() {
try {
SplashScreen splash = SplashScreen.getSplashScreen();
Graphics2D g = splash.createGraphics();
g.setColor(Color.RED);
g.drawString("測試文字", 10, 30);
splash.update();
Thread.sleep(1000);
g.setComposite(AlphaComposite.Clear);
g.fillRect(0, 0, (int) splash.getSize().getWidth(), (int) splash.getSize().getHeight());
splash.setImageURL(SplashTest.class.getResource("/test/SplashScreen.png"));
int x = 100, y = 100;
String author = "1 2 3 4 5";
g.setFont(new Font("TimesRoman", Font.PLAIN, 30));
g.setPaintMode();
for (int i = 0; i < 5; i++) {
g.setColor(new Color(50, 50, 0));
g.drawString(author, x + i, y + i - 1);
g.setColor(new Color(10, 10, 0));
g.drawString(author, x + i - 1, y + i);
}
g.setColor(Color.red);
g.drawString(author, x + 5, y + 5);
splash.update();
Thread.sleep(1000);
} catch (Exception ex) {
Logger.getLogger(SplashTest.class.getName()).log(Level.SEVERE, null, ex);
}
}
}.start();
try {
Thread.sleep(3000);
} catch (Exception e) {
e.printStackTrace();
}
JFrame jf = new JFrame("test");
JButton jb = new JButton("click");
jf.add(jb);
jf.setPreferredSize(new Dimension(320, 240));
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.pack();
jf.setVisible(true);
}
}
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package test;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.SplashScreen;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;
import javax.swing.JFrame;
/**
*
* @author root
*/
public class SplashTest {
public static void main(String[] args) {
new Thread() {
public void run() {
try {
SplashScreen splash = SplashScreen.getSplashScreen();
Graphics2D g = splash.createGraphics();
g.setColor(Color.RED);
g.drawString("測試文字", 10, 30);
splash.update();
Thread.sleep(1000);
g.setComposite(AlphaComposite.Clear);
g.fillRect(0, 0, (int) splash.getSize().getWidth(), (int) splash.getSize().getHeight());
splash.setImageURL(SplashTest.class.getResource("/test/SplashScreen.png"));
int x = 100, y = 100;
String author = "1 2 3 4 5";
g.setFont(new Font("TimesRoman", Font.PLAIN, 30));
g.setPaintMode();
for (int i = 0; i < 5; i++) {
g.setColor(new Color(50, 50, 0));
g.drawString(author, x + i, y + i - 1);
g.setColor(new Color(10, 10, 0));
g.drawString(author, x + i - 1, y + i);
}
g.setColor(Color.red);
g.drawString(author, x + 5, y + 5);
splash.update();
Thread.sleep(1000);
} catch (Exception ex) {
Logger.getLogger(SplashTest.class.getName()).log(Level.SEVERE, null, ex);
}
}
}.start();
try {
Thread.sleep(3000);
} catch (Exception e) {
e.printStackTrace();
}
JFrame jf = new JFrame("test");
JButton jb = new JButton("click");
jf.add(jb);
jf.setPreferredSize(new Dimension(320, 240));
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.pack();
jf.setVisible(true);
}
}