//这是主程序的main函数
public static void main(String args[])
{
splash myLogo = new splash(); //for creting an object
myLogo.setVisible(true); //show the logo
frame = new frameApp(); //for running the progam
myLogo.setVisible(false); //hide the logo
myLogo = null; // no longer use it
}//这是展示窗口的文件内容
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Toolkit;import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JWindow;public class splash extends JWindow
{
splash()
{
JPanel panel = new JPanel()
{
//for painting the component
public void paintComponent(Graphics g)
{
//for getting the image
ImageIcon img = new ImageIcon(ClassLoader.getSystemResource ("frameApp/images/Logo.JPG"));
//for drawing the image
g.drawImage(img.getImage(), 0, 0, null);
super.paintComponent(g);
}
};
//for setting the border
panel.setOpaque(false);
//for setting the panel in the contentPane
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setBackground(Color.BLUE);
//for setting the ContentPane to true
setContentPane(panel);
setSize(350, 250);
Dimension frameSize = getSize();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
setVisible(true);
}
}
public static void main(String args[])
{
splash myLogo = new splash(); //for creting an object
myLogo.setVisible(true); //show the logo
frame = new frameApp(); //for running the progam
myLogo.setVisible(false); //hide the logo
myLogo = null; // no longer use it
}//这是展示窗口的文件内容
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Toolkit;import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JWindow;public class splash extends JWindow
{
splash()
{
JPanel panel = new JPanel()
{
//for painting the component
public void paintComponent(Graphics g)
{
//for getting the image
ImageIcon img = new ImageIcon(ClassLoader.getSystemResource ("frameApp/images/Logo.JPG"));
//for drawing the image
g.drawImage(img.getImage(), 0, 0, null);
super.paintComponent(g);
}
};
//for setting the border
panel.setOpaque(false);
//for setting the panel in the contentPane
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setBackground(Color.BLUE);
//for setting the ContentPane to true
setContentPane(panel);
setSize(350, 250);
Dimension frameSize = getSize();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
setVisible(true);
}
}
解决方案 »
- java调用存储过程问题
- 关于安装apache和php的一个问题
- 新手 java TextField内容相对路径存入.txt文件中 在以字符形式读取出来.....
- JAVA 怎样直连Sql server 2005?
- HTTP Status 404 - Servlet action is not available
- Jtree中如何在一个节点上存放两个值.一个是文本,一个是值.文本显示出来,而键不显示.
- 求一条sql语句???急。。。。
- 这个语句是干嘛的?
- 喜闻Bruce Eckel要出TIJ4了,来散分以庆贺。
- KeyboardInput 类怎么用???
- switch 语句的一个问题
- 怎么同时编译多个包里面的.java
{
public SplashWindow(String filename, int waitTime)
{
//super(f);
JLabel l = new JLabel(new ImageIcon(filename));
ImageIcon img = new ImageIcon(ClassLoader.getSystemResource ("123.gif"));
;
getContentPane().add(l, BorderLayout.CENTER);
pack();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension labelSize = l.getPreferredSize();
setLocation(
screenSize.width/2 - (labelSize.width/2),
screenSize.height/2 - (labelSize.height/2));
addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
setVisible(false);
dispose();
Frame_2 fra2=new Frame_2();
}
});
final int pause = waitTime;
final Runnable closerRunner = new Runnable()
{
public void run()
{
setVisible(false);
dispose();
}
};
Runnable waitRunner = new Runnable()
{
public void run()
{
try
{
Thread.sleep(pause);
SwingUtilities.invokeAndWait(closerRunner);
} catch (Exception e) {
e.printStackTrace();
}
}
};
this.setVisible(true);
Thread splashThread = new Thread(waitRunner, "SplashThread");
splashThread.start();
System.out.println("---------");
}
}