SwingX AutoCompleteDecorator:找不到合适的装饰方法
我第一次尝试测试 SwingX,为此,我阅读了文档: http://www.jdocs.com/swingx/1.0/org/jdesktop/swingx/autocomplete/AutoCompleteDecorator.html
我想对这样的 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....
我很好地遵循了语法,我不明白错误来自哪里? 有什么帮助吗?
I am trying to test SwingX for the first time,For this, I read the doc : http://www.jdocs.com/swingx/1.0/org/jdesktop/swingx/autocomplete/AutoCompleteDecorator.html
I'd like to make a suggestion on a JTextField like this:
List items = [...];
JTextField textField = [...];
AutoCompleteDecorator.decorate(textField, items);
so I create a project on netbeans, this is my code:
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");
}
}
I get this error :
no suitable methode found for decorate....
I'm following well the syntax , I do not understand where the error come?
ANY HELPS ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的方法装饰调用将解析为下面的第一个方法,该方法是不正确的。第二种方法装饰预期的 JList 而不是列表。
但是,如果您仍然想使用 List,则应该使用此方法,
我已经用此更改了您问题中的错误部分。
Your method decorate call, is resolve to the first method below which is incorrect. Second method decorate expected JList instead of list.
However, if you still want to use List, you should use this method,
I've changed the error part in your question with this.