Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #360

Re: How to determine if a

From "Orlando" <orlando@THRWHITE.remove-dii-this>
Subject Re: How to determine if a
Message-ID <1165660595.211492.47430@79g2000cws.googlegroups.com> (permalink)
Newsgroups comp.lang.java.gui
References <1165640664.144009.182990@79g2000cws.googlegroups.com>
Date 2011-04-27 15:27 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
After some trial I figured that one can cast the items added to the
JMenuBar to a Container and use the getComponent() and
getComponentCount() to iterate through the items inside that container.
 The only exception was the JMenu object.  Calling the
getComponentCount() method would always return 0.

After some reading and browsing the source code for the JMenu class I
noticed that a JMenu does not behave like other containers.  One need
to call the method getMenuComponent() or getMenuComponentCount() to
iterate through the subcomponents of the menu.  So I placed an if
statement to deal with this specific class using the alternate methods.


Just in case I went about this the long way, does anyone have any
better suggestions?


Orlando wrote:
> I like to write a method that will set the font of a JMenuBar and all
> menu items in that Menu bar.  I can find any components inside the
> menubar using the getComponents() method.  How can one determine if any
> of these components is a container?  I would like to recursively go
> through every item in the menus and sub-menus and set the font of those
> menuitems as per the user preferences.
>
> Any suggestions?
> 
> Saludos,
> 
> Orlando
> orlandoamador@yahoo.com

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

How to determine if a JCo "Orlando" <orlando@THRWHITE.remove-dii-this> - 2011-04-27 15:27 +0000
  Re: How to determine if a "Orlando" <orlando@THRWHITE.remove-dii-this> - 2011-04-27 15:27 +0000
  Re: How to determine if a "Larry Barowski" <larry.barowski@THRWHITE.remove-dii-this> - 2011-04-27 15:27 +0000

csiph-web