[問題] 關於Panel 重畫
我是用InternalFrame去做
我有兩個Panel_1, Panel_2
Panel_1 上面是欄位, 當輸入不同數字, Panel_2 就會顯示出Panel_1上個數的button
Panel_2 上面是放 Button(根據Panel_1 動態改變)
那當Panel_1 上按下確定之後, 就call Panel_2 的 update_panel function
我 Panel_2 寫法是這樣
public class Panel_2
{
public Panel_2()
{
}//end constructor
public void paintComponent( Graphics g )
{
removeAll();
這裡是畫button
validate();
}//end method
public void update_panel()
{
repaint();
}
}
但是 這樣寫, 會有許多問題,
1, 原本Panel_1 輸入完之後, 按下確定的彈出視窗上面的字, 就都便空白
2, Panel_2 上面的button 的觸發事件 都不會出來
如果我把removeAll()和validate 拿掉, 觸發事件會出來, 彈出視窗也會有字,
但是就只要轉換一個frame, panel_2 上就會一直component增加
想請問我哪裡寫錯 or 怎改~~
thank you~
或是有範例程式給我參考~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.114.196.111
java 近期熱門文章
PTT數位生活區 即時熱門文章