Reputation: 316
I have a main package "UI" where i have all classes of my Swing Application.
In this package i extended JTree, JTable and some more components, and also made some custom renderers, custom models for them.
It is ok to group several classes related to a JComponent in their own package?
For example :
package ui.CustomTable
CustomJTable
CustomJTableModel
JTableColumnRenderer
package ui.MYJList
MYJList
MyJListModel
MyJListCellRenderer
I'm new in Software Engineering, it's my first job and I am asking you because i am "afraid" of breaking any OOP code conventions.
Upvotes: 1
Views: 92
Reputation: 168825
It is ok to group several classes related to a JComponent in their own package?
Certainly. In fact, it can be quite advantageous to have Swing classes in appropriate packages, especially when deployed using Java Web Start.
JWS can organize download, updates and security levels per Jar, so if each package is in a Jar, it means each package is only downloaded & cached, updated or checked for valid digital signature/security levels if needed.
Also note that renderers (or PLAFs) might change more frequently than other components when management decides the app. needs a 'different, more modern (than 4 months ago) look'.
Upvotes: 2
Reputation: 159754
As a general guide, you could look at the package structure of the standard components that you are subclassing and map it to your own structure. You could use classes like so:
ui.CustomTable
ui.CustomList
ui.CustomListModel
ui.table.CustomTableColumnRenderer
It is better to have a consistent naming convention for class names.
Upvotes: 1