I have created some custom JPanel
classes using the NetBeans GUI Builder. Next, I added them to the palette. Then I created a custom JFrame
and was able to drag my JPanel
s onto the JFrame
. This worked great while I was simply working on the GUI front end. Now I am working on the backend logic, which includes some JDBC code. I have created a BaseballCardIO
interface and implemented it in BaseballCardJDBCIO
to centralize all the the database stuff.
Now, one of my JPanels, AddCardsPanel
, needs a reference to one of these BaseballCardIO
s. I started by creating one directly in the AddCardsPanel
constructor. (I know, not the best design decision anyway...) Everything was working great until I open my JFrame
class in NetBeans. It started to complain about not finding the JDBC driver class.
I want to continue to use the NetBeans GUI Builder for now. I have two solutions in mind to fix my problem:
1) Tell NetBeans where to find the JDBC driver and keep the code as-is. How do I do this?
2) Modify my design so that AddCardsPanel
has a constructor which takes a BaseballCardIO
as a parameter. This would actually be preferrable since it makes more sense for someone else to be responsible for creating the BaseballCardIO
, not AddCardsPanel
. However, I still need AddCardsPanel
to play nicely with NetBeans GUI Builder, which means that it needs a no-args constructor. I imagine that I could add some code which detects if AddCardsPanel
is being used as a JavaBean by NetBeans then the JFrame
calls the noargs constructor. Otherwise, if my application is actually running, then the JFrame
calls other constructor and sends it a BaseballCardIO
.
Is this a good way to go? Or does anyone have any other possible solutions?