我有一个包含多个类的JApplet程序。 RegPanel,WorkshopPanel,CnferenceGUI,CnferenceHandler和CnferenceClient。基本上RegPanel和WorkShop面板被添加到CnferenceGUI,它还创建并添加了几个小面板。 CnferenceClient类仅用于初始化类以运行applet。 CnferenceHandler用于处理JButtons,JTextArea,JCheckBox等的动作事件......这是我的问题;
在CnferenceGUI类中,我将动作侦听器添加到按钮/组合框,程序运行正常。但是当我在JCheckBox上添加监听器的代码时,整个applet变成空白。有谁知道这是为什么?
这是CnferenceGUI类中的构造函数:
public ConferenceGUI()
{
setLayout(new BorderLayout());
titlePanel = new JPanel();
titleLabel = new JLabel("Select Registration Options",JLabel.CENTER);
Font titleFont = new Font("SansSerif", Font.BOLD, 18);
titleLabel.setFont(titleFont);
titlePanel.add(titleLabel);
add(titlePanel, BorderLayout.NORTH);
regPanel = new RegPanel();
add(regPanel, BorderLayout.WEST);
workshopPanel = new WorkshopPanel();
add(workshopPanel, BorderLayout.EAST);
buildButtonPanel();
add(buttonPanel, BorderLayout.SOUTH);
ConferenceHandler handler = new ConferenceHandler(this);
regPanel.regTypeComboBox.addItemListener(handler);
regPanel.regNameTextBox.addFocusListener(handler);
// This is the line that make the entire applet blank if included
regPanel.keynoteCheckBox.addItemListener(handler);
}
答案 0 :(得分:0)
听起来像applet构建期间发生了未处理的异常!请验证控制台输出。向复选框添加处理程序不会导致此类问题。