Code:
import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JPanel; public class GameFrame extends JPanel{ public GameFrame() { setFocusable(true); } public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D)g; g2d.drawString("Hello ESFA ", 150, 100); ImageIcon ic = new ImageIcon("C:/New Folder/Player.PNG"); Image i= ic.getImage(); g2d.drawImage(i, 500, 200, null); } }
here the full code
Code:
import javax.swing.JFrame; public class ESFA { public static void main(String[] args) { JFrame frame=new JFrame("ESFA Game"); frame.setSize(800,600); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setResizable(false); frame.add(new GameFrame()); frame.setVisible(true); } } import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JPanel; public class GameFrame extends JPanel{ public GameFrame() { setFocusable(true); } public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D)g; g2d.drawString("Hello ESFA ", 150, 100); ImageIcon ic = new ImageIcon("C:/New Folder/Player.PNG"); Image i= ic.getImage(); g2d.drawImage(i, 500, 200, null); } }
mats0o0o0