get Current Decorations For Swing Action - Java Swing

Java examples for Swing:Action

Description

get Current Decorations For Swing Action

Demo Code


//package com.java2s;

import java.util.Map;
import java.util.WeakHashMap;

import javax.swing.Action;

public class Main {
    public static String[] DECORATION_KEYS;

    public static Map getCurrentDecorationsFor(Action action) {
        Map<String, Object> decorations = new WeakHashMap<String, Object>();
        decorations.put("action", action);
        for (int i = 0; i < DECORATION_KEYS.length; i++) {
            Object value = action.getValue(DECORATION_KEYS[i]);
            if (value != null) {
                decorations.put(DECORATION_KEYS[i], value);
            }//from   www . java 2s.co  m
        }
        return decorations;
    }

    public static Map[] getCurrentDecorationsFor(Action[] actions) {
        Map[] decorations = new Map[actions.length];
        for (int i = 0; i < actions.length; i++) {
            decorations[i] = getCurrentDecorationsFor(actions[i]);
        }
        return decorations;
    }
}

Related Tutorials