gpt4 book ai didi

java - 需要从启动屏幕重定向到网页

转载 作者:行者123 更新时间:2023-12-02 07:25:31 25 4
gpt4 key购买 nike

我需要从启动屏幕重定向到网页,我该怎么做,请用代码建议我。我的闪屏代码是:

import java.awt.*;
import javax.swing.*;

public class SplashScreen extends JWindow {

private int duration;

public SplashScreen(int d) {
duration = d;
}

// A simple little method to show a title screen in the center
// of the screen for the amount of time given in the constructor
public void showSplash() {

JPanel content = (JPanel)getContentPane();
content.setBackground(Color.white);

// Set the window's bounds, centering the window
int width = 450;
int height =115;
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
int x = (screen.width-width)/2;
int y = (screen.height-height)/2;
setBounds(x,y,width,height);

// Build the splash screen
JLabel label = new JLabel(new ImageIcon("java-tip.gif"));
JLabel copyrt = new JLabel
("Welcome to the Application", JLabel.CENTER);
copyrt.setFont(new Font("Sans-Serif", Font.BOLD, 12));
content.add(label, BorderLayout.CENTER);
content.add(copyrt, BorderLayout.SOUTH);
Color oraRed = new Color(156, 20, 20, 255);
content.setBorder(BorderFactory.createLineBorder(oraRed, 10));

// Display it
setVisible(true);

// Wait a little while, maybe while loading resources
try { Thread.sleep(duration); } catch (Exception e) {}

setVisible(false);

}

public void showSplashAndExit() {

showSplash();
System.exit(0);

}

public static void main(String[] args) {

// Throw a nice little title page up on the screen first
SplashScreen splash = new SplashScreen(50000);

// Normally, we'd call splash.showSplash() and get on
// with the program. But, since this is only a test...
splash.showSplashAndExit();

}
}

提前致谢

最佳答案

showSplash(); 调用之后编写代码

 java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
desktop.browse(new URI("www.yoursite.com"));

这将打开您的网站的默认浏览器。

关于java - 需要从启动屏幕重定向到网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13629567/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com