Topic: 跪求解答菜鸟问题

  Print this page

1.跪求解答菜鸟问题 Copy to clipboard
Posted by: jasonwing27
Posted on: 2004-10-11 13:12

昨日写了个APPLET的程序
可是出现了以下的问题
就是显示输出所输入内容的时候不换行,见图
不知道是不是我的HTML太差了。
请各位帮忙解答
原代码如下:
//ShowWords.java
import java.applet.Applet;
import java.awt.*;
public class ShowWord extends Applet
{
Label words ;
TextField input ;
Label output ;

public void init()
{
words = new Label ("输入几个字符:") ;
input = new TextField(3) ;
output = new Label (" ") ;
add (words) ;
add (input) ;
add (output) ;
}

public boolean action (Event e, Object o)
{
output.setText ("你输入的字符是:"+o.toString()) ;
return true ;
}
}

//ShowWord.html
<html>
<head><title>ShowWord</title></head>
<body>
<hr>
<applet code = ShowWord
width = 300
height = 200>
</applet>
</body>
</html>

2.Re:跪求解答菜鸟问题 [Re: jasonwing27] Copy to clipboard
Posted by: cjyzpcl
Posted on: 2004-10-11 20:19

请设置Applet的布局,Applet的默认布局是FlowLayout,设置为GridLayout(2,2)就可以了。

3.Re:跪求解答菜鸟问题 [Re: jasonwing27] Copy to clipboard
Posted by: jasonwing27
Posted on: 2004-10-12 12:56

谢谢啊,可是我不知道该怎么设置,可以细说吗?

4.Re:跪求解答菜鸟问题 [Re: jasonwing27] Copy to clipboard
Posted by: jasonwing27
Posted on: 2004-10-12 12:58


5.Re:跪求解答菜鸟问题 [Re: jasonwing27] Copy to clipboard
Posted by: ljy0000
Posted on: 2004-10-12 15:42

import java.applet.Applet;
import java.awt.*;

public class ShowWord extends Applet
{
Label words;
TextField input;
Label output;

public void init()
{
setLayout(new GridLayout(2, 2));
words = new Label("输入几个字符:");
input = new TextField(3);
output = new Label(" ");
add(words);
add(input);
add(output);
}

public boolean action(Event e, Object o)
{
output.setText("你输入的字符是:" + o.toString());
return true;
}
}

6.Re:跪求解答菜鸟问题 [Re: jasonwing27] Copy to clipboard
Posted by: jasonwing27
Posted on: 2004-10-12 17:48

能给我讲一下关于设置布局的问题吗?

7.Re:跪求解答菜鸟问题 [Re: jasonwing27] Copy to clipboard
Posted by: kavinwang
Posted on: 2004-10-13 13:26

其实你不用跪的Blush


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923