Solved

JTabbedPane problem

Posted on 2004-04-26
8
354 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now