首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

Fatal exception occurred,program will exit解决方法!

2014-01-26 
我编写的代码如下 Java codeimport java.awt.*import java.awt.event.ItemEventimport java.awt.event.It

我编写的代码如下

Java code
import java.awt.*;import java.awt.event.ItemEvent;import java.awt.event.ItemListener;import javax.swing.*;import javax.swing.border.EtchedBorder;public class Checkradioform extends JFrame{ private JRadioButton rdbSet; private JTextArea txtDemo; private JCheckBox chkBold; private JCheckBox chkplain; private JCheckBox chkItalic; private ButtonGroup groupBtn; private JRadioButton rdbRed; private JRadioButton rdbBlack; private JRadioButton rdbGreen; private combobox_c

当我调用registerEvent()这个监听事件的时候Fatal exception occurred,program will exit,就会有这样的提示,我的环境是Eclipse SDK
Version: 3.1.0
Build id: I20050627-1435
j2sdk1.4.2,我是个新人,向各位过路人指教。


------解决方法--------------------------------------------------------
package Other;

import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.*;
import javax.swing.border.EtchedBorder;
@SuppressWarnings("serial")
public class Checkradioform extends JFrame{
private JRadioButton rdbSet;
private JTextArea txtDemo;
private JCheckBox chkBold;
private JCheckBox chkplain;
private JCheckBox chkItalic;
private ButtonGroup groupBtn;
private JRadioButton rdbRed;
private JRadioButton rdbBlack;
private JRadioButton rdbGreen;
private JRadioButton rdbBlue;


public Checkradioform()
{
createComponents();
layoutComponents();
registerEvent();
setTitle("复选框和单选框");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
}
private void createComponents()
{
txtDemo=new JTextArea("与时俱进"+"\n"+"共创辉煌",4,8);
txtDemo.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
chkBold=new JCheckBox("粗体",false);
chkItalic=new JCheckBox("斜体",false);
groupBtn=new ButtonGroup();
rdbRed=new JRadioButton("红色",false);
rdbBlack=new JRadioButton("黑色",false);
rdbGreen=new JRadioButton("绿色",false);
rdbBlue=new JRadioButton("lanse",false);  }

private void layoutComponents()
{
Container contentPane=this.getContentPane();

JPanel txtDemoPane=new JPanel(new GridLayout(4,1));
txtDemoPane.add(chkBold);
txtDemoPane.add(chkItalic);
txtDemoPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),"字体"));

JPanel colorPane=new JPanel(new GridLayout(4,1));
colorPane.add(rdbRed);
colorPane.add(rdbBlack);
colorPane.add(rdbGreen);
colorPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),"颜色"));
groupBtn.add(rdbRed);
groupBtn.add(rdbBlack);
groupBtn.add(rdbGreen);

colorPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),"颜色"));


groupBtn.add(rdbRed);
groupBtn.add(rdbBlack);
groupBtn.add(rdbBlue);
groupBtn.add(rdbGreen);

JPanel txtPane=new JPanel(new GridLayout(1,1));
txtPane.add(txtDemo);         

热点排行