I am trying to use a splash screen with my program and the splash screen shows but then nothing else happens. I am running the JAR file, that has the main class that creates an object(LoadingScreen) which creates a splash screen, through a bat file which goes through a jre and starts the splash screen with my gif. Batch file contents:
cd Desktop
cd YES (folder this stuff is in)
jre\bin\java.exe -splash:ahsSplash.gif YES.jar*
Here is the LoadingScreen class with the splash screen creator
import java.awt.*;
public class LoadingScreen
{
public LoadingScreen() throws NullPointerException, IllegalStateException, InterruptedException
{
final SplashScreen splash = SplashScreen.getSplashScreen();
Graphics2D g = splash.createGraphics();
for(int i=0; i<150; i++)
{
renderSplashFrame(g, i);
splash.update();
Thread.sleep(50);
}
splash.close();
}
static void renderSplashFrame(Graphics2D g, int frame)
{
final String[] comps = {"Getting bork.exe", "Training doggie", "Finding woof", "Loading treats", "Locating poopbag", "Sniffing Cats","Locating DogPride", "Locating AHSPride", "Deleting Bite.virus ;]", "Smelling food", "Stealing food", "Walking outside"};
g.setComposite(AlphaComposite.Clear);
g.fillRect(100,135,200,40);
g.setPaintMode();
g.setColor(Color.WHITE);
g.drawString(comps[(frame/8)%comps.length]+"...", 100, 145);
}
}
Here is the main method
public static void main(String[] args) throws NullPointerException, IllegalStateException, ClassNotFoundException, InstantiationException, IllegalAccessException, IOException, GeneralSecurityException, BadLocationException, InterruptedException, UnsupportedLookAndFeelException, UnsupportedAudioFileException, LineUnavailableException
{
System.out.println(System.getProperty("java.security.properties"));//null
new LoadingScreen();
SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
{
try
{
createValues();
}
catch (Exception e)
{
ifError(e.toString());
}
LoginScreen lS = new LoginScreen();
while(!lS.getUserAuth())
{
continue;
}
lS.setVisible(false);
userLoginData userData = lS.uD;
if(userData.getAdmin() == false)
{
try
{
new StudentScreen(userData.user, userData.grade);
}
catch (Exception e)
{
ifError(e.toString());
}
}
else
{
try
{
new AdminScreen();
}
catch (Exception e)
{
ifError(e.toString());
}
}
}
});
}
I tried many things from different arguments in the batch file, running the other methods in the loadingscreen class after the splash screen gets closed, using a manifest file to create the jar, creating the jar through multiple IDEs and I tried to make the other screens come first (because they had buttons that would call the rest of the code) and then the splash screen but I would get a security exception. I also tried to put all of the LoadingScreen class stuff inside my main method in the main class but even then it would stop after the splash screen.
THANKS FOR YOUR HELP!