Determining the priorLabel in the Java AWT/Swing Technology Domain

To determine the priorLabel in the Java AWT/Swing technology domain, all labels and groups in the same window as the target control are considered. The decision is then made based upon the following criteria:
  • Only labels either above or to the left of the control, and groups surrounding the control, are considered as candidates for a priorLabel.
  • If a parent of the control is a JViewPort or a ScrollPane, the algorithm works as if the parent is the window that contains the control, and nothing outside is considered relevant.
  • In the simplest case, the label closest to the control is used as the priorLabel.
  • If two labels have the same distance to the control, and one is to the left and the other above the control, the left one is preferred.
  • If no label is eligible, the caption of the closest group is used.