NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Newbie UI question

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
Sebastian Dahlgren
Posted via mailing list.





PostPosted: Sun Jun 22, 2008 6:30 am    Post subject: Newbie UI question Reply with quote

Hi everybody!
I have a question that probably is very basic. I have one main JForm with a menu and a Menu item called Calculations. Below the menu I have one JPanel named jPanel1. Besides I have another class in the same package which extends JPanel called Calculator.

How may I show the Calculator panel inside (or instead of) jPanel1 when someone clicks Calculations in the menu?
Thanks in advance
--
Sebastian Dahlgren
Back to top
Johnny Kewl
Posted via mailing list.





PostPosted: Sun Jun 22, 2008 11:45 am    Post subject: Newbie UI question Reply with quote

Quote:
----- Original Message -----
From: Sebastian Dahlgren (sebastian.dahlgren@gmail.com)
To: nbusers@netbeans.org (nbusers@netbeans.org)
Sent: Sunday, June 22, 2008 8:30 AM
Subject: [nbusers] Newbie UI question


Hi everybody!
I have a question that probably is very basic. I have one main JForm with a menu and a Menu item called Calculations. Below the menu I have one JPanel named jPanel1. Besides I have another class in the same package which extends JPanel called Calculator.

How may I show the Calculator panel inside (or instead of) jPanel1 when someone clicks Calculations in the menu?
Thanks in advance
--
Sebastian Dahlgren

Quote:
Sebastian, I dont know if there is a smarter way...
A typical answer would be something like use null layout, position them over each other, and hide/show as needed, but I'm a ddicted to matisse and all that other cool stuff, like auto resizing and most other layout managers are a mission... so this is what I do and its probably wrong but it works.

I layout my panels(as you have done separately) (I use NB 5.5 btw) and then I add them via the palette manager (ie they now just special panels), in the pallete.
Then I bring one in at a time... lay it out using matisse, get it right... then I copy all that BLUE autogen stuff and make another initComponents_look1 section.

Then I do the same for the others... so I'm being really lazy, letting NB make all the code for me and copying it out.
Remember that if you have made events, they also have to have to be deBLUE'd... ie copy the code.

Then I stuff around until I get it right.... but just to try it preceed each of your DE-BLUEd functions with
this.getContentPane().removeAll();
and you'll get the idea, it clears the last layout and makes a new one.

Sometimes you can share events, sometimes not, and you'll end up doctoring the code to persist some state across layouts, but at least you start with a basic frame work, for each custom layout.
The last BLUE setup you leave as your default.

What I find is that trying to overlay with matisse is near impossible... but otherwise its really cool, and DE-Blue-ing works for me;)
I prefer it to loading all components and hiding stuff...
Once you get the idea, its better to make swap out panels... and work only in those, ie dont change the whole display.
The idea is that the "footprint" is very similar for the swapped out area's, but it doesnt have to be.

One wrong way that works... I guess Wink
But it lets matisse and NB do all the work.
DE-Bluing is probably only for lazy people... like me Wink

ps: would be interesting to see how other people go about swapping out panels...
Once you have done one, you can kinda see why overlaying frames in matisse with the idea of swapping them out is not a feature... when you customize your De-Blued code, there are millions of ways to do it... so not blaming matisse are all... De-Bluing gets the best of both worlds.

You end up with lots of sub projects... but if you ever do need get an old blue back, you can get it back with a text editor...

Have fun Wink

---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------

Back to top
Sebastian Dahlgren
Posted via mailing list.





PostPosted: Sun Jun 22, 2008 12:11 pm    Post subject: Newbie UI question Reply with quote

Thanks for the informative answer!

I accually managed to find an alternative solution in the meanwhile. This is how I have done it now:

First I created my panels as separate classes. Then I created a main frame. When I want to show a new panel in the frame I create an event with code like this:

JPanel c = new CalculatorPanel();

c.setVisible(true);
c.setEnabled(true);

mainPanel.removeAll();
mainPanel.add(c);
mainPanel.updateUI();

Which cleans up the mainPanel and adds the new panel to it.

It works pretty well for this small project.

Best regards
Sebastian Dahlgren

On Sun, Jun 22, 2008 at 1:45 PM, Johnny Kewl <john@kewlstuff.co.za (john@kewlstuff.co.za)> wrote:
Quote:

Quote:

----- Original Message -----
From: Sebastian Dahlgren (sebastian.dahlgren@gmail.com)
To: nbusers@netbeans.org (nbusers@netbeans.org)
Sent: Sunday, June 22, 2008 8:30 AM
Subject: [nbusers] Newbie UI question


Hi everybody!
I have a question that probably is very basic. I have one main JForm with a menu and a Menu item called Calculations. Below the menu I have one JPanel named jPanel1. Besides I have another class in the same package which extends JPanel called Calculator.

How may I show the Calculator panel inside (or instead of) jPanel1 when someone clicks Calculations in the menu?
Thanks in advance
--
Sebastian Dahlgren



Quote:
Sebastian, I dont know if there is a smarter way...
A typical answer would be something like use null layout, position them over each other, and hide/show as needed, but I'm a ddicted to matisse and all that other cool stuff, like auto resizing and most other layout managers are a mission... so this is what I do and its probably wrong but it works.

I layout my panels(as you have done separately) (I use NB 5.5 btw) and then I add them via the palette manager (ie they now just special panels), in the pallete.
Then I bring one in at a time... lay it out using matisse, get it right... then I copy all that BLUE autogen stuff and make another initComponents_look1 section.

Then I do the same for the others... so I'm being really lazy, letting NB make all the code for me and copying it out.
Remember that if you have made events, they also have to have to be deBLUE'd... ie copy the code.

Then I stuff around until I get it right.... but just to try it preceed each of your DE-BLUEd functions with
this.getContentPane().removeAll();
and you'll get the idea, it clears the last layout and makes a new one.

Sometimes you can share events, sometimes not, and you'll end up doctoring the code to persist some state across layouts, but at least you start with a basic frame work, for each custom layout.
The last BLUE setup you leave as your default.

What I find is that trying to overlay with matisse is near impossible... but otherwise its really cool, and DE-Blue-ing works for me;)
I prefer it to loading all components and hiding stuff...
Once you get the idea, its better to make swap out panels... and work only in those, ie dont change the whole display.
The idea is that the "footprint" is very similar for the swapped out area's, but it doesnt have to be.

One wrong way that works... I guess Wink
But it lets matisse and NB do all the work.
DE-Bluing is probably only for lazy people... like me Wink

ps: would be interesting to see how other people go about swapping out panels...
Once you have done one, you can kinda see why overlaying frames in matisse with the idea of swapping them out is not a feature... when you customize your De-Blued code, there are millions of ways to do it... so not blaming matisse are all... De-Bluing gets the best of both worlds.

You end up with lots of sub projects... but if you ever do need get an old blue back, you can get it back with a text editor...

Have fun Wink

---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------





--
Sebastian Dahlgren
Back to top
Johnny Kewl
Posted via mailing list.





PostPosted: Sun Jun 22, 2008 1:12 pm    Post subject: Newbie UI question Reply with quote

Quote:
----- Original Message -----
From: Sebastian Dahlgren (sebastian.dahlgren@gmail.com)
To: nbusers@netbeans.org (nbusers@netbeans.org)
Sent: Sunday, June 22, 2008 2:11 PM
Subject: Re: [nbusers] Newbie UI question


Quote:
Thanks for the informative answer!

I accually managed to find an alternative solution in the meanwhile. This is how I have done it now:

First I created my panels as separate classes. Then I created a main frame. When I want to show a new panel in the frame I create an event with code like this:

JPanel c = new CalculatorPanel();

c.setVisible(true);
c.setEnabled(true);

mainPanel.removeAll();
mainPanel.add(c);
mainPanel.updateUI();

Which cleans up the mainPanel and adds the new panel to it.

It works pretty well for this small project.

Best regards
Sebastian Dahlgren

Yes, excellent, nice clean way to do it... when you want to change just part of a complex layout, not a complete swap... what you doing becomes deBluing Wink
What you doing is neat... that cant be bad Wink
---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------

Back to top
Gavin Ross\(i\)
Posted via mailing list.





PostPosted: Sun Jun 22, 2008 2:36 pm    Post subject: Newbie UI question Reply with quote

Hi Sebastian,

The way i find works best is if you insert a scrollpane in you jframe as the first level component and then insert your welcome jpanel into your scroll pane. use matisse for the layout of you welcome jpanel in your main jframe.

for your other jpanels create seperate jpanels under your project and then swap the jpanels via events from the menu. you need to catch the seperate jpanel events in your jframe through.

Regards
Gavin
Quote:

-----Original Message-----
From: Johnny Kewl [mailto:john@kewlstuff.co.za]
Sent: 22 June 2008 01:45 PM
To: nbusers@netbeans.org
Subject: Re: [nbusers] Newbie UI question



Quote:
----- Original Message -----
From: Sebastian Dahlgren (sebastian.dahlgren@gmail.com)
To: nbusers@netbeans.org (nbusers@netbeans.org)
Sent: Sunday, June 22, 2008 8:30 AM
Subject: [nbusers] Newbie UI question


Hi everybody!
I have a question that probably is very basic. I have one main JForm with a menu and a Menu item called Calculations. Below the menu I have one JPanel named jPanel1. Besides I have another class in the same package which extends JPanel called Calculator.

How may I show the Calculator panel inside (or instead of) jPanel1 when someone clicks Calculations in the menu?
Thanks in advance
--
Sebastian Dahlgren

Quote:
Sebastian, I dont know if there is a smarter way...
A typical answer would be something like use null layout, position them over each other, and hide/show as needed, but I'm a ddicted to matisse and all that other cool stuff, like auto resizing and most other layout managers are a mission... so this is what I do and its probably wrong but it works.

I layout my panels(as you have done separately) (I use NB 5.5 btw) and then I add them via the palette manager (ie they now just special panels), in the pallete.
Then I bring one in at a time... lay it out using matisse, get it right... then I copy all that BLUE autogen stuff and make another initComponents_look1 section.

Then I do the same for the others... so I'm being really lazy, letting NB make all the code for me and copying it out.
Remember that if you have made events, they also have to have to be deBLUE'd... ie copy the code.

Then I stuff around until I get it right.... but just to try it preceed each of your DE-BLUEd functions with
this.getContentPane().removeAll();
and you'll get the idea, it clears the last layout and makes a new one.

Sometimes you can share events, sometimes not, and you'll end up doctoring the code to persist some state across layouts, but at least you start with a basic frame work, for each custom layout.
The last BLUE setup you leave as your default.

What I find is that trying to overlay with matisse is near impossible... but otherwise its really cool, and DE-Blue-ing works for me;)
I prefer it to loading all components and hiding stuff...
Once you get the idea, its better to make swap out panels... and work only in those, ie dont change the whole display.
The idea is that the "footprint" is very similar for the swapped out area's, but it doesnt have to be.

One wrong way that works... I guess Wink
But it lets matisse and NB do all the work.
DE-Bluing is probably only for lazy people... like me Wink

ps: would be interesting to see how other people go about swapping out panels...
Once you have done one, you can kinda see why overlaying frames in matisse with the idea of swapping them out is not a feature... when you customize your De-Blued code, there are millions of ways to do it... so not blaming matisse are all... De-Bluing gets the best of both worlds.

You end up with lots of sub projects... but if you ever do need get an old blue back, you can get it back with a text editor...

Have fun Wink

---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG.
Version: 8.0.100 / Virus Database: 270.4.1/1512 - Release Date: 2008/06/21 09:27 AM
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo