I'm trying to create a variant of JTextField to make it look more like a 'search' field, I've seen this on the SeaGlass website but am having trouble implementing it... The look and feel itself work perfectly, but I cannot access the JTextField.variant method... I'm testing it a the following class:
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);
}
}
and calling it in this class:
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();
}
}
}
Fixed it! For future reference, the code you need is:
field.putClientProperty("JTextField.variant", "search");