你注释这的是构造方法,这的this可以省去,指明this后面的属性是这个类本身的属性,构造方法主要是用来赋初值的
你这的注释,this和上面意思一样,这句话是说,把这个类的radius的值
赋给局部变量r,所以在右面,而在上面的构造方法中是把参数的值赋给属性
package jac;
import java.math.BigInteger;
/**
* @author gaofeng
*/
public class TestFactorial
{
public static void main(String[] args)
BigInteger result = new BigInteger(""◆1); //创建一个BIGINTEGER对象 RESULT此时的值为1
for(int i=1; i=1000; i◆◆)
result = result.multiply(new BigInteger( "" ◆ i )); //这里的方法与result=result◆i;同意
}
几年没有碰swing了,给你详细注释了.仔细看.希望对你有所帮助.
import java.awt.*;//java抽象窗口工具包
import java.awt.event.*;//java抽象窗口工具包组件所激发的各类事件的接口和类
Frame f;//定义一个Frame窗体
TextArea center;//文本域
Panel east,south,north;//三块面板
Choice l1;//下拉单选框
TextField t1;//文本域
//textfield只有一行可写
//textarea是一个区域,可以有很多行
public static void main(String[] args){//主函数,程序入口
Test mb = new Test();
mb.go();//调用go方法,初始化界面
private void go(){
f = new Frame("留言版程序");//标题
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent evt){
f.setVisible(false);
System.exit(0);
//System.exit(0) 0--正常结束程序 1--异常关闭程序
});
f.setLayout(new BorderLayout());//显示方式
f.setResizable(false);
//下面都将控件按钮初始化,你懂得
north = new Panel();
south = new Panel();
east = new Panel();
center = new TextArea("留言内容:");
center.setEditable(false);
b1 = new Button("清屏");
la1 = new Label("留言版");
l1 =new Choice();
l1.add("微笑 ");
l1.add("生气 ");
l1.add("伤心 ");
f.add(BorderLayout.NORTH,north);//布局
f.add(BorderLayout.SOUTH,south);//布局
f.add(BorderLayout.EAST,east);//布局
f.add(BorderLayout.CENTER,center);//布局
north.add(BorderLayout.CENTER,la1);
south.add(l1);
south.add(t1);//把东西加到面板上
east.add(b1);
f.setVisible(true);//可视化
public void actionPerformed(ActionEvent e){
text1 = l1.getSelectedItem();
t1.setText(null);
if(t1.getText() != ""){//将下拉单选框的内容和你输入在文本框的内容显示在中间面板上
center.append("\n");
center.append(text1);
b1.addActionListener(new ActionListener(){//清屏按钮事件,只留下中间面板显示:"留言内容:",其余清楚
center.setText("留言内容:");
center.requestFocusInWindow();
center.setCaretPosition(center.getText().length());
public class CalculatorA {
private JFrame jf;
private JButton[] jbs;
private JTextField jtf;
private JButton clear;
private char c;
* 构造方法实例化属性
*
public CalculatorA(){
jf=new JFrame("我的计算器v1.0"); //定义窗口的title
clear=new JButton("clear");// 定义按钮
for(int i=0; istr.length(); i◆◆){//批量赋值.这样做使得定义按钮方便很多否则,你需要一个按钮一个按钮像上面的"clear"那样的定义
jbs[i]=new JButton(str.charAt(i)◆"");
init();
addEventHandler();
// setFont();
// setColor();
showMe();
* 布局图形界面
public void init(){
// jf.setLayout(manager)
JPanel jp1=new JPanel();//定义面板,用来容纳上面的按钮文本域等组件
jp1.add(jtf);//将 文本域 让如面板中
jf.add(jp1,BorderLayout.NORTH);//将显示数据面板,使用边框布局,放置最顶端.
public void setFont(){
public void setColor(){
ActionListener lis=new ActionListener(){
// TODO Auto-generated method stub
JButton jb=(JButton)e.getSource();//获取事件源
// String key=(String)e.getActionCommand();
String str =jb.getText().trim();//把字符串的首尾空格去掉!
return;
num1=Double.parseDouble(jtf.getText());//获取文本域的值并转换类型并暂时保存起来.
jtf.setText("");
c=str.charAt(0);
return ;
// jtf.setText("");
switch(c){
jtf.setText(Double.toString(jieguo)); //返回结算结果到显示文本域
if(e.getActionCommand().equals("clear")){
jtf.setText("");//清空显示文本域
};
for(int i=0; ijbs.length; i◆◆){
//为每个按钮加上监听类
jbs[i].addActionListener(lis);
clear.addActionListener(lis);
public void showMe(){
jf.pack();//调整此窗口的大小,以适合其子组件的首选大小和布局.
jf.setVisible(true);//设置窗口可见
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置程序的退出按钮,退出即同时停止程序
public static void main(String[] args){//启动程序的入口
new CalculatorA();
这代码注释写的太累人了.小窗口费劲.给加点分吧.
以上就是土嘎嘎小编为大家整理的java小程序代码注释相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!