我正在尝试创建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();
}
}
}