943,693 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 13714
  • Java RSS
Apr 24th, 2008
0

Splash screen in netbeans 6.0

Expand Post »
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.


java Syntax (Toggle Plain Text)
  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


java Syntax (Toggle Plain Text)
  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

java Syntax (Toggle Plain Text)
  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 :
Java Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 1
Light Poster
toomuchfreetime is offline Offline
29 posts
since Nov 2006
Apr 25th, 2008
0

Re: Splash screen in netbeans 6.0

This site seems to contain some useful information.

http://java.sun.com/developer/techni.../splashscreen/
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Artmann is offline Offline
19 posts
since Nov 2007
Aug 31st, 2010
0

please help!!!

sir the program i have attached with my reply moves the tray left/right depending on the key pressed(left/right).and now i want a ball to come and hit this tray and then bounces back.please suggest me something
Last edited by Nick Evan; Aug 31st, 2010 at 10:00 am. Reason: Removed tex-tags
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rahul4/69 is offline Offline
1 posts
since Aug 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Thread and Class comunication
Next Thread in Java Forum Timeline: Changing from hard code to file read





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC