• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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.
 
You will always be treated with dignity. Now, strip naked, get on the probulator and hold this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic