作者afterforever (FuckingIsSoEasy)
看板java
标题[问题] 关於Panel 重画
时间Sun Apr 16 16:24:28 2006
我是用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