import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
public class Java_3
{
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");
Container contentPane = getContentPane();
ExceptTestPanel panel = new ExceptTestPanel();
//*********Found********
contentPane.add(panel);
pack();
}
}
class ExceptTestPanel extends Box
{
public ExceptTestPanel()
{
super(BoxLayout.Y_AXIS);
group = new ButtonGroup();
addRadioButton("整数被零除", new
ActionListener()
{
//*********Found********
public void actionPerformed(ActionEvent event)
{
a[1] = 1 / (a.length - a.length);
}
});
textField = new JTextField(30);
add(textField);
}
//*********Found********
private void addRadioButton(String s, ActionListener listener)
{
JRadioButton button = new JRadioButton(s, false)
{
protected void fireActionPerformed(ActionEvent event)
{
try
{
textField.setText("No exception");
super.fireActionPerformed(event);
}
catch (Exception exception)
{
//*********Found********
textField.setText(exception.toString());
}
}
};
button.addActionListener(listener);
add(button);
group.add(button);
}
private ButtonGroup group;
private JTextField textField;
private double[] a = new double[10];
}
public class Java_1
{
public static void main(String args[])
{
int i,count;
//*********Found********
count = 0;
for( i=100 ; i <= 200 ; i++)
//*********Found********
if ( i%3 == 0 ) count++;
//*********Found********
System.out.println("Count = " + count);
}
}
import javax.swing.*;
import java.awt.event.*;
public class Java_2 extends JFrame {
private JButton b;
public Java_2(String s){
setTitle(s);
b=new JButton("Hello");
getContentPane().add(b);
//*********Found********
b.addActionListener( new HandleButton() );
setSize(150,150);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//*********Found********
setVisible( true);
}
class HandleButton implements ActionListener{
public void actionPerformed(ActionEvent e){
//*********Found********
if ( "Hello".equals( b.getText()) )
b.setText("你好");
else
b.setText("Hello");
}
}
public static void main(String args[]){
//*********Found********
new Java_2("二级Java");
}
}