• Post Reply Bookmark Topic Watch Topic
  • New Topic

PropertyChangeListener - FocusListener - which one do I use  RSS feed

 
Kieran Murray
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ranchers,

I have two questions. They are related I think , but I am not sure so I put the other question as a separate topic

I have an application which can open and save files.

However, when I open up a second file in a new Window and even if I click on the first Window it is only the second file that is saved. How do I make sure the right file is saved.

Kind regards,

Kieran
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when I open up a second file in a new Window and even if I click on the first Window it is only the second file that is saved. How do I make sure the right file is saved
The part of the application that is doing the opening/saving will need to keep track of each window and the file that is loaded into it. Perhaps you are using a single reference that is reset with each new window/file opened or having trouble identifying them via your listener events.
 
Kieran Murray
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Craig,

I think I understand what you mean.
This is the code that opens up a new Shape Drawing canvas.



I am just stuck. How do I get at the first instance of the Drawing object when I have instantiated multiple copies. I might open up three or four files for example.

How do I keep track - some sort of count which I set in the Drawing object.

Thanks.

Kieran

[RP]Improbed code layout so it doesn't mess up the forum layout.[/RP]
[ August 17, 2008: Message edited by: Rob Prime ]
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try saving a reference to each instance in a Collection.
In pseudo–java it might go something like this:
 
Kieran Murray
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Craig,

Thank you very much for your help on this and on Affine Transforms.
I used your suggestion.

I had to pass a count to ShapeDraw so that I had a reference for each Drawing object and then register a WindowListener on the Drawing object and then use windowFocusGained to pass back the number to the main Frame and then use this number to get the correct instantiation of ShapeDraw from the ArrayList.

Kind regards,

Kieran
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!