大家帮我看看这个程序啊``~~~
我最后想依次输出几个水仙花数,怎么被覆盖了?不可以换行吗?
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class applet extends Applet implements ActionListener
{
Label tital,result;
Button btn;
public void init()
{
tital=new Label( "开始计算水仙花数请按GO: ");
result=new Label( " ");
// output=new TextField(20);
btn=new Button( "GO ");
setLayout(new FlowLayout());
add(tital);
add(btn);
add(result);
btn.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
int a=0,b=0,c=0,i=0,s=0,m=1;
for(i=100;i <1000;i++)
{
a=i/100;
b=(i-a*100)/10;
c=i%10;
if(Math.pow(a,3)+Math.pow(b,3)+Math.pow(c,3)==i)
{ s=i;
result.setText( "第 "+(m++)+ "个水仙花数为: "+s+ '\n ');
}
}
}
}
------解决方案--------------------
Label好像不行,试试JLable吧
new JLabel( " <html> ABC <br> DEF </html> ");