Solved

JSplitPane

Posted on 1998-11-04
1
195 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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 different types of Android Layout and some basics of an Android App.
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 video teaches viewers about errors in exception handling.

726 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