简体   繁体   中英

What does focus means?

Just wondering what focus means in java code, because I have seen onWindowFocusChanged, addFocussables, findFocus...

If I have a scrollable list and I scrolled it down, the first item will have focus false? or it means other thing?

Thanks

Focus means you have selected the particular GUI element. For example when you select a window that window gains focus, when you select another window the first window loses focus.... It's the same for JTextField, JTextArea, etc.

The definition of the focus here on StackOverflow is as follows:

Focus indicates the component of the graphical user interface which is currently selected to receive input.

Saying that focused component is selected is not accurate. For instance, we can have a JCheckBox which is deselected (has no tick mark) and it is also the current focus owner. Since it has focus, its state is toggled with the spacebar. The term active is more precise. I came up with the following definition of focus:

Focus is a state of a component in which it receives keyboard input. Focus is represented by some visual cue; for instance, in Metal look and feel a focused JButton has a blue rectangle around its label. The component with the current input focus is called the focus owner.

The current GUI element that is "active" has the focus. For example when you have several Input windows only one can have the focus and receive your keyboard input. See here the Android GUI doc http://developer.android.com/guide/topics/ui/ui-events.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM