Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_java thread: Adv Real World Swing (Dynamics) ??


Message #1 by "Kharsim Al Mosawi" <Kharsim@Y...> on Wed, 20 Jun 2001 04:21:47
Kharsim Al Mosawi wrote:

> Im pretty new to Swing, was able to master most of its interface
> components, what puzzled me was how to Create components from a Real World
> Programs view...
>
> Take the JTree for example, its pretty easy to create one before
> compiling, but how do i create it, then dynamically changed and make
> updates to it during run time or even saving those changes and reloading
> them next time the program starts.
>
> Ive looked through a fair amount of books, all seem to cover Basics as
> creating them but not the Above "Run Time Manipulation" of such
> components. Played around with storing variables in a txt file and loading
> them, but it doesn?t seem efficient...
>
> I'd appreciate it if somebody cleared the issue up a bit, or even point me
> towards a learning source. Thx

Hi,

Definitely, you can dynamically control the JTree content. The first thing
you need to know that
new JDK2 swing uses model-view-control separation model. The JTree itself is
just a
GUI view,  the actual data is maitained by its model. You can manipulate the
model to change
data and then fire a proper change event to notif the GUI tree to refresh its
contents. In such case,
you even don't have to delete GUI tree but you are able to change its model
such as replacing a new
model or changing a part data of the existing model. I think the tutorial on
www.javasoft.com may
gives a few tips and hints. You even can extend the jtree to have drag-drop
behavour. Have a try.


Chris


  Return to Index