SVEmptyMenuItem.java 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2007 Google Inc. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License"); You may not
  4. // use this file except in compliance with the License. You may obtain a copy of
  5. // the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
  6. // applicable law or agreed to in writing, software distributed under the
  7. // License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
  8. // OF ANY KIND, either express or implied. See the License for the specific
  9. // language governing permissions and limitations under the License.
  10. package com.google.scrollview.ui;
  11. /**
  12. * A MenuListItem is any sort of menu entry. This can either be within a popup
  13. * menu or within a menubar. It can either be a submenu (only name and
  14. * command-id) or a name with an associated value and possibly description. They
  15. * can also have new entries added (if they are submenus).
  16. *
  17. * @author wanke@google.com
  18. */
  19. import com.google.scrollview.ScrollView;
  20. import com.google.scrollview.events.SVEvent;
  21. import com.google.scrollview.events.SVEventType;
  22. import javax.swing.JMenuItem;
  23. /**
  24. * Constructs a new menulistitem which just has an ID and a name attached to
  25. * it. In this case, we will have to ask for the value of the item and its
  26. * description if it gets called.
  27. */
  28. class SVEmptyMenuItem extends SVAbstractMenuItem {
  29. SVEmptyMenuItem(int id, String name) {
  30. super(id, name, new JMenuItem(name));
  31. }
  32. /** What to do when user clicks on this item. */
  33. @Override
  34. public void performAction(SVWindow window, SVEventType eventType) {
  35. // Send an event indicating that someone clicked on an entry.
  36. // Value will be null here.
  37. SVEvent svme =
  38. new SVEvent(eventType, window, id, getValue());
  39. ScrollView.addMessage(svme);
  40. }
  41. }