public class WaitDialog extends javax.swing.JDialog implements Runnable{
Wait wa = new Wait();
/** Creates new form WaitDialog */
public WaitDialog() {
this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
this.setResizable(false);
this.setSize(250, 80);
Dimension d = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); //Bildschirmgröße ermitteln
double hight = d.getHeight(); //Höhe rausziehen
int y = (int)((hight/2)-(this.getSize().getHeight()/2)); //Dialog muss in die Mitte des Bildschirms positioniert werden
double width = d.getWidth(); //Breite rausziehen
int x = (int)((width/2)-(this.getSize().getWidth()/2));
this.setLocation(x,y); //Positionieren
this.setUndecorated(true);
this.setLayout(new GridLayout(1,1));
this.add(wa);
}
public void run() {
this.setVisible(true);
}
private class Wait extends javax.swing.JPanel {
public BufferedImage image;
private int w;
private int h;
private javax.swing.JLabel jLabel1;
/** Creates new form Wait */
public Wait() {
//Bild einlesen
try{
URL pic_url = this.getClass().getClassLoader().getResource("spulenberechnung/Bilder/load.gif");
image = ImageIO.read(pic_url);
}
catch(IOException ex){
System.out.println( ex.getMessage() );
}
w = image.getWidth(null);
h = image.getHeight(null);
jLabel1 = new javax.swing.JLabel();
setPreferredSize(new java.awt.Dimension(200, 50));
jLabel1.setFont(new java.awt.Font("Arial", 0, 12));
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(image,0,0,null);
}
}
}