If you want to intercept tabbed panel selection, I'd implement a custom 
SingleSelectionModel and assign that to the JTabbedPane object in question.  
Swing's philosophy is that behavior is controlled separately from the look of 
widgets (the MVC principle).  Hence, you have model interfaces, which are 
separate from the UI interfaces.  I've never tried overriding a JTabbedPane's 
model and the API docs aren't quite clear on what happens if the 
SingleSelectionModel refuses to respond to setSelectionIndex(int), but my gut 
tells me it'll work, since JTabbedPane is probably listening for the model 
object to fire a ChangeEvent to begin changing the tab.

Alexey
2001 Honda CBR600F4i (CCS)
1992 Kawasaki EX500
http://azinger.blogspot.com
http://bsheet.sourceforge.net
http://wcollage.sourceforge.net



--- On Sun, 10/5/08, rich shar <[EMAIL PROTECTED]> wrote:

> From: rich shar <[EMAIL PROTECTED]>
> Subject: [The Java Posse] swing re-paint
> To: "The Java Posse" <[email protected]>
> Date: Sunday, October 5, 2008, 11:58 AM
> I've been listening to the java posse for the last two
> years, but this
> is my first post, so please inform me if i break any
> protocols.
> 
> i'm trying to understand the best way to manage some
> effects in a
> tabbed UI.
> 
> I have 3 JPanels that i added to a JTabbedPane.
> When i move from one tab to the other i need to ensure that
> user saved
> their changes and if not inform them with a dialog.
> 
> I used the AncestorListener#ancestorRemoved call to
> determine when the
> user moved to another tab.
> And in my implementation i create a dialog.
> 
> But when the dialog comes up the user sees the JPanel that
> they are
> going to, not the JPanel that they came from.  I tried to
> step through
> it and it looks like the dialog dispatches all the events
> before
> showing.
> 
> two questions:
> 1. Is there a better listener to use?
> 2. How can i keep the current panel visible until after the
> user
> confirms using the dialog.
> 
> any help greatly appreciated :)
> 
> 

      

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to