Questions tagged [jcomponent]

JComponent is the base class for all Java Swing components except top-level containers.

JComponent is the base class for all Java Swing components except top-level containers which descend from Window instead.

To use a component that inherits from JComponent, you must place the component in a containment hierarchy whose root is a top-level Swing container. Top-level Swing containers -- such as JFrame, JDialog, and JApplet -- are specialized components that provide a place for other Swing components to paint themselves.

768 questions
-3
votes
4 answers

How do I display a BufferedImage in a JComponent?

I have been trying this for hours now. I have a class that extends JComponent, and in its paintComponent I am trying to draw an image, but I am not being able to. Here is my code: public class Main extends JComponent{ public static void…
-3
votes
2 answers

Simple Pong Game Keyboard Input

(The game is not complete yet but nevertheless) Using the keyboard input does not do anything, I believe this is due to KeyListener not being defined properly. Here is my code: mainClass: import java.awt.Color; import java.awt.Graphics; import…
Tom
  • 9
-4
votes
2 answers

using JPanel in chess in java

in making a chess game in java using JPanel,is there a method that returns whether the container contains anything? for example by defining an array like this: JPanel [8][8] we want to check if there is a man in the square[i][j], so that we can…
Elaheh
  • 1
  • 2
1 2 3
51
52