public WaitingDialog() { super(MapView.parentFrame); setTitle("waiting..."); pack(); setModal(true); setResizable(false);
initPanel(); } 下面的那个PACK();去掉试试。
splash myLogo = new splash(); //for creting an object myLogo.setVisible(true); //show the logo frame = new frameApp(); //for running the progam myLogo.setVisible(false); //hide the logo myLogo = null; // no longer use it///////////// import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Toolkit;import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JPanel; import javax.swing.JWindow;public class splash extends JWindow { splash() { JPanel panel = new JPanel() { //for painting the component public void paintComponent(Graphics g) { //for getting the image ImageIcon img = new ImageIcon(ClassLoader.getSystemResource ("frameApp/images/Logo.JPG")); //for drawing the image g.drawImage(img.getImage(), 0, 0, null); super.paintComponent(g); } };
//for setting the border panel.setOpaque(false); //for setting the panel in the contentPane panel.setBorder(BorderFactory.createEtchedBorder()); panel.setBackground(Color.BLUE); //for setting the ContentPane to true setContentPane(panel);
super(MapView.parentFrame);
setTitle("waiting...");
pack();
setModal(true);
setResizable(false);
initPanel();
}
下面的那个PACK();去掉试试。
myLogo.setVisible(true); //show the logo
frame = new frameApp(); //for running the progam
myLogo.setVisible(false); //hide the logo
myLogo = null; // no longer use it/////////////
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Toolkit;import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JWindow;public class splash extends JWindow
{
splash()
{
JPanel panel = new JPanel()
{
//for painting the component
public void paintComponent(Graphics g)
{
//for getting the image
ImageIcon img = new ImageIcon(ClassLoader.getSystemResource ("frameApp/images/Logo.JPG"));
//for drawing the image
g.drawImage(img.getImage(), 0, 0, null);
super.paintComponent(g);
}
};
//for setting the border
panel.setOpaque(false);
//for setting the panel in the contentPane
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setBackground(Color.BLUE);
//for setting the ContentPane to true
setContentPane(panel);
setSize(350, 250);
Dimension frameSize = getSize();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
setVisible(true);
}
}
public class WaitingDialog extends JDialog implements Runnable {
...
private Thread waitThread = null;
public start() {
if (waitThread == null) {
waitThread = new Thread(this, "waitdialog");
waitThread.start();
}
}public void run() {
...
}
...
}