Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import javax.swing.InputMap;
import javax.swing.JComponent;

public class Main {
    public static void uninstallInputMap(JComponent c, InputMap map, int condition) {
        if (map == null) {
            return;
        }

        InputMap firstMap = c.getInputMap(condition);
        InputMap parent = firstMap;
        InputMap child = null;
        InputMap 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.setInputMap(condition, newMap);
        }
    }
}