Example usage for javax.accessibility AccessibleContext getAccessibleRelationSet

List of usage examples for javax.accessibility AccessibleContext getAccessibleRelationSet

Introduction

In this page you can find the example usage for javax.accessibility AccessibleContext getAccessibleRelationSet.

Prototype

public AccessibleRelationSet getAccessibleRelationSet() 

Source Link

Document

Gets the AccessibleRelationSet associated with an object.

Usage

From source file:MainClass.java

void dumpConnectedInfo(AccessibleContext ac) {
    AccessibleRelationSet ars = ac.getAccessibleRelationSet();

    AccessibleRelation ar = null;

    if (ars != null)
        ar = ars.get("connector");

    if (ar != null) {
        Object[] o = ar.getTarget();
        JComponent jc = (JComponent) o[0];
        System.out.println("Label connected to: " + jc.getAccessibleContext().getAccessibleName());
        return;/*from w w w .  ja v a2s.c  o m*/
    }
    int nChildren = ac.getAccessibleChildrenCount();
    for (int i = 0; i < nChildren; i++)
        dumpConnectedInfo(ac.getAccessibleChild(i).getAccessibleContext());
}

From source file:MainClass.java

MainClass() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel p = new JPanel();
    p.setPreferredSize(new Dimension(300, 50));
    JLabel jl = new JLabel("Name:");
    p.add(jl);/*from   ww  w  . jav a  2 s  . c o m*/
    JTextField jtf = new JTextField(20);
    jtf.getAccessibleContext().setAccessibleName("Name-entry");
    p.add(jtf);

    AccessibleRelation ar = new AccessibleRelation("connector", jtf);

    AccessibleContext ac = jl.getAccessibleContext();
    ac.getAccessibleRelationSet().add(ar);

    getContentPane().add(p);

    pack();
    setVisible(true);
}