Solved

JTabbedPane problem

Posted on 2004-04-26
8
359 Views
Last Modified: 2012-05-04
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
Comment
Question by:abstractionz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 92

Expert Comment

by:objects
ID: 10923343
define distorted
0
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 10923357
> 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
 

Author Comment

by:abstractionz
ID: 10923477
members.aol.com/abstractionz/images/tabs.jpg

that's a screenshot of what is happening.  
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 92

Expert Comment

by:objects
ID: 10923502
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
 

Author Comment

by:abstractionz
ID: 10923515
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
 
LVL 92

Expert Comment

by:objects
ID: 10923540
works fine here
win2k, 1.4
0
 

Author Comment

by:abstractionz
ID: 10923545
strange.  i am running winxp pro sp1, 1.4
0
 

Author Comment

by:abstractionz
ID: 10925987
anybody else have this problem?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question