Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes Gui inheritance Question Using NetBeans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Gui inheritance Question Using NetBeans" Watch "Gui inheritance Question Using NetBeans" New topic
Author

Gui inheritance Question Using NetBeans

Jim Schneider
Greenhorn

Joined: Oct 22, 2003
Posts: 3
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?

TIA
Jim
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38508
    
  23
Welcome to the Ranch.

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."

    CR
    Darrin Cartwright
    Ranch Hand

    Joined: Dec 27, 2002
    Posts: 107
    Hi Jim!

    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

    Good luck!

    Darrin


    Life is good on the Ponderosa,<br />but mind where you step.
     
    jQuery in Action, 2nd edition
     
    subject: Gui inheritance Question Using NetBeans