All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.valkyriercp.component.SkipComponentsFocusTraversalPolicy Maven / Gradle / Ivy

There is a newer version: 1.3
Show newest version
package org.valkyriercp.component;

import javax.swing.*;
import javax.swing.text.JTextComponent;
import java.awt.*;
import java.util.List;

public class SkipComponentsFocusTraversalPolicy extends LayoutFocusTraversalPolicy
{
    List componentsToSkip;

    public static final SkipComponentsFocusTraversalPolicy skipJTextComponentTraversalPolicy = new SkipComponentsFocusTraversalPolicy();

    public SkipComponentsFocusTraversalPolicy()
    {}

    public SkipComponentsFocusTraversalPolicy(List componentsToSkip)
    {
        this.componentsToSkip = componentsToSkip;
    }

    @Override
    protected boolean accept(Component aComponent)
    {
        if( !super.accept(aComponent))
            return false;

        if (aComponent instanceof JTextComponent && ((JTextComponent)aComponent).isEditable() == false)
            return false;

        if (componentsToSkip != null)
        {
            for (JComponent component : componentsToSkip)
            {
                if (component == aComponent || component.isAncestorOf(aComponent))
                    return false;
            }
        }
        return true;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy