2012-02-07 1 views
1

が見つかりません、私は、ドキュメントを読んで:http://www.jdocs.com/swingx/1.0/org/jdesktop/swingx/autocomplete/AutoCompleteDecorator.htmlSwingX AutoCompleteDecorator:もし適切なMethodeのは、私はこのために、初めてSwingXをテストしようとしています飾る

私はこのような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"); 

} 
} 

enter image description here

私はこのエラーを取得する:

no suitable methode found for decorate.... 

私はうまく構文を以下のよエラーが来るところ、私は理解していませんか? すべてのヘルプ

+0

提案を – kleopatra

+0

おかげでJavaの命名規則を学び、それらに固執してください。.. –

答えて

1

あなたのメソッドdecorate callは、以下の最初の不正なメソッドに解決されます。 2番目のメソッドは、リストの代わりに期待されるJListを装飾します。

public static void decorate(JComboBox comboBox, ObjectToStringConverter stringConverter) 
public static void decorate(JList list, JTextComponent textComponent) 

あなたはまだリストを使用したい場合は、この方法を使用する必要があり、

public static void decorate(JTextComponent textComponent, List<?> items, boolean strictMatching) 

私はこれで、あなたの質問にエラー部分を変更しました。

import java.util.ArrayList; 
import java.util.List; 

import javax.swing.JFrame; 
import javax.swing.JPanel; 
import javax.swing.JTextField; 
import javax.swing.text.JTextComponent; 

import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; 

public class Test_swingx extends JFrame 
{ 

    public Test_swingx(String p_title) 
    { 
     this.setTitle(p_title); 
     JPanel pan = new JPanel(); 
     JTextComponent jtf = new JTextField(); 
     ((JTextField) jtf).setColumns(20); 
     List items = new ArrayList(); 
     items.add("hello"); 
     items.add("marwen"); 
     items.add("allooo"); 
     AutoCompleteDecorator.decorate(jtf, items, false); 
     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");  
     tsx.setVisible(true); 
    } 

} 
+0

はい、それに動作し、非常によく、災害がdocに誤りがあることである:O ...を参照します。http:// www.jdocs.com/swingx/1.0/org/jdesktop/swingx/autocomplete/AutoCompleteDecorator.html –

+1

ええ、ええ、ドクターが混乱している場合は、ソースコード自体を読んでください。それは常にうまくいくはずです。 ;-)ところで、私はswingxバージョン1.6.2を使用しています – Jasonw

関連する問題