import java.awt.*;
import java.awt.event.*;
import javax.swing.*;public class splash extends JFrame
{
Toolkit kit = Toolkit.getDefaultToolkit();
JWindow jw = new JWindow();
JLabel la = new JLabel(new ImageIcon("a.jpg"));
public splash()
{
la.setBorder(BorderFactory.createRaisedBevelBorder());
jw.getContentPane().add(la,BorderLayout.CENTER);
centerWindow();
jw.show();
jw.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
jw.dispose();
System.exit(0);
}
});
}
private void centerWindow()
{
Dimension sc = kit.getScreenSize();
Dimension ls = la.getPreferredSize();
int law = ls.width;
int lah = ls.height;
jw.setLocation(sc.width/2 - (law/2),sc.height/2 - (lah/2));
jw.pack(); }
public static void main(String args[])
{
JFrame fr = new splash();
}
}
import java.awt.event.*;
import javax.swing.*;public class splash extends JFrame
{
Toolkit kit = Toolkit.getDefaultToolkit();
JWindow jw = new JWindow();
JLabel la = new JLabel(new ImageIcon("a.jpg"));
public splash()
{
la.setBorder(BorderFactory.createRaisedBevelBorder());
jw.getContentPane().add(la,BorderLayout.CENTER);
centerWindow();
jw.show();
jw.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
jw.dispose();
System.exit(0);
}
});
}
private void centerWindow()
{
Dimension sc = kit.getScreenSize();
Dimension ls = la.getPreferredSize();
int law = ls.width;
int lah = ls.height;
jw.setLocation(sc.width/2 - (law/2),sc.height/2 - (lah/2));
jw.pack(); }
public static void main(String args[])
{
JFrame fr = new splash();
}
}
解决方案 »
- 如何对JScrollPane里的输入进行正则表达式验证,不符合则不让输入
- 关于Iterator的问题
- 空指针错误,大家帮忙找错
- 求助!哪位大虾会用izpack?
- **关于enum的俩个问题**about enum ,i have two questions! **enumについて、二つの問題があります**enum에 대해서, 두 개의 문제가 있습니다**
- JAVA BAR问题
- 一个密码的算法,结果不正常,麻烦大家给看看吧。
- 谁知道如何,将JAVA文件,加到自己建的包里,并调用啊?
- readline()怎么只能读一半啊?
- 汉字输出到文件
- 简单问题,考考你们,啊啊
- 紧急求助! 关于LoadRunner7.0的使用方法
// centers the dialog within the screen [1.1]
// (put that in the Frame/Dialog class)
public void centerScreen() {
Dimension dim = getToolkit().getScreenSize();
Rectangle abounds = getBounds();
setLocation((dim.width - abounds.width) / 2,
(dim.height - abounds.height) / 2);
super.setVsible(true);
requestFocus();
}
// centers the dialog within the parent container [1.1]
// (put that in the Dialog class)
public void centerParent () {
int x;
int y; // Find out our parent
Container myParent = getParent();
Point topLeft = myParent.getLocationOnScreen();
Dimension parentSize = myParent.getSize(); Dimension mySize = getSize(); if (parentSize.width > mySize.width)
x = ((parentSize.width - mySize.width)/2) + topLeft.x;
else
x = topLeft.x;
if (parentSize.height > mySize.height)
y = ((parentSize.height - mySize.height)/2) + topLeft.y;
else
y = topLeft.y;
setLocation (x, y);
super.setVsible(true);
requestFocus();
}