Can't put the image on the screen??
For some reason, when I run this code, it won't put the Start.png image on the screen! it puts the 2 Strings on the screen, but not the image..
Any help?
P.S, ignore the unneeded imports at the beginning.
Code:
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
public class TheWindow extends JFrame{
private StockMarket myPanel;
Color customColor = new Color(100,149,237);
private boolean loaded;
private Image sb;
public TheWindow(){
super("ProjectN (Un-named game)");
myPanel = new StockMarket();
myPanel.setBackground(customColor);
add(myPanel, BorderLayout.CENTER);
}
public void loadPics(){
sb = new ImageIcon(getClass().getResource("Start.png")).getImage();
loaded = true;
repaint();
}
public void paint(Graphics g) {
if(g instanceof Graphics2D){
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
}
super.paint(g);
g.drawString("This is the current state of the game", 60, 100);
g.drawString("Things will be added soon, I'm currently working on the basic code", 60, 130);
g.drawImage(sb, 10, 10, null);
}
}