This is my first post on this forum so hi everyone.
I would like to ask for your opinion about this code. It is GUI for small program I want to write.
Is there something I need to change or something what clearly could be writen better?
I could add only that second tab will be a bit bigger than first. Is there any point in splitting this GUI into few classes?
I'm waiting for your opinions. Thank you in advance.
You seem to organize your program pretty good, very clear splitting each section of the main window (frame) into its own methods.
* you can extend the class making it a JFrame instead of declaring a (instance) variable.
* instance variables in GUI code is only necessary IMHO when multiple methods or inner class (eg anonymous listeners) need them. Try keeping the scope of these as small (local) as possible.
* you xxxPanel() methods can in fact return the actual panel instead of void. The syntax would then look like line line 44 & 45 of your code
* when it comes to GUI design, IMHO if there is a lots of components (panels, menu bars, dialogs, listeners etc) that can possibly "reuse", then having it as a separate class is a good idea. The key is reusability. Another key is to some extend maintainability - changing one class or that section of the GUI "should not" affect the other parts. The disadvantage I see to splitting into classes is you need to understand how each class/component interact. For example: say you have a JTable, does a listener need to update the table model, if so do you need to pass the JTable reference to the listener class or can the listener get the table from some where else.
K. Tsang OCPJP OCMJEA SOACP PMP
posted 4 years ago
Thank you for your suggestions but I have another questions.
Is there any limit of lines in class which determines if I should split my class or it doesn't matter? Is there such a thing as too big class?