LayoutDemo - /* This applet demonstrates various layout...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* This applet demonstrates various layout managers. The applet itself uses a border layout with a panel in the center, a "Choice" menu to the North, and a Label to the south. The center panel uses a CardLayout. Each card in the card layout contains a number of buttons and uses a different layout manager. The "Choice" menu is used to select among these cards. The Label reports events as they occur. */ * import java.awt.*; import java.awt.event.*; import java.applet.Applet; i public class LayoutDemo extends Applet implements ItemListener, ActionListener { p CardLayout cards; // the layout manager for the center panel Panel cardPanel; // the center panel Label message; // a message shown at the bottom of the applet public void init() { setBackground(; Choice panelChoice = new Choice(); // Set up the "Choice" menu panelChoice.setBackground(Color.white); panelChoice.addItemListener(this); panelChoice.add("FlowLayout"); // Add in the names of the cards. panelChoice.add("FlowLayout with Big Hgap"); panelChoice.add("BorderLayout"); panelChoice.add("GridLayout(3,2)"); panelChoice.add("GridLayout(1,0)"); panelChoice.add("GridLayout(0,1)"); message = new Label("Layout Demo", Label.CENTER);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/15/2010 for the course CSC 115 taught by Professor Jackson during the Spring '09 term at University of Victoria.

Page1 / 3

LayoutDemo - /* This applet demonstrates various layout...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online