🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #704

Re: regaining functionality from save file

#704
From: Alan Shiers
Date: Wed, 29 Dec 2004 16:23
50 lines
2794 bytes
Ok, things are starting to fall into place a little better.  One other
functionality however is not being reinstated when I open a saved file. I
make use of Drag 'n Drop in my application.  Several instances of an object
that is getting saved is a class I named TargetPanel which extends JPanel
implements Serializable and in its constructor it calls a method called
installDnD().

installDnD() and associated inner class TargetPanelContainerListener are as
follows:

public class TargetPanel extends JPanel implements Serializable
{
    public TargetPanel()
   {
      ...
      installDnD();
   }
   ...
   ...
   protected void installDnD()
  {
    //setDragEnabled(true);
    setTransferHandler(new ComponentTransferHandler());
    addContainerListener(new TargetPanelContainerListener());
  }

  class TargetPanelContainerListener extends ContainerAdapter implements
Serializable
  {
     public void componentAdded(ContainerEvent e)
     {  System.out.println("entering componentAdded");
       if(e.getChild() instanceof InputTool)
       {
         //Make sure every InputTool knows what row its in
         InputTool comp = (InputTool)e.getChild();
         comp.setItemNumber(TargetPanel.this.getRowNumber());
         //Set the isDirty flag
         if(DocumentPanel.isDirty == false)
            DocumentPanel.isDirty = true;
       }
     }
  }

When I open a saved file, I wound up manually iterating over every instance
of the TargetPanel(s) and calling installDnD() on each one in order to
reinstate each TargetPanel as being a viable drop target for transferable
components.  Is this usual? Wouldn't this functionality be saved. I
shouldn't have to do that should I?

Alan
Technical Details
Message-ID: <41d2db25$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <41d0409e$1@newsgroups.borland.com> <xn0drjdwa6iyqr9003@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,24838fa202265eb4
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Alan Shiers" <ashiers@hfx.eastlink.ca>
Newsgroups: borland.public.jbuilder.java.swing
References: <41d0409e$1@newsgroups.borland.com> <xn0drjdwa6iyqr9003@newsgroups.borland.com>
Subject: Re: regaining functionality from save file
Date: Wed, 29 Dec 2004 12:23:51 -0400
Lines: 52
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 24.222.101.2
Message-ID: <41d2db25$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1104337701 24.222.101.2 (29 Dec 2004 08:28:21 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail