Article View: borland.public.jbuilder.java.swing
Article #221Accessing Components of top-level Frame?
From: Tom Giammo
Date: Sun, 31 Dec 2006 18:35
Date: Sun, 31 Dec 2006 18:35
33 lines
2715 bytes
2715 bytes
After a six year hiatus, I'm back into Java and have been using JBuilder Foundation to relearn what I once knew and to learn some new things that weren't around back when. I'm stuck on trying to alter the text of a "statusBar" JLabel component that was set up for me on the top-level frame when I started a new application. From looking at the generated source code, it appears that when the main() method of my application constructs itself, its creates an instance (which it names "frame") of my designated top-level extension to JFrame. The constructor for that top-level JFrame extension lists among its components a JLabel named "statusBar". I would like to alter the text of "stausBar" from within another component that I've added to "frame", the instance of the top-level JFrame extension. I've tried several approaches to getting at "statusBar". Simply using its name (i.e. "frame.statusBar") doesn't work - presumably because "frame" is only a property of the generated application class (named, in this case, "hexGame"). The instance of hexGame, however, has not been given a name by JBuilder - it is simply generated in the main() method by "new hexGame()" without any assignment - and so I can't prefix its name to "frame.statusBar". I've tried using the "parentFrame" property of the component on the same "frame" from which I am trying to alter "statusBar". With the right castings, this compiles without a problem but causes an uncaught exception in the system's event queue. Everything else in my application works like a charm - as long as I don't try to access "statusBar". I'm obviously missing something. I'd appreciate what ever help anyone gan give. Tom Giammo
Technical Details
Message-ID:
<459802c2$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 111d45,d29c312c94108c85,start X-Google-Attributes: gid111d45,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Tom Giammo" <crestline@giammo.com> From: "Tom Giammo" <crestline@giammo.com> Newsgroups: borland.public.jbuilder.java.swing Subject: Accessing Components of top-level Frame? Date: Sun, 31 Dec 2006 13:35:26 -0500 Lines: 35 Organization: Crestline Enterprises X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3028 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 NNTP-Posting-Host: 69.138.228.103 Message-ID: <459802c2$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1167590082 69.138.228.103 (31 Dec 2006 10:34:42 -0800) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail