Ich wollte etwas ausprobieren, deshalb habe ich ein neues Projekt gestartet. Aus einem mir nicht erklärlichen Grund wird die paintComponent nie aufgerufen. Ich bin schon seit Stunden daran.
Bitte um Hilfe
MfG
Duco
Bitte um Hilfe
Java:
import javax.swing.JFrame;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author DuCo
*/
public class frame extends JFrame {
public static void main(String[] args) {
frame gameframe = new frame("Yu-Gi-Oh!");
gameframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
gameframe.setSize(1365,765);
gameframe.setLayout(null);
gameframe.setVisible(true);
gameframe.add(new yugioh());
}
public frame(String title) {
super(title);
}
}
Java:
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import javax.swing.Timer;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author DuCo
*/
public class yugioh extends JPanel implements ActionListener{
Timer time;
public yugioh(){
this.setLayout(null);
setFocusable(true);
time = new Timer(5,this);
time.start();
}
@Override
public void actionPerformed(ActionEvent ae) {
repaint();
}
@Override
public void paintComponent(Graphics g){
super.paintComponent(g);
Graphics2D f2 =(Graphics2D)g;
f2.drawString("AAAAAAAAAAAAAAAAAAA",5,5);
}
}
MfG
Duco
Zuletzt bearbeitet von einem Moderator: