public class bbb {
public static void main (String[] args) {
bbb obj = new bbb();
System.out .println(obj.fac(100 ));
}
public long fac (int m) {
if (_m==0 _)
return 0 ;
else
return _m+fac(m-1 )_;
}
}
import java.awt.*;
import javax.swing.* ;
public class WelcomeFrameDemo extends JFrame {
private JLabel lblname;
private JTextField tfname;
private JButton btnOK;
public WelcomeFrameDemo (){
super ("Welcome Frame" );
setLayout(new FlowLayout());
lblname = new JLabel("Please input your name:" );
lblname.setFont(new Font("Arial" ,Font.PLAIN,20 ));
getContentPane().add(lblname);
tfname = new JTextField(15 );
tfname.setFont(new Font("Arial" ,Font.PLAIN,20 ));
getContentPane().add (tfname);
btnOK = new JButton("OK" );
btnOK.setFont(new Font("Arial" ,Font.PLAIN,20 ));
getContentPane().add (btnOK);
}
}
import javax.swing.JFrame;
public class WelcomeFrameTest {
public static void main (String[] args){
WelcomeFrameDemo demo=new WelcomeFrameDemo();
demo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
demo.setSize(600 ,300 );
demo.setVisible(true );
}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Main {
private static int numclicks = 0 ;
private static JFrame frame = new JFrame("统计点击按钮的次数" );
Private static JLabel _label=new JLabel();____
Private_static JButton button=new_JButton(“请点击按钮”);__________
private static JPanel pane = new JPanel();
public static void main (String[] args) {
pane.setBorder(BorderFactory.createEmptyBorder(60 ,60 ,20 ,60 ));
pane.setLayout(new GridLayout(0 ,1 ));
pane.add(button);
pane.add(label);
frame.getContentPane().add(pane,BorderLayout.CENTER);
button.setMnemonic(KeyEvent.VK_I);
button.addActionListener(new ActionListener(){
public void _actionPerformed (ActionEvent e){
__numclicks++;____
label.setText("按钮单击次数:" +numclicks);
}
});
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame._setVisible(true )______;
}
}