There's a custom class extending JPanel, named CustomJPanel
, that has a JTable in it. I've added an instance of CustomJPanel to the JDialog derived class, which has an OK and cancel buttons.
Once the user presses OK, I'd like to access the value at specific cell from my custom JDialog class. This is because the user should know if there's a cell with an incorrect value set by the user, and if there is, it should know which one exactly. The problem is the JDialog class has the reference to CustomJPanel, not the JTable. I have two options:
add a method to CustomJPanel that returns the JTable (it breaks encapsulation)
add a method to CustomJPanel that returns the value of a specific cell from JTable
Which one is better? These are the two I was able to come up with, maybe you could suggest something better.