L
luaijun
Unregistered / Unconfirmed
GUEST, unregistred user!
是Jbuilder7下的一程序.编译可通过,但运行时窗体显示不出来?不知为什么,谢谢
代码如下:
package welcomtojbuilder6;
import javax.swing.*;
import java.awt.*;
import com.borland.jbcl.layout.*;
import java.awt.event.*;
/**
* <p>Title: 使用JBuilder制作欢迎屏幕</p>
* <p>Description: 本程序利用Jbuilder显示一幅图片作为欢迎屏幕</p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
public class WelcomeWindow extends JWindow {
private JLabel jLabel1 = new JLabel();
private BorderLayout borderLayout1 = new BorderLayout();
public WelcomeWindow() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
WelcomeWindow welcomeWindow1 = new WelcomeWindow();
welcomeWindow1.show() ;
//setVisible(true);
}
private void jbInit() throws Exception {
jLabel1.setIcon(new ImageIcon(new java.net.URL("file:///C:/Mydo
cuments/桌面.jpg"))) ;
this.pack();
//此函数用于将JWindow大小设置为适应于jLabel
this.getContentPane().setLayout(borderLayout1);
this.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(MouseEvent e) {
this_mousePressed(e);
}
});
this.getContentPane().add(jLabel1, BorderLayout.CENTER);
//得到屏幕大小的Dimension,与jLable 的大小比较后,将窗体设置在屏幕的正中央
Dimension screenSize=Toolkit.getDefaultToolkit() .getScreenSize() ;
Dimension labelSize=jLabel1.getPreferredSize();
//setLocation(screenSize.width/2-labelSize.width/2,screenSize.height/2-labelSize.height/2);
setLocation(300,400);
setVisible(true);//使窗体可见
}
void this_mousePressed(MouseEvent e) {
setVisible(false);
System.exit(0);
}
}
代码如下:
package welcomtojbuilder6;
import javax.swing.*;
import java.awt.*;
import com.borland.jbcl.layout.*;
import java.awt.event.*;
/**
* <p>Title: 使用JBuilder制作欢迎屏幕</p>
* <p>Description: 本程序利用Jbuilder显示一幅图片作为欢迎屏幕</p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
public class WelcomeWindow extends JWindow {
private JLabel jLabel1 = new JLabel();
private BorderLayout borderLayout1 = new BorderLayout();
public WelcomeWindow() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
WelcomeWindow welcomeWindow1 = new WelcomeWindow();
welcomeWindow1.show() ;
//setVisible(true);
}
private void jbInit() throws Exception {
jLabel1.setIcon(new ImageIcon(new java.net.URL("file:///C:/Mydo
cuments/桌面.jpg"))) ;
this.pack();
//此函数用于将JWindow大小设置为适应于jLabel
this.getContentPane().setLayout(borderLayout1);
this.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(MouseEvent e) {
this_mousePressed(e);
}
});
this.getContentPane().add(jLabel1, BorderLayout.CENTER);
//得到屏幕大小的Dimension,与jLable 的大小比较后,将窗体设置在屏幕的正中央
Dimension screenSize=Toolkit.getDefaultToolkit() .getScreenSize() ;
Dimension labelSize=jLabel1.getPreferredSize();
//setLocation(screenSize.width/2-labelSize.width/2,screenSize.height/2-labelSize.height/2);
setLocation(300,400);
setVisible(true);//使窗体可见
}
void this_mousePressed(MouseEvent e) {
setVisible(false);
System.exit(0);
}
}