Java支持多少种侦听器?

时间:2021-12-23 21:01:42

How many kinds of listeners supported in Java? I am a newbie and just know there is the ActionListener, which listens the button clicked. I want to a JLabel in a JFrame to update with time. So, is there any listeners for time to update the label in a frame?

Java支持多少种侦听器?我是一个新手,只知道有一个ActionListener,它监听点击的按钮。我希望JFrame中的JLabel能够随时更新。那么,是否有任何听众有时间更新框架中的标签?

2 个解决方案

#1


1  

How many kinds of listeners supported in Java?

Java支持多少种侦听器?

The Java 8 Standard API supports these:

Java 8 Standard API支持以下内容:

  1. ActionListener
  2. AdjustmentListener
  3. AncestorListener
  4. AWTEventListener
  5. BasicButtonListener
  6. BeanContextMembershipListener
  7. BeanContextServiceRevokedListener
  8. BeanContextServicesListener
  9. CaretListener
  10. CellEditorListener
  11. ChangeListener
  12. ComponentListener
  13. ConnectionEventListener
  14. ContainerListener
  15. ControllerEventListener
  16. DiagnosticListener
  17. DocumentListener
  18. DragGestureListener
  19. DragSourceListener
  20. DragSourceMotionListener
  21. DropTargetListener
  22. ErrorListener
  23. EventListener
  24. EventListener
  25. ExceptionListener
  26. FlavorListener
  27. FocusListener
  28. HandshakeCompletedListener
  29. HierarchyBoundsListener
  30. HierarchyListener
  31. HyperlinkListener
  32. IIOReadProgressListener
  33. IIOReadUpdateListener
  34. IIOReadWarningListener
  35. IIOWriteProgressListener
  36. IIOWriteWarningListener
  37. InputMethodListener
  38. InternalFrameListener
  39. ItemListener
  40. KeyListener
  41. LineListener
  42. ListDataListener
  43. ListSelectionListener
  44. Marshaller.Listener
  45. MenuDragMouseListener
  46. MenuKeyListener
  47. MenuListener
  48. MetaEventListener
  49. MouseInputListener
  50. MouseListener
  51. MouseMotionListener
  52. MouseWheelListener
  53. NamespaceChangeListener
  54. NamingListener
  55. NodeChangeListener
  56. NotificationListener
  57. ObjectChangeListener
  58. PopupMenuListener
  59. PreferenceChangeListener
  60. PrintJobAttributeListener
  61. PrintJobListener
  62. PrintServiceAttributeListener
  63. PropertyChangeListener
  64. RowSetListener
  65. RowSorterListener
  66. SSLSessionBindingListener
  67. StatementEventListener
  68. TableColumnModelListener
  69. TableModelListener
  70. TextListener
  71. TreeExpansionListener
  72. TreeModelListener
  73. TreeSelectionListener
  74. TreeWillExpandListener
  75. UndoableEditListener
  76. Unmarshaller.Listener
  77. UnsolicitedNotificationListener
  78. VetoableChangeListener
  79. WindowFocusListener
  80. WindowListener
  81. WindowStateListener

So, is there any listeners for time to update the label in a frame?

那么,是否有任何听众有时间更新框架中的标签?

As mentioned by MadProgrammer, an ActionListener used inside a Swing based Timer should do the job.

正如MadProgrammer所提到的,在基于Swing的Timer中使用的ActionListener应该可以胜任。

#2


0  

Listeners

  • ActionListener

    This interface is used for receiving the action events. 2

    此接口用于接收动作事件。 2

  • ComponentListener

    This interface is used for receiving the component events. 3

    此接口用于接收组件事件。 3

  • ItemListener

    This interface is used for receiving the item events. 4

    此接口用于接收项目事件。 4

  • KeyListener

    This interface is used for receiving the key events. 5

    该接口用于接收密钥事件。五

  • MouseListener

    This interface is used for receiving the mouse events. 6

    该接口用于接收鼠标事件。 6

  • TextListener

    This interface is used for receiving the text events. 7

    此接口用于接收文本事件。 7

  • WindowListener

    This interface is used for receiving the window events. 8

    该接口用于接收窗口事件。 8

  • AdjustmentListener

    This interface is used for receiving the adjusmtent events. 9

    该接口用于接收adjusmtent事件。 9

  • ContainerListener

    This interface is used for receiving the container events. 10

    此接口用于接收容器事件。 10

  • MouseMotionListener

    This interface is used for receiving the mouse motion events. 11

    该接口用于接收鼠标运动事件。 11

  • FocusListener

    This interface is used for receiving the focus events.

    该接口用于接收焦点事件。

For more info Show this, this too

更多信息显示这个,这也是

#1


1  

How many kinds of listeners supported in Java?

Java支持多少种侦听器?

The Java 8 Standard API supports these:

Java 8 Standard API支持以下内容:

  1. ActionListener
  2. AdjustmentListener
  3. AncestorListener
  4. AWTEventListener
  5. BasicButtonListener
  6. BeanContextMembershipListener
  7. BeanContextServiceRevokedListener
  8. BeanContextServicesListener
  9. CaretListener
  10. CellEditorListener
  11. ChangeListener
  12. ComponentListener
  13. ConnectionEventListener
  14. ContainerListener
  15. ControllerEventListener
  16. DiagnosticListener
  17. DocumentListener
  18. DragGestureListener
  19. DragSourceListener
  20. DragSourceMotionListener
  21. DropTargetListener
  22. ErrorListener
  23. EventListener
  24. EventListener
  25. ExceptionListener
  26. FlavorListener
  27. FocusListener
  28. HandshakeCompletedListener
  29. HierarchyBoundsListener
  30. HierarchyListener
  31. HyperlinkListener
  32. IIOReadProgressListener
  33. IIOReadUpdateListener
  34. IIOReadWarningListener
  35. IIOWriteProgressListener
  36. IIOWriteWarningListener
  37. InputMethodListener
  38. InternalFrameListener
  39. ItemListener
  40. KeyListener
  41. LineListener
  42. ListDataListener
  43. ListSelectionListener
  44. Marshaller.Listener
  45. MenuDragMouseListener
  46. MenuKeyListener
  47. MenuListener
  48. MetaEventListener
  49. MouseInputListener
  50. MouseListener
  51. MouseMotionListener
  52. MouseWheelListener
  53. NamespaceChangeListener
  54. NamingListener
  55. NodeChangeListener
  56. NotificationListener
  57. ObjectChangeListener
  58. PopupMenuListener
  59. PreferenceChangeListener
  60. PrintJobAttributeListener
  61. PrintJobListener
  62. PrintServiceAttributeListener
  63. PropertyChangeListener
  64. RowSetListener
  65. RowSorterListener
  66. SSLSessionBindingListener
  67. StatementEventListener
  68. TableColumnModelListener
  69. TableModelListener
  70. TextListener
  71. TreeExpansionListener
  72. TreeModelListener
  73. TreeSelectionListener
  74. TreeWillExpandListener
  75. UndoableEditListener
  76. Unmarshaller.Listener
  77. UnsolicitedNotificationListener
  78. VetoableChangeListener
  79. WindowFocusListener
  80. WindowListener
  81. WindowStateListener

So, is there any listeners for time to update the label in a frame?

那么,是否有任何听众有时间更新框架中的标签?

As mentioned by MadProgrammer, an ActionListener used inside a Swing based Timer should do the job.

正如MadProgrammer所提到的,在基于Swing的Timer中使用的ActionListener应该可以胜任。

#2


0  

Listeners

  • ActionListener

    This interface is used for receiving the action events. 2

    此接口用于接收动作事件。 2

  • ComponentListener

    This interface is used for receiving the component events. 3

    此接口用于接收组件事件。 3

  • ItemListener

    This interface is used for receiving the item events. 4

    此接口用于接收项目事件。 4

  • KeyListener

    This interface is used for receiving the key events. 5

    该接口用于接收密钥事件。五

  • MouseListener

    This interface is used for receiving the mouse events. 6

    该接口用于接收鼠标事件。 6

  • TextListener

    This interface is used for receiving the text events. 7

    此接口用于接收文本事件。 7

  • WindowListener

    This interface is used for receiving the window events. 8

    该接口用于接收窗口事件。 8

  • AdjustmentListener

    This interface is used for receiving the adjusmtent events. 9

    该接口用于接收adjusmtent事件。 9

  • ContainerListener

    This interface is used for receiving the container events. 10

    此接口用于接收容器事件。 10

  • MouseMotionListener

    This interface is used for receiving the mouse motion events. 11

    该接口用于接收鼠标运动事件。 11

  • FocusListener

    This interface is used for receiving the focus events.

    该接口用于接收焦点事件。

For more info Show this, this too

更多信息显示这个,这也是