Wrox Programmer Forums
|
Java GUI Discussions specific to programming Java GUI.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java GUI section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 18th, 2003, 09:38 AM
Registered User
 
Join Date: Sep 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Simple Problem

I'm sure this is a really simple problem, but I'm quite new to Java and I can't figure it out, and am now having trouble thinking of a way of describing it...

OK say you have an application which is a book shop, in the main class file you launch from it it creates a new booklist instance to store all the books in the store.

But now then you want to do some work on this instance but from a different class which wasn't the once that called the construction, ie how can an instance be made global?

Hope this makes sense, I see there inheritance but does this provide access to the current instances/variables or just the methods?

cheers,

David

 
Old December 19th, 2003, 11:56 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 175
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Instantite an object of the type of class that you want to call and then pass to it's constructor, the reference of the new BookList.

// incomplete code snippet
BookList list = new BookList();
BookListUser = new BookListUser(list);

Cheers

Martyn
 
Old February 5th, 2004, 09:05 PM
Authorized User
 
Join Date: Feb 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your soloution of your problem depends on many things. Is the modifying object another (model)object, or a GUI object/class. The simplest way to do it is to have a class to that call the construction as you say, and that the same class sends your problem class ( maybe through the constructure ) to the working class. But maybe your problem can be solved through the MVC sofware pattern. Maybe you need an Observer? It's difficult to know with litle information






Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple != problem akentanaka XSLT 3 October 13th, 2008 11:54 PM
A Simple Problem paole Wrox Book Feedback 7 July 23rd, 2007 08:55 PM
Simple Problem Little Shell XML 2 June 5th, 2006 03:30 PM
Simple problem rsa3des Classic ASP Basics 4 August 8th, 2005 06:14 PM
a simple problem aquarius XSLT 1 February 27th, 2004 06:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.