Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

JSplitPane

Posted on 1998-11-04
1
Medium Priority
?
198 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 100 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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 tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

609 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