This src/Title2.gif
is going to be problem, the src
directory will not exist when the program is built.
Toolkit.getDefaultToolkit().createImage(String)
also assumes that the resource is file on the file system, but anything that is contained within the application context (or jar file) is consider an embedded resource and can not be treated as a file.
Instead, you could need to use something more like
image = ImageIO.read(getClass().getResource("/Title2.gif"));
This will return a BufferedImage
but will also throw an IOException
if the image can not be loaded. If the gif is an animated gif you will need to use something more like
image = new ImageIcon(getClass().getResource("/Title2.gif"));
The same will go for your font, but in that case you will likely need to use
Font Confetti = Font.createFont(Font.TRUETYPE_FONT, getClass().getResourceAsStream(
"/Fonts/Confetti.ttf"));
If you're using Eclipse, you may need to move these resources out the the src
directory and in a "resources" directory at the same level as the src
directory in order for them to be included in the final build.