2011-11-10 12 views
3

2つの列を持つJTableを作成しようとしています.1つは製品名、2つ目は価格、1つは価格を示す必要があります。問題は、JTableが非常に小さいので、私はスクロールが必要ですが、私はそれを作成することはできません。JTableをスクロール可能にする

enter image description here

DefaultTableModel model = new DefaultTableModel(); 
    JTable productos = new JTable(model); 


    model.addColumn("Product");//name of the first columns 
    model.addColumn("Price");//name of the second columns 
    BTW: the table doesn't show the name of the column, but creates the 2 columns 


    for (i=0; i<null_copy4; i++)//null_copy4 is a integer that shows me how many stacks are used in the array 
    { 
     model.insertRow(model.getRowCount(), new Object[]{product_copy3[i],price_copy3[i]}); 
    } 
      //product_copy3 and price_copy3 are arrays. String[] and integer[]. 
    products.setBounds(5,50,200,200); //define the dimensions of the JTable 
    this.add(productos);//add it to the window 
+0

もしティムベンダーの提案があなたを助けてくれたら、彼の答えを "受け入れる"ことを忘れないでください。 –

+0

StackOverflowでは、 "解決済み"と言うタイトルを編集するのではなく、通常、OPは答えを "受け入れ"ます。これにより、質問が回答されたことが示されます(答えは金で表示されます)。あなた自身の問題を解決すれば、あなた自身の質問に答えてその答えを受け入れることができます。 –

答えて

関連する問題