【发布时间】:2011-02-28 20:33:19
【问题描述】:
我有一个 JTextField,我在其中设置了一些自定义属性:
nameField.setPreferredSize(new Dimension(275,40));
nameField.setBackground(bgColor);
nameField.setForeground(txtColor);
nameField.setFont(new Font("HelveticaNeue",Font.PLAIN,22));
nameField.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
当组件具有焦点时,字段周围不会显示高亮显示。在 Mac 上,它通常是一个蓝色的发光矩形,表示该组件具有焦点。
如果我注释掉 nameField.setBorder(...),突出显示会再次出现。如何保持突出显示以及我的自定义边框!?
基本上,我只想在组件有焦点时显示高亮边框,而在组件未获得焦点时不显示边框。
请注意,原始边框的类型为com.apple.laf.AquaTextFieldBorder。
【问题讨论】:
标签: java focus border highlight jcomponent