Package java.awt

Examples of java.awt.CardLayout


public class first implements Testlet
{

  public void test(TestHarness harness)
  {
    CardLayout layout = new CardLayout();
    Frame containerWithLayout = new Frame();
    Panel panel = new Panel();
    containerWithLayout.setLayout(layout);

    // test without a panel added - no exception should be thrown
    try
      {
        layout.first(containerWithLayout);
        harness.check(true);
      }
    catch (Exception e)
      {
        harness.check(false);
      }

    // test correct usage - with an added panel
    containerWithLayout.add(panel, "Panel");
    try
      {
        layout.first(containerWithLayout);
        harness.check(true);
      }
    catch (Exception e)
      {
        harness.check(false);
      }

    // test null behaviour - triggers NPE
    try
      {
        layout.first(null);
        harness.check(false);
      }
    catch (NullPointerException e)
      {
        harness.check(true);
      }

    // test usage with container without setLayout called
    Frame container = new Frame();
    container.add(panel);
    try
      {
        layout.first(container);
        harness.check(false);
      }
    catch (IllegalArgumentException e)
      {
        harness.check(true);
View Full Code Here


public class testMaximumLayoutSize implements Testlet
{

  public void test(TestHarness harness)
  {
    CardLayout layout = new CardLayout();
    harness.check(layout.maximumLayoutSize(null),
                  new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
   
    Frame frame = new Frame();
    harness.check(frame.getComponentCount(), 0);
    harness.check(layout.maximumLayoutSize(frame),
                  new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
  }
View Full Code Here

public class show implements Testlet
{

  public void test(TestHarness harness)
  {
    CardLayout layout = new CardLayout();
    Frame containerWithLayout = new Frame();
    Panel panel = new Panel();
    containerWithLayout.setLayout(layout);
    containerWithLayout.add(panel, "Panel");

    // test correct usage
    try
      {
        layout.show(containerWithLayout, "Panel");
        harness.check(true);
      }
    catch (Exception e)
      {
        harness.check(false);
      }

    // test with string == null
    // nothing should happen no exception
    try
      {
        layout.show(containerWithLayout, null);
        harness.check(true);
      }
    catch (Exception e)
      {
        e.printStackTrace();
        harness.check(false);
      }

    // same with unknown names
    try
      {
        layout.show(containerWithLayout, "XXXXX");
        harness.check(true);
      }
    catch (Exception e)
      {
        harness.check(false);
      }

    // same with empty strings
    try
      {
        layout.show(containerWithLayout, "");
        harness.check(true);
      }
    catch (Exception e)
      {
        harness.check(false);
      }

    // test usage with container without setLayout called
    Frame container = new Frame();
    container.add(panel);
    try
      {
        layout.show(container, "Panel");
        harness.check(false);
      }
    catch (IllegalArgumentException e)
      {
        harness.check(true);
      }
   
    // test usage with container with another CardLayout instance called
    CardLayout layout2 = new CardLayout();
    container.setLayout(layout2);
    try
      {
        layout.show(container, "Panel");
        harness.check(false);
View Full Code Here

public class testMinimumLayoutSize implements Testlet
{

  public void test(TestHarness harness)
  {
    CardLayout layout = new CardLayout();
    boolean failed = false;
    try
      {
        layout.minimumLayoutSize(null);
      }
    catch (NullPointerException e)
      {
        failed = true;
      }
View Full Code Here

import org.eclipse.core.runtime.IProgressMonitor;

public class CardLayoutAdapter extends LayoutAdapter implements ILayoutBean {
  private boolean hovered;
  public void initConainerLayout(Container container, IProgressMonitor monitor) {
    container.setLayout(new CardLayout());
  }
View Full Code Here

    return child.isVisible();
  }

  @Override
  public void showChild(Component widget) {
    CardLayout cardLayout = (CardLayout) container.getLayout();
    WidgetAdapter adapter = WidgetAdapter.getWidgetAdapter(widget);
    String name = adapter.getName();
    cardLayout.show(container, name);
    container.doLayout();
  }
View Full Code Here

  @Override
  public boolean drop(Point p) {
    WidgetAdapter parent = WidgetAdapter.getWidgetAdapter(container);
    parent.clearAllSelected();
    CardLayout layout = (CardLayout) container.getLayout();
    for (WidgetAdapter todrop : parent.getDropWidget()) {
      container.add(todrop.getParentContainer(), todrop.getName());
      layout.show(container, todrop.getName());
      todrop.setSelected(true);
    }
    parent.getRootAdapter().getWidget().validate();
    hovered = false;
    return true;
View Full Code Here

    return true;
  }

  @Override
  protected LayoutManager copyLayout(Container con) {
    CardLayout layout = (CardLayout) container.getLayout();
    CardLayout copy = new CardLayout();
    copy.setHgap(layout.getHgap());
    copy.setVgap(layout.getVgap());
    return copy;
  }
View Full Code Here

    }

    private void initGui()  {

  cardPanel = new JPanel();
  cardLayout = new CardLayout();
  cardPanel.setLayout(cardLayout);

        initLayers(cardPanel);

  setViewportView(cardPanel);
View Full Code Here

    windowCountPanel.setLayout(new BoxLayout(windowCountPanel, BoxLayout.LINE_AXIS));
    windowCountPanel.add(this.windowCountSpinner);
    windowCountPanel.add(Box.createRigidArea(new Dimension(3,0)));
    windowCountPanel.add(new JLabel("Instances"));
       
    this.windowSpinnerPanel = new JPanel(new CardLayout());
    this.windowSpinnerPanel.add(windowDurationPanel, WindowOperator.DURATION.toString());
    this.windowSpinnerPanel.add(windowCountPanel, WindowOperator.COUNT.toString());
   
       
        this.winTypeBox = new JComboBox(WindowOperator.values());
        this.winTypeBox.addItemListener(new ItemListener() {     
      @Override
      public void itemStateChanged(ItemEvent e) {
        CardLayout cl = (CardLayout)(EventWindowView.this.windowSpinnerPanel.getLayout());
          cl.show(EventWindowView.this.windowSpinnerPanel, EventWindowView.this.winTypeBox.getSelectedItem().toString());
      }
    });
        JPanel windowPanel = new JPanel();
        windowPanel.setLayout(new BoxLayout(windowPanel, BoxLayout.X_AXIS));
        windowPanel.add(this.winTypeBox);
View Full Code Here

TOP

Related Classes of java.awt.CardLayout

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.