这个你研究一下,很简单 /* * @(#)LogoMainApp.java 1.0 03/01/11 * * You can modify the template of this file in the * directory ..\JCreator\Templates\Template_1\Project_Name.java * * You can also create your own project template by making a new * folder in the directory ..\JCreator\Template\. Use the other * templates as examples. * */ //package logomainapp;import java.awt.*; import java.awt.event.*; import javax.swing.*;class LogoMainApp extends JFrame {
public LogoMainApp() { addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); System.exit(0); } }); } public static void main(String args[]) { //Logo lg = new Logo("Logo.gif"); //lg.run(); //try{ // Thread.currentThread().sleep(5000); //}catch(Exception e){} LogoMainApp mainFrame = new LogoMainApp(); mainFrame.setSize(400, 400); mainFrame.setTitle("LogoMainApp"); //mainFrame.setIconImage(Toolkit.getDefaultToolkit().createImage("Logo.gif")); //lg.setNotVisible(); mainFrame.setVisible(true); } }import javax.swing.*; import java.lang.Runnable; import java.awt.*;public class Logo extends JWindow implements Runnable{ String filename;//Logo 图象文件的文件名; public Logo(String name){ filename = name; } public void run(){ ImageIcon ig = new ImageIcon(filename); JButton btn = new JButton(ig);//将图片给JButton显示; getContentPane().add(btn);//将显示图片的btn加到JPanel里; Toolkit kit = Toolkit.getDefaultToolkit(); Dimension screenSize = kit.getScreenSize();//获得屏幕大小; setLocation(screenSize.width/2,screenSize.height/2);//将LOGO窗口显示在屏幕宽,高各1/4处 setSize(ig.getIconWidth(),ig.getIconHeight());//将LOGO窗口大小设成图象大小; toFront();//将logo窗口显示为最前面的窗口; setVisible(true);//显示窗口; } public void setNotVisible(){ setVisible(false);//不显示该窗口 } }
/*
* @(#)LogoMainApp.java 1.0 03/01/11
*
* You can modify the template of this file in the
* directory ..\JCreator\Templates\Template_1\Project_Name.java
*
* You can also create your own project template by making a new
* folder in the directory ..\JCreator\Template\. Use the other
* templates as examples.
*
*/
//package logomainapp;import java.awt.*;
import java.awt.event.*;
import javax.swing.*;class LogoMainApp extends JFrame {
public LogoMainApp() {
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
System.exit(0);
}
});
} public static void main(String args[]) {
//Logo lg = new Logo("Logo.gif");
//lg.run();
//try{
// Thread.currentThread().sleep(5000);
//}catch(Exception e){}
LogoMainApp mainFrame = new LogoMainApp();
mainFrame.setSize(400, 400);
mainFrame.setTitle("LogoMainApp");
//mainFrame.setIconImage(Toolkit.getDefaultToolkit().createImage("Logo.gif"));
//lg.setNotVisible();
mainFrame.setVisible(true);
}
}import javax.swing.*;
import java.lang.Runnable;
import java.awt.*;public class Logo extends JWindow implements Runnable{
String filename;//Logo 图象文件的文件名;
public Logo(String name){
filename = name;
}
public void run(){
ImageIcon ig = new ImageIcon(filename);
JButton btn = new JButton(ig);//将图片给JButton显示;
getContentPane().add(btn);//将显示图片的btn加到JPanel里;
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();//获得屏幕大小;
setLocation(screenSize.width/2,screenSize.height/2);//将LOGO窗口显示在屏幕宽,高各1/4处
setSize(ig.getIconWidth(),ig.getIconHeight());//将LOGO窗口大小设成图象大小;
toFront();//将logo窗口显示为最前面的窗口;
setVisible(true);//显示窗口;
}
public void setNotVisible(){
setVisible(false);//不显示该窗口
}
}