SeaGlass J组件修改

3

我正在尝试创建JTextField的变体,使其看起来更像一个“搜索”字段。我在SeaGlass网站上看到过这种变体,但我在实现时遇到了问题...外观和感觉本身完美无缺,但我无法访问JTextField.variant方法...我正在测试以下类:

public class Stuff extends JFrame {

    JTextArea text;
    JTextField field;

    public Stuff() {
        text = new JTextArea("something");
        text.setEditable(false);
        field = new JTextField(20).variant("search");            
        setLayout(new FlowLayout());            
        add(text);
        add(field);            
        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(600, 300);
    }
}

并在这个类中调用它:

public class SeaGlassTest {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
            new Stuff();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
1个回答

3

已经修复了!以后的参考,你需要的代码是:

field.putClientProperty("JTextField.variant", "search");

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接