天天练习java

package tiantian;
import javax.swing.*;
public class Lesson {
	
	private JFrame mianFrame;
	private JLabel resultLabel;
	
	private void initFrame(){
		mianFrame=new JFrame("计算两个数的和");
		resultLabel=new JLabel();
		mianFrame.setSize(300, 200);
		mianFrame.add(resultLabel);
		mianFrame.setVisible(true);
	}
	public void pulsFun(int x,int y){
		resultLabel.setText("计算两个数相加的结果:"+(x+y));
		
	}
	public static void main(String[]args){
		Lesson testObj=new Lesson();
		testObj.initFrame();
		testObj.pulsFun(100, 200);
		
	}
}

你可能感兴趣的:(天天练习java)