This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I have a Frame that I inherited from JFrame Class. I have placed a couple of Buttons on that frame I will call this frame aFrame.
Now what I want to do is inherit from the new aFrame class which has the buttons already placed on the frame. I could not find a way in the netbeans ide to specify that I wanted the superclass to be the frame with the buttons already on it.I create a new frame class and change the generated code to extend the aFrame class. When I open that class in the GUI designer I cannot see the buttons but if I run the app and open the new frame the buttons are there and visible.
My questions are as follows. 1. Am I correct in assuming that if I inherit from a Frame object it should contain the buttons which it does but should they be visible when I open the "new" Frame? I am coming from another visual development language which works in this way.
2. I know that this is not a NetBeans forum but does anybody know is there a correct way in the NetBeans GUI to specify a class to extend that allows the buttons to be visible in the class that is extending another Frame?
Not quite sure about either half of your query, but try this:-
If you call your class AFrame, you need another class which extends it.
Create class BFrame extends AFrame.
Create BFrame constructor with String title as its parameter.
Call super(title); in the BFrame constructor.
Add any other features you need.
I don't use NetBeans very often, preferring Eclipse, but I can't remember a simple way of naming a superclass in the NetBeans new class wizard. There is a "superclass" box and an "interfaces" box in the corresponding wizard in Eclipse, which I use all the time. You might have to do it the hard way, writing "class BFrame extends AFrame."
As a fellow Netbeans user, I have fought this before. In order to get your subclass to show up correctly in the form designer, you must create a javabean containing the component, and then install that bean into the Pallet. After that, you can drag-and-drop the item from the Pallet onto a form, and all should be well. If you are using Netbeans 5.5, there is an easier way using a project, but a better description of the process can be found here: http://wiki.netbeans.org/wiki/view/FaqFormUsingCustomComponent
Life is good on the Ponderosa,<br />but mind where you step.