Splash screen in netbeans 6.0

Reply

Join Date: Nov 2006
Posts: 29
Reputation: toomuchfreetime is an unknown quantity at this point 
Solved Threads: 1
toomuchfreetime's Avatar
toomuchfreetime toomuchfreetime is offline Offline
Light Poster

Splash screen in netbeans 6.0

 
0
  #1
Apr 24th, 2008
Hey

I'm trying to get a splash screen going for my application but having a problem in finding the image once the splash screen is called it returns a null.

I'm trying to use the java standard 6 way where the splash screen is displayed before the jvm is started and is displayed until a swing or awt container is displayed.


  1. if (splash == null) {
  2. System.out.println("SplashScreen.getSplashScreen() returned null");
  3. return;
  4. }


it fails at this point and returns null and continues on with the rest of the program as normal.



full code is as follows


  1. package tree;
  2.  
  3.  
  4. import java.awt.*;
  5. import java.awt.event.*;
  6.  
  7. public class splashScreen extends Frame implements ActionListener {
  8. static void renderSplashFrame(Graphics2D g, int frame) {
  9. final String[] comps = {"foo", "bar", "baz"};
  10. g.setComposite(AlphaComposite.Clear);
  11. g.fillRect(130,250,280,40);
  12. g.setPaintMode();
  13. g.setColor(Color.BLACK);
  14. g.drawString("Loading "+comps[(frame/5)%3]+"...", 130, 260);
  15. g.fillRect(130,270,(frame*10)%280,20);
  16. }
  17. public splashScreen() {
  18. super("SplashScreen demo");
  19. setSize(500, 300);
  20. setLayout(new BorderLayout());
  21. Menu m1 = new Menu("File");
  22. MenuItem mi1 = new MenuItem("Exit");
  23. m1.add(mi1);
  24. mi1.addActionListener(this);
  25.  
  26. MenuBar mb = new MenuBar();
  27. setMenuBar(mb);
  28. mb.add(m1);
  29. final SplashScreen splash = SplashScreen.getSplashScreen();
  30.  
  31. if (splash == null) {
  32. System.out.println("SplashScreen.getSplashScreen() returned null");
  33. return;
  34. }
  35. Graphics2D g = (Graphics2D)splash.createGraphics();
  36. if (g == null) {
  37. System.out.println("g is null");
  38. return;
  39. }
  40. for(int i=0; i<100; i++) {
  41. renderSplashFrame(g, i);
  42. splash.update();
  43. try {
  44. Thread.sleep(200);
  45. }
  46. catch(InterruptedException e) {
  47. }
  48. }
  49. splash.close();
  50. setVisible(true);
  51. toFront();
  52. }
  53. public void actionPerformed(ActionEvent ae) {
  54. System.exit(0);
  55. }
  56. public static void main (String args[]) {
  57. splashScreen test = new splashScreen();
  58. }
  59. }

The manifest code is

  1. Manifest-Version: 1.0
  2. Main-Class: tree/splashScreen
  3. SplashScreen-Image: tree/splash.png

not sure if i have this right so this is my file format :
  1. myTree -project name
  2. scr
  3. HelpPanells -package
  4. tree -package
  5. splashScreen.java
  6. splash.png
  7. tree.exercises -package
  8. tree.exercises.pictures -package
  9. tree.icon -package

this is just a basic representation of the project hope it helps you to help me as i'm stumped at this point

Thanks
Last edited by toomuchfreetime; Apr 24th, 2008 at 1:53 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 19
Reputation: Artmann is an unknown quantity at this point 
Solved Threads: 0
Artmann Artmann is offline Offline
Newbie Poster

Re: Splash screen in netbeans 6.0

 
0
  #2
Apr 25th, 2008
This site seems to contain some useful information.

http://java.sun.com/developer/techni.../splashscreen/
-Signed Artmann
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC