开发者

Java Swing - Show border of controls when clicking Tab key only

开发者 https://www.devze.com 2023-01-30 11:32 出处:网络
I have noticed this behavior in most programs : When clicking any control in a window no border appears around this control, like here :

I have noticed this behavior in most programs :

  1. When clicking any control in a window no border appears around this control, like here :

    Java Swing - Show border of controls when clicking Tab key only

  2. When clicking 'Tab' key a border appears around the control, then i can navigate through all controls, like here :

    Java Swing - Show border of controls when clicking Tab key only

But in Java Swing applications the border appears when click on the control and also when clicking the 'Tab' key, or i can hide tha开发者_运维百科t border forever.

Is there a way to use the default behavior mentioned above(Show the border when clicking 'Tab' key only) ?


public void setFocusPainted(boolean b) ?

Actually it depends on L&F. E.g. the code

    protected void paintFocus(Graphics g, Rectangle textRect, Dimension d){
    g.setColor(getFocusColor());
    BasicGraphicsUtils.drawDashedRect(g, textRect.x, textRect.y, textRect.width, textRect.height);
} 

from WindowsRadioButtonUI (checkbox UI extends radiobutton UI)

0

精彩评论

暂无评论...
验证码 换一张
取 消