-2

Is it possible to read the content of a JPanel?

In my situation, I've got a main JPanel that I called container, and 3 other JPanels inside it: p1, p2 and p3.
I've also created a class that extends JPanel for a little virtual keyboard (26 buttons) and this implements ActionListener.

The p1 is to display the title of the game, p2 is the virtual keyboard and p3 should display the value of the button I clicked on.

My class VirtualKeyboard has a constructor that accepts an object of type JPanel (to get the container and hopefully its contents).

Many thanks for your answers.

Michaël
  • 3,679
  • 7
  • 39
  • 64
onizukaek
  • 1,082
  • 1
  • 14
  • 38

1 Answers1

0

check out JPanel#getComponent(int) to access the members that have been added to a Container(JPanel is implementing Container).

Simulant
  • 19,190
  • 8
  • 63
  • 98