• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • Last Modified:

JTabbedPane problem

I have a JFrame with a menubar and a JTabbedPane.  The user specifies how many tabs there will be and what they will be named, and then the tabs are created, each tab containing a JTextField and a JTable.  However, the tabs look distorted.  Any idea what is happening?  Why the text and graphics look distorted?  I'm using addTab to create the tabs.  Also, lets say the user creates n tabs, how can I access JTable n?  Thanks.
0
abstractionz
Asked:
abstractionz
  • 4
  • 4
1 Solution
 
objectsCommented:
define distorted
0
 
objectsCommented:
> Also, lets say the user creates n tabs, how can I access JTable n?

use a wrapper panel for you tabs

public class TabPanel extends JPanel
{
   public JTable getTable()
   ...

And add instances of TabPanel to your tabbed pane, and use getComponentAt() method to access them
0
 
abstractionzAuthor Commented:
members.aol.com/abstractionz/images/tabs.jpg

that's a screenshot of what is happening.  
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
objectsCommented:
that doesn't look to healthy does it.
can u post your code.
or better a still a working example that I can run here
0
 
abstractionzAuthor Commented:
It's code taken straight from the book 'Java Swing' by O'Reilly:

public class SimpleTab extends JFrame {
      JTabbedPane jtp;
      
      public SimpleTab(){
            super("JTabbedPane");
            setSize(200,200);
            Container contents = getContentPane();
            jtp = new JTabbedPane();
            jtp.addTab("Tab1", new JLabel("This is Tab One"));
            jtp.addTab("Tab2", new JButton("This is Tab Two"));
            jtp.addTab("Tab3", new JCheckBox("This is Tab Three"));
            contents.add(jtp);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            setVisible(true);
      }
      public static void main(String[] args) {
            new SimpleTab();
      }
}
0
 
objectsCommented:
works fine here
win2k, 1.4
0
 
abstractionzAuthor Commented:
strange.  i am running winxp pro sp1, 1.4
0
 
abstractionzAuthor Commented:
anybody else have this problem?
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now