Here you can find the source of removeDocumentListeners(JTextComponent component)
Parameter | Description |
---|---|
component | a parameter |
public static void removeDocumentListeners(JTextComponent component)
//package com.java2s; /******************************************************************************* * Copyright (c) 2012 Firestar Software, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/* w w w. java2 s. c o m*/ * Firestar Software, Inc. - initial API and implementation * * Author: * Sally Conway * *******************************************************************************/ import javax.swing.event.DocumentListener; import javax.swing.event.UndoableEditListener; import javax.swing.text.AbstractDocument; import javax.swing.text.Document; import javax.swing.text.JTextComponent; public class Main { /** Remove all document listeners from this text component * @param component */ public static void removeDocumentListeners(JTextComponent component) { Document document = component.getDocument(); if (document instanceof AbstractDocument) { DocumentListener[] dls = ((AbstractDocument) document).getDocumentListeners(); for (int i = 0; i < dls.length; i++) { ((AbstractDocument) document).removeDocumentListener(dls[i]); } UndoableEditListener[] uels = ((AbstractDocument) document).getUndoableEditListeners(); for (int i = 0; i < uels.length; i++) { ((AbstractDocument) document).removeUndoableEditListener(uels[i]); } } } }