Solved

JTabbedPane problem

Posted on 2004-04-26
8
356 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
  • 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
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

770 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