Click to See Complete Forum and Search --> : Move from 1.6_11 to 1.6_13 broke my app


Khoram
April 23rd, 2009, 04:13 PM
I have an app that was working fine in 1.6_11, that now does not work in _13. I used a code snippet I saw somewhere to show a splashscreen image on startup, that is then replaced with the actual drawing canvas after a short thread sleep. In _13, however, the image used for the splashscreen stays drawn on top of everything else that is added afterwards.

public class BattleHex extends JFrame {
WrapBattleHex wbh;
private static final String MAP_DIR = "JCreator LE/MyProjects/BattleHex/maps/";
JButton selectHexButton, placeUnitButton, moveUnitButton;

public BattleHex()
{
super("BattleHex");
Container c = getContentPane();
c.setLayout( new BorderLayout() );
wbh = new WrapBattleHex(); // panel holding the 3D canvas
c.add(new JButton(new ImageIcon("BattleHexLogo v01.png")), BorderLayout.CENTER);

setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
pack();
setResizable(true);
setVisible(true);

// show splash sceeen title logo for 1 second, then replace with game canvas
try { Thread.sleep(1000); }
catch (Exception e) { e.printStackTrace(); }

c.add(wbh, BorderLayout.CENTER);
pack();
} // end of BattleHex()


public static void main(String[] args) {
new BattleHex();
}

} // end of BattleHex class


Any ideas?

dlorde
April 24th, 2009, 07:15 AM
Why not just remove the splash button (button:confused:) from the content pane, or hide it? This is simple to do if you keep a reference to it:...
JButton splash = new JButton(new ImageIcon("BattleHexLogo v01.png"));
... // wait for timeout
c.remove(splash);
// or
splash.setVisible(false);
...Alternatively, wouldn't it be simpler to use the SplashScreen (http://java.sun.com/javase/6/docs/api/java/awt/SplashScreen.html) class provided in the SDK?

Making the simple complicated is commonplace; making the complicated simple, awesomely simple, that's creativity...
C. Mingus

Khoram
April 24th, 2009, 09:03 AM
Thanks for the reply. I wasn't using SplashScreen because I can't get it to work with my IDE. I was using the splash "button" because it was just some code I got from a book or website I think.

dlorde
April 24th, 2009, 11:42 AM
I wasn't using SplashScreen because I can't get it to work with my IDE. :confused: what has the IDE got to do with it?

Computer Science is a science of abstraction -creating the right model for a problem and devising the appropriate mechanizable techniques to solve it...
A. Aho and J. Ullman

postmortem
April 24th, 2009, 07:45 PM
there's -splash: command line option for Java 1.6.xx

http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/splashscreen/