1. /*
  2. * @(#)Panel.java 1.24 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.awt;
  8. import java.awt.peer.PanelPeer;
  9. /**
  10. * <code>Panel</code> is the simplest container class. A panel
  11. * provides space in which an application can attach any other
  12. * component, including other panels.
  13. * <p>
  14. * The default layout manager for a panel is the
  15. * <code>FlowLayout</code> layout manager.
  16. *
  17. * @version 1.24, 11/29/01
  18. * @author Sami Shaio
  19. * @see java.awt.FlowLayout
  20. * @since JDK1.0
  21. */
  22. public class Panel extends Container {
  23. private static final String base = "panel";
  24. private static int nameCounter = 0;
  25. /*
  26. * JDK 1.1 serialVersionUID
  27. */
  28. private static final long serialVersionUID = -2728009084054400034L;
  29. /**
  30. * Creates a new panel using the default layout manager.
  31. * The default layout manager for all panels is the
  32. * <code>FlowLayout</code> class.
  33. */
  34. public Panel() {
  35. this(new FlowLayout());
  36. }
  37. /**
  38. * Creates a new panel with the specified layout manager.
  39. * @param layout the layout manager for this panel.
  40. * @since JDK1.1
  41. */
  42. public Panel(LayoutManager layout) {
  43. setLayout(layout);
  44. }
  45. /**
  46. * Construct a name for this component. Called by getName() when the
  47. * name is null.
  48. */
  49. String constructComponentName() {
  50. synchronized (getClass()) {
  51. return base + nameCounter++;
  52. }
  53. }
  54. /**
  55. * Creates the Panel's peer. The peer allows you to modify the
  56. * appearance of the panel without changing its functionality.
  57. */
  58. public void addNotify() {
  59. synchronized (getTreeLock()) {
  60. if (peer == null)
  61. peer = getToolkit().createPanel(this);
  62. super.addNotify();
  63. }
  64. }
  65. }