Answer the question
In order to leave comments, you need to log in
JComponent not drawing line?
it is necessary that the orange line is displayed from the JComponent method, but it is not displayed, I watched tutorials on YouTube, it displays for types, I don’t have it, what could be the reason that I’m missing?
package GameArcher.GameView;
import java.awt.*;
import javax.swing.*;
import GameArcher.GameEngine.GameEngine;
import GameArcher.Constants.IConstants;
/**
Данный класс рисует человка, стрелу, мишень.
*/
public class GameView extends JComponent {
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.ORANGE);
g.drawLine(0, 0, 700, 700);
}
public void createFrame() {
// Создание окна
JFrame frame = new JFrame("GameArcher");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setPreferredSize(new Dimension(1080, 720));
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
GameView gameView = new GameView();
gameView.createFrame();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question