• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question about splach screen + Jframe

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hola, I need your help guys.
First: How to make a (Splash screen).
Second: I have a button, when pressed, it must show a new Frame, but when I closed this frame, it also closed the main frame.
I have put the following code in the second frame:
public class About extends JFrame {
// some code
this.setTitle("About me");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
/********/
So, what is the problem?
 
Timmy Marks
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2: Try using DISPOSE_ON_CLOSE instead of EXIT_ON_CLOSE
 
Timmy Marks
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In regards to Splash screens:
looking around on the web, I found this:
Java Tip 104
Hope it helps!
Tim
 
Brian Pipa
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a free, open-source Spalsh screen you can use here:
http://filenabber.com/free-java-classes/
Javadocs for it are here:
http://filenabber.com/free-java-classes/splash/javadocs
Enjoy!
Brian
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much guys, your replies were very nice.
but I face a new problem.
I have tried Brian's Splash class, but when I tried to launch, no picture is displayed ( I have tried many extensions ico, bmp, jpg)
What can I do?
 
Brian Pipa
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's probably not finding your image. Are you getting any errors? Where is your image? in a folder on disk? in a .jar? and what did you pass in to the constructor telling it where the image is?
If the image is in your .jar, you can give it something like:
new Splash("images/splash.jpg", 3, true);
This will load the image splash.jpg from within a jar on the classpath for 3 seconds and it will allow you to click it to close it.
if the image is located outside of the .jar, let's say in the same dir, but that dir is not on the classpath, you can do this:
new Splash("c:\\myapp\\splash.jpg", 3, true);
or better yet, pass in something with the paths not hard-coded using something like
String dir = System.getProperty("user.dir");
new Splash(dir+"splash.jpg", 3, true);
Give me more details and I'll help you get it working. It will work with .jpg, .gif, or.png files - it won't do .bmp files
Brian
 
Brian Pipa
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

causes the entire application to exit. From the JFrame Javadocs:

You probably want to use one of the other parameters or don't call setDefaultCloseOperation at all since the default is to hide the frame which is probably what you want.
Brian
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Brain.
It now work, I was using :
new Splash("F:" + File.separator + "Photos" + "snow.gif");
I think I have missed File.separator after Photos.
Thank Brian, you are the best.
Best of luck.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!