In my main class, I call a class that, upon instantiation, should display its JFrame window. However, that is not the case. I've had this class work before, when I ran the project through Eclipse. Now, running it through command line, it does not work :(.
From my main method:
PaintTitleMovie q = new PaintTitleMovie();
The Jframe class:
public class PaintTitleMovie extends JPanel implements MouseListener {
Image image;
Font ConfettiFinal = new Font("Analog", 1, 20); // fail safe
static JFrame frame = new JFrame();
public PaintTitleMovie() {
image = Toolkit.getDefaultToolkit().createImage("src/Title2.gif");
try {
Font Confetti = Font.createFont(Font.TRUETYPE_FONT, new File(
"src/Fonts/Confetti.ttf"));
ConfettiFinal = Confetti.deriveFont(1, 50);
} catch (FontFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
addMouseListener(this);
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (image != null) {
g.drawImage(image, 0, 0, this);
}
// draw exit button
g.setColor(Color.BLUE);
g.fillRect(990, 50, 210, 100);
g.setColor(Color.BLACK);
g.fillRect(1000, 60, 190, 80);
g.setColor(Color.WHITE);
g.setFont(ConfettiFinal);
g.drawString("Continue", 1000, 120);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
frame.add(new PaintTitleMovie());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1200, 800);
frame.setUndecorated(true);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
SongTitle s = new SongTitle();
}
});
}
@Override
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
int x = arg0.getX();
int y = arg0.getY();
if (x >= 990 && y >= 50 && y <= 150) {
this.setVisible(false);
frame.dispose();
PaintMenu load = new PaintMenu(); // load paint menu
}
}
}