希望大家可以帮我看看这个程序
请问以下这个程序图片为什么出不来,没有报任何错。就是图片出不来。
import javax.swing.*;
import java.awt.*;
import java.net.*;
public class JSplashWindow extends JWindow implements Runnable {
Thread splashThread=null;
boolean bool = true;
JPanel splash = null;
URL url = null;
public JSplashWindow() {
splash = new JPanel(new BorderLayout());
url = getClass().getResource("/images/winter.jpg");
setContentPane(splash);
Dimension screen = getToolkit().getScreenSize();
pack();
setLocation((screen.width - getSize().width) / 2,(screen.height - getSize().height) / 2);
}
public void start(){
this.toFront();
splashThread=new Thread(this);
splashThread.start();
}
public void run(){
JLabel label = new JLabel(new ImageIcon(url));
try {
setVisible(true);
while(bool) {
if(url != null){
splash.add(label,BorderLayout.CENTER);
}
Thread.sleep(500);
splash.remove(label);
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
Thread.sleep(500);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
static void showFrame(String title){
JFrame frame = new JFrame(title);
frame.setSize(400,300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
}
public static void main(String[] args) {
showFrame("Demo splash window");
JSplashWindow splash = new JSplashWindow();
splash.start();
}
}
import javax.swing.*;
import java.awt.*;
import java.net.*;
public class JSplashWindow extends JWindow implements Runnable {
Thread splashThread=null;
boolean bool = true;
JPanel splash = null;
URL url = null;
public JSplashWindow() {
splash = new JPanel(new BorderLayout());
url = getClass().getResource("/images/winter.jpg");
setContentPane(splash);
Dimension screen = getToolkit().getScreenSize();
pack();
setLocation((screen.width - getSize().width) / 2,(screen.height - getSize().height) / 2);
}
public void start(){
this.toFront();
splashThread=new Thread(this);
splashThread.start();
}
public void run(){
JLabel label = new JLabel(new ImageIcon(url));
try {
setVisible(true);
while(bool) {
if(url != null){
splash.add(label,BorderLayout.CENTER);
}
Thread.sleep(500);
splash.remove(label);
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
Thread.sleep(500);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
static void showFrame(String title){
JFrame frame = new JFrame(title);
frame.setSize(400,300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
}
public static void main(String[] args) {
showFrame("Demo splash window");
JSplashWindow splash = new JSplashWindow();
splash.start();
}
}
...全文
相关推荐
一个简单的单片机呼吸灯程序
这个程序简单,能让你的led呼吸起来!很好用,希望能帮大家啊
阿姨帮小程序.zip
而随着小程序市场的不断扩大,越来越多的开发者投入到小程序的开发中,希望能够创造出既实用又受欢迎的产品。其中,“阿姨帮小程序”就是一款以家政服务为主要内容的精品小程序。
安卓微信相关相关-踩了无数个微信支付的坑终于做成了传一个自己生成参数的demo希望有所帮住只要修改里面的参数就可以植入工程使用前请仔细阅读使用说明.rar
踩了无数个微信支付的坑,终于做成了,传一个自己生成参数的demo,希望有所帮住,只要修改里面的参数就可以植入工程,使用前请仔细阅读使用说明.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,
c++语言程序
需要单片机430程序的大家可以看看,这里是液晶显示的一些程序,希望可以帮你
假设Laughing Sir希望全部采用公里计量,你可以帮他写出转换程序吗?已知1英里等于1.609公里。
Laughing Sir在某次案件调查中需要研究一些地图,但是其中一些地图使用公里为单位,而另一些使用英里为单位。假设Laughing Sir希望全部采用公里计量,你可以帮他写出转换程序吗?已知1英里等于1.609公里。以公里表示的距离,结果保留2位小数。


Java SE
