jjzjj

eventListener

全部标签

java - 如何删除 SWING 组件上的监听器

有没有一种简单的方法可以从JComponent中删除所有监听器?JComponentwidget=getComponentOverScaryMethod();EventListener[]listners=widget.getListeners(EventListener.class);for(EventListenerl:listners){widget.remove*RandomListener*(l);}背景:我有一个JComponent,它的监听器数量未知(随机类型)。由于小部件应该从可见部分移除(并且不再需要),因此应该将其销毁(并且应该删除监听器)。提前致谢琼

java - 让我的 EventListeners 触发我的 @ElementCollection 属性有什么诀窍?

我已经开始处理我的JPA事件(postUpdate),当我更新实体上的属性时,它们会正确触发,映射为@ElementCollection的属性除外。这是限制吗?配置选项?这是我实体的一部分@Entity@Inheritance(strategy=InheritanceType.JOINED)publicclassPckg{@Id@GeneratedValue(strategy=GenerationType.AUTO)privateLongid;@Column(nullable=false,length=100)privateStringtitle;@ElementCollection@

java - Java 中的事件监听器

我一直在AS3中使用事件监听器,但在Java中似乎没有(图形组件除外)。令人惊讶。问题是,我如何在java中实现我自己的事件监听器?也许以前有人做过这项工作? 最佳答案 你可以定义一个Listener接口(interface):publicinterfaceEventListener{voidfireEvent(Evente);}然后在你的代码中:EventListenerlst=newEventListener(){@OverridepublicvoidfireEvent(Evente){//dowhatyouwantwithe}

java - 为什么这种泛型方法的重写适用于 1.6 而不是 1.7?

给定以下类,它覆盖了AbstractListModel的getListeners方法:importjava.util.EventListener;importjavax.swing.AbstractListModel;publicclassGenericBugextendsAbstractListModel{/***Thisisthemethodofinterest*Thisistheexactsamemethodsignaturethatispresentinthebaseclass*/@OverridepublicT[]getListeners(ClasslistenerType)

如何对EventListener实现函数

CSS:.motionContainerMenu{width:100%;height:30px;position:relative;margin:auto;margin-bottom:-7px;border:2pxsolidred}.motionTop{position:absolute;border:2pxsolidblue;background-color:red;height:10px;width:100%}html:TestoneTestTwoJavaScript:functionfocusMenu(x){x.style.borderColor="#fff";x.style.heigh

android - 如何在 android 中使用 Firebase EventListener 作为后台服务?

我正在尝试制作即使应用程序关闭也能运行的后台服务。这个服务应该监听Firebase的变化,并根据触发器启动应用程序。我不知道我是否遗漏了代码中的某些内容,或者甚至没有接近正确答案,但这是我的代码:publicclassFireBaseServiceextendsService{privateHashMapfireBaseBattery;@OverridepublicvoidonCreate(){super.onCreate();fireBaseBattery=newHashMap();finalFirebasefirebaseRef_Battery=newFirebase("theur

mongodb - Doctrine EventListener onFlush 获取旧 Document

我可以在Doctrine2的onFlusheventListerner中访问更新的文档。我想要完整的旧文档以旧状态将其存储在其他地方。publicfunctiononFlush(OnFlushEventArgs$eventArgs){$dm=$eventArgs->getDocumentManager();$uow=$dm->getUnitOfWork();foreach($uow->getScheduledDocumentUpdates()as$document){//$documentisupdateddocument//$changeSetcontainsonlynewandol

mongodb - @PrePersist EventListener spring-data-mongo 的替代品

我创建了一个Repository来自动增加@Document的id但现在我需要显式调用@Idsetter方法来设置新的ID。有没有一种方法可以使用JPA@PrePersist中的监听器来做到这一点@RepositoryinterfaceUserRepository:MongoRepository,UserRepositoryCustominterfaceUserRepositoryCustom{funsave(user:User):User}classUserRepositoryImpl(privatevalmongoOperations:MongoOperations,private

javascript - 如何为每个帖子添加一个 eventListener(不使用 jQuery)?

我正在编写一个代码,用户可以在其中获取帖子标题列表中的用户帖子。如果用户点击帖子标题,那么应该会显示一个包含更多信息的新div框。帖子是用php获取的,帖子描述将由AJAX获取。(稍后我也会用AJAX获取帖子)我的问题:只有第一个帖子标题有效,点击它,所有帖子描述都显示在1个div框中。我想我需要一个数组,但没有成功。它应该做什么:例如,通过点击标题:2,应该只显示帖子2的描述。请记住,帖子标题列表是动态的,并且是从数据库中获取的数据。这是我的代码:索引.PHPXYTitle:".$row['img_title']."";}?>document.getElementById('img_

javascript - 如何在 JavaScript 中实现 'onVisible' 事件?

是否有任何技术或一组技术可用于实现JavaScript中的onVisible“事件”?我希望我的JavaScript能够检测当用户向下滚动页面时网页中的元素(例如一段文本或图像)何时在浏览器窗口中可见。我还想要一个相应的“事件”onNotVisible,以便在浏览器窗口中曾经可见的元素不再可见时触发。如果不能用JavaScript轻松实现,是否有任何特定于浏览器的事件可以提供相同的功能? 最佳答案 我不得不自己尝试,这就是我想出的:varEventListener=function(element,callback){this._e