package visad.tests;

import java.awt.Component;
import java.awt.Container;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.rmi.RemoteException;

import javax.swing.JFrame;
import javax.swing.JTabbedPane;

import visad.LocalDisplay;
import visad.VisADException;

/**
 * Test73 extends Test40, but places displays in tabbed pane.
 * 
 * This test is primarily to demonstrate rendering problems which become
 * obvious when user resizes a JTabbedPane that contains plots.  Every
 * plot is rendered in undefined order, even though only the currently
 * selected tab should be rerendered.
 * 
 * @author Ian Graham
 */
public class Test73 extends Test40
{

  public Test73()
  {
    super();
  }

  public Test73(String[] args) throws RemoteException, VisADException
  {
    super(args);
  }

  /*
   * Override to place displays in tabbed pane.
   */
  void setupUI(LocalDisplay[] dpys)
    throws RemoteException, VisADException
  {
    Component special = getSpecialComponent(dpys);
    if (special == null && dpys.length == 1) {
      special = dpys[0].getComponent();
    }
  
    Container content;
    JTabbedPane big_panel = new JTabbedPane();

    for (int i = 0; i < dpys.length; i++) {
      big_panel.addTab("Display " + i, dpys[i].getComponent());
    }
    content = big_panel;

    JFrame jframe = new JFrame(getFrameTitle() +
getClientServerTitle());
    jframe.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {System.exit(0);}
    });
    jframe.setContentPane(content);
    jframe.pack();
    jframe.setVisible(true);
  }

  String getFrameTitle() { return "Resizing Tabbed Java2D displays(try
resizing)"; }

  public static void main(String[] args)
    throws RemoteException, VisADException
  {
    new Test73(args);
  }

}
