• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Prevent tab movement in JTabbedPane

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings, I have an interesting if not somewhat non-standard problem with JTabbedPane. I have a JTabbedPane with 5 tabs that the user can select. However, on each of the tabs, I'd like for the user to hit the SAVE button (or CANCEL changes button) before s/he is allowed to move to another tab. Therefore, what I'd like to do is intercept the user's movement when s/he attempts to move to a new tab, determine if there are any changes on the current tab, and if so, present a dialog box asking the user if they would like to save changes before moving to the next tab. This will give the user the chance to save the changes and move on to the next tab, cancel the changes and move on to the next tab, or cancel the movement to the next tab and just stay on the current tab.
Just wondered if anyone has had a need/solution for this type of situation.
Thanks
CR
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would just set a FocusListener on each tab and when the focus changes you could pull up a JDialog or JOptionPane requesting the save. Now, I am not good at listeners. But thought the idea might be a good start for you.
 
reply
    Bookmark Topic Watch Topic
  • New Topic