當我點擊位於某個面板上的按鈕時,該面板是否會被刪除?Java - 刪除按鈕所在的面板
像
public void actionPerformed(ActionEvent e) {
if(e.getSource()==removebutton)
System.out.println("ok");
removebutton.getRootPane().remove(cartpanel);
}
我試圖做一個購物車,其中,當用戶查看購物車,他會看到位於該有一個刪除按鈕面板項目。然後當他點擊該按鈕時,面板將被移除。
我上面的代碼沒有做預期的輸出,但是有沒有任何方法應該與它一起使用?
panel http://dl.dropbox.com/u/62021435/Untitled.png
從你的照片,我會建議使用'JTable'代替,參見[如何使用JTable中( http://docs.oracle.com/javase/tutorial/uiswing/components/table.html)獲取更多信息 – MadProgrammer