• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

JOptionPane affecting JTabbedPane

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am using a JTabbedPane with 4 different tabs displaying a form on each.
I have a button below the JTabbedPane that when pressed checks if all the required fields have been entered. If not then i use a JOptionPane to notify the user.

The problem is when the user clicks "OK" the JTabbedPane disappears and the screen is left with the contents of the first tab.

Anyone know what I am doing wrong?
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
post a small compilable program that demonstrates the behaviour

just a frame, a JTabbedPane with 4 tabs (each holding just a JPanel),
the button, and the code that dislays the JOptionPane
 
Ben Wong
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem is, each panel has its own class that extends JPanel. The JButton listener checks if the relevant fields have been complete on each JPanel by calling a method to each class.

I've tried relocating the JOptionPane.showMessageDialog() method to each of the JPanel classes instead of the JTabbedPane class but the same thing happens: the JTabbedPane disappears when the "OK" button is pressed.
[ April 05, 2006: Message edited by: Ben Wong ]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, lets do this in reverse.

here's a simple example of your description - add the code to make it disappear

 
What are you saying? I thought you said that Santa gave you that. And this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic