Very simple question:
What is a component's baseline in Java?
The documentation does not provide an answer as to what the "baseline" is, just describes its use by LayoutManagers. Yes, the answer is probably straightforward, but I don't want to play the guessing game.
From JavaDocs of FontMetrics
When an application asks to place a character at the position (x, y), the character is placed so that its reference point (shown as the dot in the accompanying image) is put at that position. The reference point specifies a horizontal line called the baseline of the character. In normal printing, the baselines of characters should align.
More formally a component's baseline is an imaginary line on which text is placed in a component. In general it is the distance in pixels between top-left of the component and Text's baseline. So in order to get this baseline one needs to pass height and width of the component. It is not necessary for every component to have baseline and for those components this method returns -1.
This method is used during component layout, so it can not use actual dimensions at that point because component is still being resized/repositioned. Hence it needs width and height to be passed.
For your reference as @Frakcool mentioned:
Line under "Find What:" is baseline.
© 2022 - 2024 — McMap. All rights reserved.