Java Utililty Methods JTextComponent Action

List of utility methods to do JTextComponent Action

  1. HOME
  2. Java
  3. J
  4. JTextComponent Action

Description

The list of methods to do JTextComponent Action are organized into topic(s).

Method

Action getAction(JTextComponent component, String actionName)
Search the given text component's list of actions for an action with the given name.
for (Action a : component.getActions()) {
 if (actionName.equals(a.getValue(Action.NAME))) {
 return a;
return null;
T getAction(JTextComponent target, Class aClass)
Searches all actions of a JTextComponent for ab action of the given class and returns the first one that matches that class, or null if no Action is found
for (Object k : target.getActionMap().allKeys()) {
 Action a = target.getActionMap().get(k);
 if (aClass.isInstance(a)) {
 @SuppressWarnings("unchecked")
 T t = (T) a;
 return t;
return null;
void setHistoryActions(JTextComponent textComponent)
set History Actions
Document doc = textComponent.getDocument();
UndoManager undo = new UndoManager();
doc.addUndoableEditListener(new UndoableEditListener() {
 @Override
 public void undoableEditHappened(UndoableEditEvent evt) {
 undo.addEdit(evt.getEdit());
});
...

AltStyle によって変換されたページ (->オリジナル) /