i have an error with my code saying:
at javax.swing.JComponent.paintComponent(JComponent.java:783)
at com.game.screen.screen.PaintComponent(screen.java:29)
at com.game.screen.screen.GameScreen(screen.java:39)
at com.game.gamecore.Core.StartGame(Core.java:15)
at com.game.gamecore.Core.main(Core.java:6)
my code: com.game.screen
package com.game.screen;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Ellipse2D;
import javax.swing.*;
public class screen extends JPanel implements ActionListener {
/**
*
*/
ActionListener AL = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
}
};
Timer timer = new Timer(5, AL);
double x = 0, y = 0, velY = 0,velX = 0;
public void PaintComponent(Graphics pixel){
super.paintComponent(pixel);
Graphics2D g2 = (Graphics2D) pixel;
Ellipse2D circle = new Ellipse2D.Double(x,y,40,40);
g2.fill(circle);
timer.start();
}
public void GameScreen(){
JFrame GameScreen = new JFrame("THE GAME");
GameScreen.setSize(600, 600);
PaintComponent(null);
GameScreen.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
}
com.game.gameCore.Core
package com.game.gamecore;
public class Core {
public static void main(String[] args) {
// new Menu();
new Core().StartGame();
}
public void StartGame(){
String GameState = "idle";
if(GameState=="idle"){
GameState="Running";
new com.game.screen.screen().GameScreen();
} else if(GameState=="Running") {
//enter process kill code here
}
}
}
how do i call my PaintComponent(grahpics G) code?
ineedto type something random else this thing wont let me post it... i will just keep typing untill it stops giving me error...