Originally Posted by
CallMeCrazySam
Problem: I want to be able to listen to a button click (left and right) from Panel in TopPanel
Possible solutions to my problem:
1. Figure out how to listen to the left and right click from Panel in TopPanel
2. Get rid of TopPanel and have Panel contain the "label" from top and the array of buttons. My problem here was I did not know how draw on the panel that contains the buttons apart from the panel that contains it. I tried this earlier, but it would clear the numbers that are supposed to lie behind the buttons after they were drawn (I think). Here's the paintComponent() method I tried from before.
1. TopPanel extends JFrame implements MouseListener, MouseMotionListener, MouseWheelListener .....listen to suit your needs
2.You can work it with or without the JPanel class, but a JPanel is not a top level container and must be contained within one. (ie your TopPanel is a JFrame, which is one of the top level containers)
You can add listeners to the JPanel, or the JFrame, or both to suit your needs
Try to keep the logic separate from the GUI. The "driver" class(es) should contain the logic and control the flow and respond to the user. The GUI class(es) should display the results of the driver(s) in pretty colors and provide the interface to interact with the user. The GUI should do nothing more than report user interaction to the driver(s) and continue waiting for user inputs, while the drivers do what was requested in the background