Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import javax.swing.ActionMap;

import javax.swing.JComponent;

public class Main {
    public static void uninstallActionMap(JComponent c, ActionMap map) {
        if (map == null) {
            return;
        }

        ActionMap firstMap = c.getActionMap();
        ActionMap parent = firstMap;
        ActionMap child = null;
        ActionMap newMap = null;
        while (parent != null) {
            if (parent == map) {
                if (child != null) {
                    child.setParent(parent.getParent());
                    child = parent;
                } else {
                    newMap = parent.getParent();
                }
            } else {
                child = parent;
            }
            parent = parent.getParent();
        }

        if (newMap != null) {
            c.setActionMap(newMap);
        }
    }
}