Solved

JSplitPane

Posted on 1998-11-04
1
194 Views
Last Modified: 2010-03-30
I've written a program which will generate a split window:

public class AVIS extends JSplitPane
{
  static      JFrame frame;
  private      JTextField      tf=new JTextField(19);

  public AVIS()
  {
    super(HORIZONTAL_SPLIT);
   
    JScrollPane listScrollPane = new JScrollPane();

           JTabbedPane      tabbedPane=new JTabbedPane();
            tabbedPane.addTab("Nr.1", tf);
            tabbedPane.addTab("Nr.2", tf);         setLeftComponent(listScrollPane);                  setRightComponent(tabbedPane);
   setDividerLocation(150);
   setDividerSize(10);
   setPreferredSize(new Dimension(400, 200));
  }

  public static void main(String s[])
  {
    WindowListener l = new WindowAdapter()
    {
      public void windowClosing(WindowEvent e)       {System.exit(0);
    }
  };
  frame = new JFrame("AVIS");
  frame.addWindowListener(l);          frame.getContentPane().add("Center", new AVIS());          frame.pack();
  frame.setVisible(true);
  }
};

But as I start the program, one can just see a tab "Nr.1", not two tabs "Nr.1" and "Nr.2".
 Why?
0
Comment
Question by:chenwei
[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
1 Comment
 
LVL 5

Accepted Solution

by:
msmolyak earned 50 total points
ID: 1226933
You normally add a container such as JPanel in the call to addTab(). Try creating two panels and adding each to the corresponding tab, that should fix it. Later you can add the text field (why are you adding the same field to both panels, by the way?) to the panels.
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Chrome and Firefox Java 5 88
Java syntax, or is it Selenium 6 59
Notify sent to other threads in Java 9 54
netbeans can not run self signed app 8 37
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

732 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