java splashwindow
来源:互联网 发布:pptv聚力网络电视官网 编辑:程序博客网 时间:2024/06/08 13:28
package util;
import java.awt.*;
import javax.swing.*;
import main.CMainApp;
/**
* A class used to display a splashwindow on the screen while the program
* is starting up. A message can be displayed on top of the image
* in the lower right corner.
*/
final public class PBSUISplashWindow
extends JWindow {
/**
* Constant handle to the glass pane that handles drawing text
* on top of the splash screen.
*/
private static final SplashGlassPane GLASS_PANE =
new SplashGlassPane();
/**
* Creates a new SplashWindow, setting its location, size, etc.
*/
public PBSUISplashWindow(String SplashImageFileName) {
ImageIcon splashIcon = new ImageIcon(SplashImageFileName);
Image image = splashIcon.getImage();
Dimension size = new Dimension(image.getWidth(null) + 2,
image.getHeight(null) + 2);
this.setSize(size);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setLocation( (screenSize.width - size.width) / 2,
(screenSize.height - size.height) / 2);
JLabel splashLabel = new JLabel(splashIcon);
splashLabel.setBorder(BorderFactory.createLineBorder(Color.black, 1));
this.setGlassPane(GLASS_PANE);
this.getContentPane().add(splashLabel, BorderLayout.CENTER);
this.pack();
this.setVisible(true);
GLASS_PANE.setVisible(true);
}
/**
* Sets the loading status text to display in the splash
* screen window.
*
* @param text the text to display
*/
public static void setStatusText(String text) {
GLASS_PANE.setText(text);
}
/**
* A private glass for the glass pane that handles drawing
* status text above the background image.
*/
private static final class SplashGlassPane
extends JPanel {
/**
* Handle for the panel that contains the text.
*/
private static JPanel TEXT_PANEL = new JPanel();
/**
* The label for the text.
*/
private static JLabel TEXT_LABEL = new JLabel();
/**
* Constructor lays out the panels and label, sets them to
* be transparent, etc.
*/
private SplashGlassPane() {
this.setOpaque(false);
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
this.add(Box.createVerticalGlue());
TEXT_PANEL.setOpaque(false);
TEXT_PANEL.setLayout(new BoxLayout(TEXT_PANEL, BoxLayout.X_AXIS));
TEXT_PANEL.add(Box.createHorizontalGlue());
// make sure label doesn't clip....
TEXT_LABEL.setMinimumSize(new Dimension(40, 3));
TEXT_PANEL.add(TEXT_LABEL);
//TEXT_PANEL.add(a horizontal separator component);
this.add(TEXT_PANEL);
//this.add(a vertical separator component);
}
/**
* Sets the text to display for the status area.
*
* @param text the text to display
*/
private static void setText(String text) {
FontMetrics fm = TEXT_LABEL.getFontMetrics(TEXT_LABEL.getFont());
TEXT_LABEL.setPreferredSize(new Dimension(fm.stringWidth(text),
fm.getHeight()));
TEXT_LABEL.setText(text);
}
}
public static void main(String[] args) {
PBSUISplashWindow window = new PBSUISplashWindow("D://PMM2005//PMMGUI//res//splash.jpg");
window.setStatusText("SplashWindow Test ");
try {
Thread.sleep(5000);
}
catch (InterruptedException ex) {
}
window.dispose();
window = null;
}
}
- java splashwindow
- java
- JAVA
- JAVA
- JAVA
- java
- Java
- Java
- JAVA:
- java
- java
- java
- java
- Java
- java
- java
- java
- JAVA?
- Visual Studio 2008开发新特性系列课程(8):VSTO in Visual Studio 2008
- Visual Studio 2008开发新特性系列课程(9):开发 SharePoint工作流
- 把自己的经历先放到这里
- Visual Studio 2008开发新特性系列课程(10):使用Visual Studio 2008和.NET Compact Framework 3.5创建Mobile应用程序
- Visual Studio 2008开发新特性系列课程(11):VS2008-WPF(Cider), ClickOnce
- java splashwindow
- Visual Studio 2008开发新特性系列课程(12):团队协作开发利器——VSTS2008新特性展示
- RFC (Remote Function Call)
- 《信息系统监理》之变更控制
- Visual Studio 2008开发新特性系列课程(13):团队协作开发利器——VSTS2008如何提高团队开发效率
- VB ADO连接DataGrid
- Hello, Weka
- Oracle中存储过程
- 呼转类型