• Post Reply Bookmark Topic Watch Topic
  • New Topic

JOptionPane affecting JTabbedPane  RSS feed

 
Ben Wong
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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

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