Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / November 2003

Tip: Looking for answers? Try searching our database.

Opening a panel in another class?

Thread view: 
={ Advocated }= - 04 Nov 2003 13:29 GMT
Hi there, i could do with a bit of help please:

Ive got 2 classes at the moment:
km (km.java)
jPanel44 (jPanel44.java)

the km.java holds most of the details, and within it, ive got a jPanel,
named ghJPanel, this is set to a border layout, so ive got components in the
west,north,south and east, and the Center bit is; at the moment empty.

Now, in the other class jPanel44(jPanel44.java) Its set like, Form JPanel,
on there is the JPanel which is also set to border, on there ive got
mainPanel44.

What i now want is a way that i can show(setVisible(true);) the mainPanel44,
on the CENTER part of the ghJPanel

I just cant work out what do do :S

Im going to use a button on the km Form, so when clicked it shows the
mainPanel44

Anyone got any ideas?
Help would be greatly apreciated

Thanks
Andrew Thompson - 04 Nov 2003 13:55 GMT
> Hi there, i could do with a bit of help please:

It sounds, from your description, that you are putting
the program logic into the GUI elements.

This is not good design.

Try to imagine how you would code your
app to work from the command line / DOS
window.  In fact, _make_ it work from the
command line.

_Then_ write a GUI to interact with it.

--
Andrew Thompson
http://www.AThompson.info/
http://www.PhySci.org/
http://www.1point1C.org/
={ Advocated }= - 05 Nov 2003 11:41 GMT
> > Hi there, i could do with a bit of help please:
>
[quoted text clipped - 15 lines]
> http://www.PhySci.org/
> http://www.1point1C.org/

i can already run the program from dos if i wish to, but this program is
really only for me, so i can test something. The GUI is the main part of it,
and the way i wanted it to work is so all the logic is actually with the GUI
components.

Ive read some articles etc, and have tried doing:

   private void start44MouseClicked(java.awt.event.MouseEvent evt) {
       gridHouseJPanel.add(mainPanel44, java.awt.BorderLayout.CENTER);
   }

this should mean, that when the mouse is clicked, the mainPanel44 should be
loaded onto the gridHouseJPanel.
The mainPanel44 is from the JPanel44 class, and the gridHouseJPanel is from
the km class.

I assumed this would work, obviously not, i get the error:
"
Java/Assessment/Km/km.java [104:1] cannot resolve symbol
symbol  : variable mainPanel44
location: class Java.Assessment.km.km
       gridHouseJPanel.add(mainPanel44, java.awt.BorderLayout.CENTER);
                           ^
1 error
Errors compiling km.
"

Anyone know what im missing, i cant work it out? i tried also making the
mainPanel44 public but it shouldnt matter as both are in the same package

Thanks all
={ Advocated }= - 05 Nov 2003 19:31 GMT
> > > Hi there, i could do with a bit of help please:
> >
[quoted text clipped - 47 lines]
>
> Thanks all

You wouldnt think this was difficult would u... :p


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.