3
我試圖創建一個JTextField的變體,使它看起來更像一個'搜索'字段,我在SeaGlass網站上看到了這個,但是在實現它時遇到了麻煩......外觀和感覺本身完美地工作,但我不能訪問JTextField.variant方法......我測試它下面的類:修改SeaGlass JComponents
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();
}
}
}