我试图测试SwingX首次,对于这一点,我读的文档:http://www.jdocs.com/swingx/1.0/org/jdesktop/swingx/autocomplete/AutoCompleteDecorator.htmlSwingX AutoCompleteDecorator:没有合适的梅索德发现装饰
我想做出一个JTextField这样的建议:
List items = [...];
JTextField textField = [...];
AutoCompleteDecorator.decorate(textField, items);
,所以我创建的NetBeans项目,这是我的代码:
package test_swingx;
import java.awt.Dimension;
import java.awt.HeadlessException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
/**
*
* @author marwen
*/
public class Test_swingx extends JFrame {
public Test_swingx(String title) throws HeadlessException {
this.setTitle(title);
JPanel pan=new JPanel();
JTextField jtf=new JTextField();
jtf.setColumns(20);
List items = new ArrayList();
items.add("hello");
items.add("marwen");
items.add("allooo");
AutoCompleteDecorator.decorate(jtf, items);
pan.add(jtf);
this.setContentPane(pan);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
this.setBounds(280, 150, 500, 200);
}
public static void main(String[] args) {
Test_swingx tsx=new Test_swingx("helloo swingx");
}
}
我得到这个错误:
no suitable methode found for decorate....
我下面还有语法,我不明白的地方的错误来? 任何帮助?
请学习Java命名约定并严格遵守 – kleopatra 2012-02-07 16:50:33
感谢您的建议.. – 2012-02-07 17:07:53