NetBeans Forums

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

Inserting a Label and a Image Icon into the Menu bar

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users
View previous topic :: View next topic  
Author Message
anusanraj



Joined: 12 Sep 2012
Posts: 3

PostPosted: Mon Dec 17, 2012 6:59 am    Post subject: Inserting a Label and a Image Icon into the Menu bar Reply with quote

In my netbeans platform based app, I need to add a Label which shows the user name and a image icon into the Menu bar. Menu items are defined in an xml file and action classes are used to define menu actions. How can I customize the menu bar in order to put a label and a image icon at the right corner of the menu bar? Is this possible?
Back to top
markiewb



Joined: 29 Aug 2012
Posts: 494

PostPosted: Mon Dec 17, 2012 6:07 pm    Post subject: [platform-dev] Re: Inserting a Label and a Image Icon into the Menu bar Reply with quote

Go the easy way and show the label in a toolbar or the statusbar. In both cases cases you can show arbitrary jcomponents including images.

Greetings markiewb Am 17.12.2012 12:27 schrieb "anusanraj" <address-removed ([email]address-removed[/email])>:
Quote:
In my netbeans platform based app, I need to add a Label which shows the user name and a image icon into the Menu bar. Menu items are defined in an xml file and action classes are used to define menu actions. How can I customize the menu bar in order to put a label and a image icon at the right corner of the menu bar?




Back to top
mienamoo



Joined: 12 Nov 2010
Posts: 356
Location: South Africa

PostPosted: Tue Dec 18, 2012 6:24 am    Post subject: [platform-dev] Re: Inserting a Label and a Image Icon into the Menu bar Reply with quote

Hi,

Quote:
In my netbeans platform based app, I need to add a Label which shows the user name and a image icon into the Menu bar. Menu items are defined in an xml file and action classes are used to define menu actions. How can I customize the menu bar in order to put a label and a image icon at the right corner of the menu bar?

In the same way that you can add a component to the toolbar [1], you
can also add it to the menubar. Just change the @ActionReference
annotation so that the path is "Menu", and it will appear on the
menubar instead.

Adding a spacer to the left of it will force the component to the
right. See the very last part of [2] for an example.

[1] http://platform.netbeans.org/tutorials/nbm-google.html
[2] http://platform.netbeans.org/tutorials/nbm-quick-search.html

I will write a blog post with specific details soon. :)

Best wishes,
Hermien PELLISSIER
Back to top
anusanraj



Joined: 12 Sep 2012
Posts: 3

PostPosted: Wed Dec 19, 2012 5:28 am    Post subject: Re: [platform-dev] Re: Inserting a Label and a Image Icon into the Menu bar Reply with quote

Thanks for your reply.
mienamoo wrote:
Hi,

Quote:
In my netbeans platform based app, I need to add a Label which shows the user name and a image icon into the Menu bar. Menu items are defined in an xml file and action classes are used to define menu actions. How can I customize the menu bar in order to put a label and a image icon at the right corner of the menu bar?

In the same way that you can add a component to the toolbar [1], you
can also add it to the menubar. Just change the @ActionReference
annotation so that the path is "Menu", and it will appear on the
menubar instead.

Adding a spacer to the left of it will force the component to the
right. See the very last part of [2] for an example.

[1] http://platform.netbeans.org/tutorials/nbm-google.html
[2] http://platform.netbeans.org/tutorials/nbm-quick-search.html

I will write a blog post with specific details soon. Smile

Best wishes,
Hermien PELLISSIER


I was able to add a Label into the menu bar by creating an Actionclass and overriding its getToolbarPresenter() method. Inside getToolbarPresenter(), it returns the Jlabel.
Back to top
mienamoo



Joined: 12 Nov 2010
Posts: 356
Location: South Africa

PostPosted: Wed Dec 19, 2012 1:40 pm    Post subject: [platform-dev] Re: Inserting a Label and a Image Icon into the Menu bar Reply with quote

Quote:
I was able to simple add a quck search into menu bar. But how can I add my own customized Jpanel instead?

Follow the steps of [1], to get your JPanel onto the toolbar. Then
change the @ActionReference annotation in the action class so that the
path is "Menu" instead of "Toolbars/File".

And then add the spacer like in the quick search tutorial. Only the
spacer part, not the quick search too. You can position it relative to
your component by choosing its position relative to the position in
the annotation.

[1] http://platform.netbeans.org/tutorials/nbm-google.html

Best wishes,
Hermien PELLISSIER
Back to top
mienamoo



Joined: 12 Nov 2010
Posts: 356
Location: South Africa

PostPosted: Wed Dec 19, 2012 8:02 pm    Post subject: Re: [platform-dev] Re: Inserting a Label and a Image Icon into the Menu bar Reply with quote

Hi,

I just published a blog post with more details as promised. You can read it at http://www.pellissier.co.za/hermien/?p=646

Best wishes,
Hermien PELLISSIER
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform 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