0
我正在學習Swing和試圖與自動完成文本編輯器作爲一個練習。我使用Netbeans。自動完成裝飾中的JFrame
當我創建的JFrame和一個文本區域添加到它,我結束了這種自動生成的代碼:
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
}
我想嘗試爲所適用自動完成裝飾在
描述http://www.jdocs.com/swingx/1.0/org/jdesktop/swingx/autocomplete/AutoCompleteDecorator.html
當我嘗試做
List list = Arrays.asList("A", "B", "C");
AutoCompleteDecorator.decorate(jTextArea1, list);
它的結果爲:
error: <identifier> expected
AutoCompleteDecorator.decorate(jTextArea1, list);
有什麼不好的代碼?
'錯誤:預期 AutoCompleteDecorator.decorate(jTextArea1,列表,真); 錯誤:預期 AutoCompleteDecorator.decorate(jTextArea1,list,true); 錯誤:預期 AutoCompleteDecorator.decorate(jTextArea1,list,true); 錯誤:非法啓動類型 AutoCompleteDecorator.decorate(jTextArea1,list,true);' –
kaboom
@ ror6ax您是否下載過庫?並清潔和建立 – nachokk
你的意思是「圖書館」?我認爲這是標準庫裝飾器... – kaboom