请救帮助....java编写一个程序,从两个文本框接收两个数,然后计算这两个数的乘积
4个回答
展开全部
import java.awt.*;
import java.awt.event.*;
public class TestInner {
public static void main (String[] args) {
new MyFrame2().launchFrame();
}
}
class MyFrame2 extends Frame {
TextField t1,t2,t3;
public void launchFrame () {
t1 = new TextField (10);
t2 = new TextField (10);
t3 = new TextField (15);
Label lab = new Label ("x");
Button bu = new Button ("=");
bu.addActionListener (new MyMonitor2());
setLayout (new FlowLayout());
add (t1);
add (lab);
add (t2);
add (bu);
add (t3);
pack();
setLocation (300,300);
setVisible (true);
}
private class MyMonitor2 implements ActionListener {
public void actionPerformed(ActionEvent e) {
int n1= Integer.parseInt (t1.getText());
int n2 = Integer.parseInt (t2.getText());
t3.setText (""+ (n1*n2));
try {
Thread.sleep (1000);
} catch (InterruptedException ee) {
ee.printStackTrace();
}
t3.setText (""); t1.setText (""); t2.setText ("");
}
}
}
输入数字,点击等号按钮,就可以得到结果
import java.awt.event.*;
public class TestInner {
public static void main (String[] args) {
new MyFrame2().launchFrame();
}
}
class MyFrame2 extends Frame {
TextField t1,t2,t3;
public void launchFrame () {
t1 = new TextField (10);
t2 = new TextField (10);
t3 = new TextField (15);
Label lab = new Label ("x");
Button bu = new Button ("=");
bu.addActionListener (new MyMonitor2());
setLayout (new FlowLayout());
add (t1);
add (lab);
add (t2);
add (bu);
add (t3);
pack();
setLocation (300,300);
setVisible (true);
}
private class MyMonitor2 implements ActionListener {
public void actionPerformed(ActionEvent e) {
int n1= Integer.parseInt (t1.getText());
int n2 = Integer.parseInt (t2.getText());
t3.setText (""+ (n1*n2));
try {
Thread.sleep (1000);
} catch (InterruptedException ee) {
ee.printStackTrace();
}
t3.setText (""); t1.setText (""); t2.setText ("");
}
}
}
输入数字,点击等号按钮,就可以得到结果
展开全部
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
function a()
{
document.getElementById('t3').value = document.getElementById('t1').value * document.getElementById('t2').value;
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>计算乘机</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<label>
<input name="t1" type="text" id="t1" />
* </label>
<label>
<input name="t2" type="text" id="t2" />
</label>
<label>
<input type="button" name="Submit" value="=" onclick="a()" />
</label>
<label>
<input name="t3" type="text" id="t3" />
</label>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
function a()
{
document.getElementById('t3').value = document.getElementById('t1').value * document.getElementById('t2').value;
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>计算乘机</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<label>
<input name="t1" type="text" id="t1" />
* </label>
<label>
<input name="t2" type="text" id="t2" />
</label>
<label>
<input type="button" name="Submit" value="=" onclick="a()" />
</label>
<label>
<input name="t3" type="text" id="t3" />
</label>
</form>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public class Test {
public int sum (int x , int y ){
return x*y;
}
public static void main (String [] args) {
Test t = new Test();
int c = t.sum(1,45);
System.out.println(c);
}
}
public int sum (int x , int y ){
return x*y;
}
public static void main (String [] args) {
Test t = new Test();
int c = t.sum(1,45);
System.out.println(c);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
C/S ?
B/S ?
B/S ?
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询