您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Display.java 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. Copyright (c) Xerox Corporation 1998-2002. All rights reserved.
  3. Use and copying of this software and preparation of derivative works based
  4. upon this software are permitted. Any distribution of this software or
  5. derivative works must comply with all applicable United States export control
  6. laws.
  7. This software is made available AS IS, and Xerox Corporation makes no warranty
  8. about the software, its performance or its conformity to any specification.
  9. */
  10. package observer;
  11. import java.awt.Frame;
  12. import java.awt.Panel;
  13. import java.awt.Container;
  14. import java.awt.Component;
  15. import java.awt.event.WindowAdapter;
  16. import java.awt.event.WindowEvent;
  17. import java.awt.BorderLayout;
  18. /*
  19. * Display is the container class that holds all the views of the
  20. * colored number.
  21. * In this demo, it holds buttons.
  22. */
  23. class Display extends Panel {
  24. protected Frame frame = new Frame("Subject/Observer Demo");
  25. Display() {
  26. frame.addWindowListener(new WindowAdapter() {
  27. public void windowClosing(WindowEvent e) {System.exit(0);}
  28. });
  29. frame.add(this, BorderLayout.CENTER);
  30. frame.pack();
  31. frame.setVisible(true);
  32. }
  33. void addToFrame(Component c) {
  34. add(c);
  35. frame.pack();
  36. }
  37. }