Solved

JSplitPane

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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 last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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.

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

17 Experts available now in Live!

Get 1:1 Help Now