ERLEDIGT
NEIN
NEIN
ANTWORTEN
3
3
ZUGRIFFE
909
909
EMPFEHLEN
-
Hi,
habe ein Problem mit einem JFrame. Und zwar will ich nachdem ich mein Program beende (das Frame schliesse) einen kleinen Splashscreen anzeigen. nur leider bleibt er leer (es sollte eigentlich ein Label mit dem übergebenen String angezeigt werden). Genau den selben Screen lass ich mir aber schon am Anfang anzeigen und da klappt alles. An dem liegt es also nicht. Hat da evtl. jmd. eine Ahnung woran es liegen kann?
hier mal der code meiner Testumgebung:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
public static void main(String args[]) { SplashScreen intro = new SplashScreen("Anfang"); intro.showFor(5000); final JFrame test = new JFrame("Test"); test.setVisible(true); test.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { test.dispose(); SplashScreen intro = new SplashScreen("Ende"); intro.showFor(5000); System.exit(0); } }); }
Kai
-
Moin,
Du ziehst Dir mit test.dispose() die Beine selbst weg. Denn test wird damit beseitigt. Dummerweise verschwindet damit auch der WindowListener, in dem nach dem dispose() der SplashScreen angezeit werden soll. Probiers mal mit test.hide() statt test.dispose()
-
Das bringt nix...selbst wenn ich es komplett wegnehme bleibt das frame leer
-
12.10.05 22:35 #4
- Registriert seit
- Jun 2002
- Ort
- Saarbrücken (Saarland)
- Beiträge
- 9.886
- Blog-Einträge
- 29
Hallo!
Schau mal hier:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
/** * */ package de.tutorials; import java.awt.BorderLayout; import java.awt.event.WindowAdapter; import java.util.Timer; import java.util.TimerTask; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; /** * @author Tom * */ public class SimpleSplashExample extends JFrame { public SimpleSplashExample() { super("SimpleSplashExample"); addWindowListener(new WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { dispose(); new SplashScreen("Exiting...", 2000L, true, null); }; }); setSize(640, 480); setVisible(true); } /** * @param args */ public static void main(String[] args) throws Exception { new SplashScreen("Starting...", 5000L, false, SimpleSplashExample.class); } static class SplashScreen extends JFrame { static Timer timer = new Timer(); public SplashScreen(String caption, long duration, final boolean shouldExit, final Class applicationClass) { setUndecorated(true); add(new JLabel(new ImageIcon("c:/Sonnenuntergang.jpg")), BorderLayout.CENTER); add(new JLabel(caption), BorderLayout.SOUTH); pack(); setVisible(true); setLocationRelativeTo(null); timer.schedule(new TimerTask() { public void run() { setVisible(false); dispose(); if (shouldExit) { System.exit(0); } if (applicationClass != null) { try { applicationClass.newInstance(); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } } } }, duration); } } }
gruß TomJava rocks!
How to become a good Java Programmer?
Does IT in Java and .Net
The only valid measurement of code quality: WTFs / minute
Blog
Xing
Twitter
Ähnliche Themen
-
ScrollPane bleibt leer
Von dodlhuat im Forum Swing, Java2D/3D, SWT, JFaceAntworten: 3Letzter Beitrag: 03.08.09, 19:48 -
DataGridView bleibt leer?
Von ParadiseCity im Forum .NET Windows FormsAntworten: 0Letzter Beitrag: 08.11.07, 13:28 -
Formularemail bleibt leer
Von schiwunja im Forum PHPAntworten: 6Letzter Beitrag: 27.10.07, 19:48 -
Array ist und bleibt leer
Von Braver Willy im Forum PHPAntworten: 5Letzter Beitrag: 17.07.07, 19:28 -
JTable bleibt leer :(
Von Davtorik im Forum Swing, Java2D/3D, SWT, JFaceAntworten: 4Letzter Beitrag: 13.05.06, 22:10





Zitieren

Login





