2014-01-10 3 views
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(); 
     } 
    } 
} 

답변

3

그것을 고정! 나중에 참조 할 수 있도록 필요한 코드는 다음과 같습니다.

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