day79(异常三)
来源:互联网 发布:emacs for mac 编辑:程序博客网 时间:2024/05/22 17:47
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
public class ExceptTest{
public static void main(String[] args){
ExceptTestFrame frame=new ExceptTestFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
class ExceptTestFrame extends JFrame{
public ExceptTestFrame(){
setTitle("ExceptTest");
ExceptTestPane1 pane1=new ExceptTestPane1();
add(Pane1);
pack();
}
}
class ExceptTestPane1 extends Box{
public ExceptTestPane1(){
super(BoxLayout..Y_AXIS);
group=new ButtonGroup();
addRadioButton("Integer divide yb zero",new ActionLIstener(){
public void actionPerformed(ActionEvent event){
a[1]=1/(a.length-a.length);
}
});
addRadioButton("Floation point divide yb zero",new ActionLIstener(){
public void actionPerformeformed(ActionEvent event){
a[1]=a[2]/(a[3]-a[3]);
}
addRadioButton("Floation point divide by zero",new ActionLIstener(){
public void actionPerformed(ActionEvent event){
a[1]=a[2]/(a[3]-a[3]);
}
});
addRadioButton("Floation point divide yb zero",new ActionListener(){
public void actionPerformed(ActionEvent event){
a[1]=a[2]/(a[3]-a[3]);
}
});
addRadioButton("Array bounds",new ActionLIstener(){
public void actionPerformed(ActionEvent event){
a[1]=a[10];
}
});
addRadioButton("Bad cast",new ActionLIstener(){
public void actionPerformed(ActionEvent event){
a=(double[])event.getSource();
}
});
addRadioButton("Null pointer,new ActionLIstener(){
public void actionPerformed(ActionEvent event){
a=(double[])event.getSource();
}
});
addRadioButton("sqrt(-1)",new ActionLIstener(){
public void actionPerformed(ActionEvent event){
a[1]=Math.sart(-1);
}
});
addRadioButton("Overflow",new ActionLIstener(){
public void actionPerformed(ActionEvent event){
a[1]=1000*1000*1000*1000;
int n=(int)a[1];
}
});
addRadioButton("No such file",new ActionLIstener(){
public void actionPerformed(ActionEvent event){
try{
InputStream in=new FileInputStream("woozle.txt");
}
catch (IOException e){
textField.setText(e.toString());
}
}
});
addRadioButton("Throw unknown",new ActionLIstener(){
public void actionPerformed(ActionEvent event){
throw new UnknownError();
}
});
textField=new JTextField(30);
add(textField);
}
private void addRadioButton(String s,ActionLIstener listener){
JRadioButton button=new JRadioButton(s,false){
protected void fireActionPerformed(ActiopnEvent event){
try{
textField.setText("No exception");
super.fireActionPerformed(event);
}
catch (Exception e)
textField.setText(e.toString());
}
}
};
button.addActionLIstener(listener);
add(button);
group.add(button);
}
private button group group;
private JTextField textField;
private double[] a=new double [10];
}
- day79(异常三)
- Day79
- 鼠标滚轮实现图片的缩放-------Day79
- 开始刷leetcode day79:Rectangle Area
- More Effective(三)异常
- 异常初探(三)
- java 异常三
- 抛出三种异常
- 异常检测(三)
- (三)OutOfMemoryError异常
- 异常处理(三)-------C++异常类
- 三、Action及异常处理
- 异常处理总结(三)
- C++中的异常处理(三)
- 黑马程序员_java异常<三>
- java异常处理(三)
- mysql三种处理异常
- JAVA基础(三)异常处理
- [tolua++]tolua++中暴露对象给lua时,一定要把析构函数暴露给lua 【转】
- java 不固定参数 / 可选参数介绍
- 基于MFC的社团纳新抽题系统
- Ecliplse安装tomcat插件
- Unity3D之MeleeWeaponTrail武器轨迹插件的使用
- day79(异常三)
- 关于用netbeans和xdebug调试php的配置
- Ubuntu下压缩文件
- xml笔记:3 引入xsd来编写xml
- hdu-1429 胜利大逃亡(续)
- 小感
- jquery mobile
- source insight支持.S的汇编文件和禁止for if等下一行缩进
- C语言str系列库函数之strtok()