Quantcast

Change JFrame to JPanel?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Change JFrame to JPanel?

Johnny Tolliver
I have a simple GUI with a couple of GridBagLayout panels and a few buttons in
a JFrame. I would now like to put that GUI in a JTabbedPane, then add another
tab with more options, etc. That means I need to convert the first JFrame GUI
into a JPanel so I can add it to the JTabbedPane. The NB form designer doesn't
seem to like me doing that. Is there any way without recreating the original
GUI design in a new JPanel? Thanks.

Johnny S. Tolliver
Oak Ridge National Laboratory
[hidden email], 865-574-1305


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Change JFrame to JPanel?

Chuck Davis
Johnny:

I've changed some simple dialogs from one to another just by changing the
"extends" statement.  I think if I wanted to do what you are suggesting I
would make a copy of the original and with the copy I'd change the extends
statement and see what happened.  I have a hunch it would work.  Then delete
the JFrame and rename your JPanel dialog.  Done.  As I said, I've done it for
simple JFrames, JDialogs but never anything complex.  Can't hurt anything to
try!

Chuck Davis

On Thursday 10 November 2005 10:57 am, Johnny Tolliver wrote:

> I have a simple GUI with a couple of GridBagLayout panels and a few buttons
> in a JFrame. I would now like to put that GUI in a JTabbedPane, then add
> another tab with more options, etc. That means I need to convert the first
> JFrame GUI into a JPanel so I can add it to the JTabbedPane. The NB form
> designer doesn't seem to like me doing that. Is there any way without
> recreating the original GUI design in a new JPanel? Thanks.
>
> Johnny S. Tolliver
> Oak Ridge National Laboratory
> [hidden email], 865-574-1305
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Change JFrame to JPanel?

Tomas Pavek
In reply to this post by Johnny Tolliver
Changing 'extends' clause to JPanel should be enough in most cases. See also
this FAQ entry:
http://www.netbeans.org/kb/faqs/gui-editor.html#FaqFormChangingType

   - Tomas


Johnny Tolliver wrote:

> I have a simple GUI with a couple of GridBagLayout panels and a few buttons in
> a JFrame. I would now like to put that GUI in a JTabbedPane, then add another
> tab with more options, etc. That means I need to convert the first JFrame GUI
> into a JPanel so I can add it to the JTabbedPane. The NB form designer doesn't
> seem to like me doing that. Is there any way without recreating the original
> GUI design in a new JPanel? Thanks.
>
> Johnny S. Tolliver
> Oak Ridge National Laboratory
> [hidden email], 865-574-1305
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Change JFrame to JPanel?

Charles Whittington
In reply to this post by Chuck Davis
Yes I have done this and it does work; sort of. Change the extends and
them save (close) the source. Re-open and then fix up the mess which, in
my cases, was not too bad.

Charles Whittington

Chuck Davis wrote:

>Johnny:
>
>I've changed some simple dialogs from one to another just by changing the
>"extends" statement.  I think if I wanted to do what you are suggesting I
>would make a copy of the original and with the copy I'd change the extends
>statement and see what happened.  I have a hunch it would work.  Then delete
>the JFrame and rename your JPanel dialog.  Done.  As I said, I've done it for
>simple JFrames, JDialogs but never anything complex.  Can't hurt anything to
>try!
>
>Chuck Davis
>
>On Thursday 10 November 2005 10:57 am, Johnny Tolliver wrote:
>  
>
>>I have a simple GUI with a couple of GridBagLayout panels and a few buttons
>>in a JFrame. I would now like to put that GUI in a JTabbedPane, then add
>>another tab with more options, etc. That means I need to convert the first
>>JFrame GUI into a JPanel so I can add it to the JTabbedPane. The NB form
>>designer doesn't seem to like me doing that. Is there any way without
>>recreating the original GUI design in a new JPanel? Thanks.
>>
>>Johnny S. Tolliver
>>Oak Ridge National Laboratory
>>[hidden email], 865-574-1305
>>    
>>
>
>
>  
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Change JFrame to JPanel?

Vanja Bucic
You can also open a new JPanel and copy&paste the stuff from old JFrame...


Charles Whittington wrote:

> Yes I have done this and it does work; sort of. Change the extends and
> them save (close) the source. Re-open and then fix up the mess which, in
> my cases, was not too bad.
>
> Charles Whittington
>
> Chuck Davis wrote:
>
>> Johnny:
>>
>> I've changed some simple dialogs from one to another just by changing
>> the "extends" statement.  I think if I wanted to do what you are
>> suggesting I would make a copy of the original and with the copy I'd
>> change the extends statement and see what happened.  I have a hunch it
>> would work.  Then delete the JFrame and rename your JPanel dialog.  
>> Done.  As I said, I've done it for simple JFrames, JDialogs but never
>> anything complex.  Can't hurt anything to try!
>>
>> Chuck Davis
>>
>> On Thursday 10 November 2005 10:57 am, Johnny Tolliver wrote:
>>  
>>
>>> I have a simple GUI with a couple of GridBagLayout panels and a few
>>> buttons
>>> in a JFrame. I would now like to put that GUI in a JTabbedPane, then add
>>> another tab with more options, etc. That means I need to convert the
>>> first
>>> JFrame GUI into a JPanel so I can add it to the JTabbedPane. The NB form
>>> designer doesn't seem to like me doing that. Is there any way without
>>> recreating the original GUI design in a new JPanel? Thanks.
>>>
>>> Johnny S. Tolliver
>>> Oak Ridge National Laboratory
>>> [hidden email], 865-574-1305
>>>  
>>
>>
>>
>>  
>>
>
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Change JFrame to JPanel?

Chris Dickerson-2
In reply to this post by Johnny Tolliver
HI John

I have converted between JDialog <-> JFrame a few times. Change the code as
needed. Close the form and re-open and NB handles the transition well. For
frame to panel I have done it by making a new frame placing the panel where
required and copy/paste the components into the panel. The existing
GridBagLayout settings will remain intact.

Chris Dickerson

-----Original Message-----
From: Johnny Tolliver [mailto:[hidden email]]
Sent: Friday, 11 November 2005 4:58 AM
To: [hidden email]
Subject: [nbusers] Change JFrame to JPanel?

I have a simple GUI with a couple of GridBagLayout panels and a few buttons
in
a JFrame. I would now like to put that GUI in a JTabbedPane, then add
another
tab with more options, etc. That means I need to convert the first JFrame
GUI
into a JPanel so I can add it to the JTabbedPane. The NB form designer
doesn't
seem to like me doing that. Is there any way without recreating the original
GUI design in a new JPanel? Thanks.

Johnny S. Tolliver
Oak Ridge National Laboratory
[hidden email], 865-574-1305





Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Change JFrame to JPanel?

Johnny Tolliver
In reply to this post by Johnny Tolliver
Thanks to all who replied. I had already tried changing the "extends" in the
source. After that the form designer became rather unhappy, complaining of
multiple errors, and suggesting that I switch to a "read-only" version.

Having not found the FAQ entry that said to remove all the non-JFrame things,
I paniced and put back "extends JFrame" and got back to normal. Then I turned
to the nbusers posting you all so kindly replied to. I have not tried but am
convinced that following the FAQ entry recommendations would work
(http://www.netbeans.org/kb/faqs/gui-editor.html#FaqFormChangingType)

> You can also open a new JPanel and copy&paste the stuff from old JFrame...

While awaiting your replies (I read the digest version of nbusers, so there is
a definite latency to deal with) that is exactly what I eventually did. Copy
and paste worked fine, keeping all the gridbag layout features intact just
fine. Pasting the entire frame contents en masse to a JPanel didn't quite work
(since the panel layout is different from a frame). But I just had to move
some of the components around to get back to what I needed.

Thanks for the quick and helpful replies.

Johnny S. Tolliver
Oak Ridge National Laboratory
[hidden email], 865-574-1305



Loading...