Hi When I started programming the assignment, I found I put too much code on the same page. I tried to split the code into files by creating public classes. By doing so, I call the external class by creating instance. Am I in the right approach? However, when I tried to create another class for creating the panel of a JTable together with a button which tells the program to go to the next panel, I need to create another instance from the Jtable class to call back to the main class to navigate to the next panel. This approach looks strange to me. Also, although clicking the button on the Jtable panel can trigger an event, it goes to the wrong panel. Any recommedation is highly appreciated. [ January 31, 2002: Message edited by: Brandon W ]
By doing so, I call the external class by creating instance. Am I in the right approach?
Well yes you will have plenty of public classes. That's what is a benefit of OOP. As far as having to recreate an instance of your JTable because you switch panels. You will want to relook at where you create your instance, whether you want to pass the reference of that JTable to the next class, so that that class does not have to create a seperate/different instance of the JTable, which means that they both have no clue as to the others existance.
This approach looks strange to me.
I found that whenever I said that, I needed to rewrite that part. You need to trust your instincts in those areas. I hope that helps a bit for you. I wish I had a good link for you to go to that explains designing OOP applications. But I don't know of any sorry. Except maybe some of the forums here. I think there is an OOP forum at Javaranch Mark
One way I found was to make sure you were using the correct Java API class. For instance, the collections classes. If I used say a Vector, and it took me 10 lines of code to find a matching Object in a Vector, and then changed it to a HashSet and found that that same code was only 1 line. That's using the correct class. Always make methods do one thing and one thing only. If you feel that a method is becoming too large, look to see if it is trying to do more than one thing. By spliting this out, you will find that the new method might be able to be called from another method that needs that same functionality, so there you have the code in one place. and It is more readable. Hope that helps. Mark