Java JFrame中的自动完成装饰器
我正在学习Swing,并尝试制作一个带有自动完成功能的文本编辑器作为练习。我使用Netbeans 当我创建JFrame并向其中添加一个文本区域时,我得到了这样一个自动生成的代码:Java JFrame中的自动完成装饰器,java,swing,Java,Swing,我正在学习Swing,并尝试制作一个带有自动完成功能的文本编辑器作为练习。我使用Netbeans 当我创建JFrame并向其中添加一个文本区域时,我得到了这样一个自动生成的代码: package javaapplication5; public class NewJFrame extends javax.swing.JFrame { public NewJFrame() { initComponents(); } @SuppressWarnings("unche
package javaapplication5;
public class NewJFrame extends javax.swing.JFrame {
public NewJFrame() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
// End of variables declaration
当我试着去做
List list = Arrays.asList("A", "B", "C");
AutoCompleteDecorator.decorate(jTextArea1, list);
其结果是:
error: <identifier> expected
AutoCompleteDecorator.decorate(jTextArea1, list);
错误:应为
自动完成装饰(jTextArea1,列表);
代码有什么问题?在谷歌中搜索,因为没有带有您签名的方法。如果布尔值是严格匹配的
,则必须将其作为参数传递
AutoCompleteDecorator.decorate(jTextArea1, list,true);
错误:应为AutoCompleteDecorator.decoration(jTextArea1,list,true);错误:应为AutoCompleteDecorator.decoration(jTextArea1,list,true);错误:应为AutoCompleteDecorator.decoration(jTextArea1,list,true);错误:类型AutoCompleteDecorator.decoration的启动非法(jTextArea1,list,true)代码>@ror6ax您下载库了吗?干净&build@ror6axswingx
是一个第三方库,您必须下载它,然后将它添加到您的项目中。在这里你可以下载swingx-all-1.6.4.jar
在那里你什么都有了
AutoCompleteDecorator.decorate(jTextArea1, list,true);