为什么绘画不到第二个长方形?import java.awt.Graphics;
import javax.swing.JApplet;
import javax.swing.JOptionPane;
import java.applet.Applet;
import java.awt.Graphics;
public class sss3 extends Applet{
int number1;
int number2;
int number3;
int number4; int number5;
int number6;
int number7;
int number8;
public void init(){
String firstnumber;
String secondnumber;
String thirdnumber;
String forthnumber;
firstnumber=JOptionPane.showInputDialog("input the first number:");
secondnumber=JOptionPane.showInputDialog("input the second number:");
thirdnumber=JOptionPane.showInputDialog("input the third number:");
forthnumber=JOptionPane.showInputDialog("input the forth number:");
number1=Integer.parseInt(firstnumber);
number2=Integer.parseInt(secondnumber);
number3=Integer.parseInt(thirdnumber);
number4=Integer.parseInt(forthnumber);
}
public void init2(){ String firstnumber2;
String secondnumber2;
String thirdnumber2;
String forthnumber2;
firstnumber2=JOptionPane.showInputDialog("input the first2 number:");
secondnumber2=JOptionPane.showInputDialog("input the second2 number:");
thirdnumber2=JOptionPane.showInputDialog("input the third2 number:");
forthnumber2=JOptionPane.showInputDialog("input the forth2 number:");
number5=Integer.parseInt(firstnumber2);
number6=Integer.parseInt(secondnumber2);
number7=Integer.parseInt(thirdnumber2);
number8=Integer.parseInt(forthnumber2);
}
public void paint(Graphics g)
{
g.drawRect(number1,number2, number3, number4);
}
public void paint2(Graphics h)
{
h.drawRect(number5,number6, number7, number8);
}
}
解决方案 »
- 一道第三届itatjava复赛试题
- java timer
- EJB 调用的问题,很简单的,轻松得100分。
- 用java编了个小的计算器程序,但运行后无法输入数值,显示不出输入的数字,望好心人帮帮忙,谢谢了!!!
- 定义变量的问题
- 如何让JList动态显示?
- log4j找不到类,解决就给分!
- 谁能帮我看看这个Applet程序那里出错了?
- 如何实现在JTABLE的列标题分成两行显示.如这种功能 AAA\nBBB
- 怎么这个requestFocus()不好使? 看似简单的问题怎么在我的程序中就不行?ivjJTextField1.requestFocus()得不到焦点!问题出在哪里?
- 下了一个java写的扫雷,怎么看啊?用eclipse?感觉里面好乱。。。
- 不知道不用配置文件而采用Annotation实现ssh架构的项目多吗?
import java.awt.Graphics;
import javax.swing.JApplet;
import javax.swing.JOptionPane;
import java.applet.Applet;
import java.awt.Graphics;public class sss3 extends Applet
{
int number1;
int number2;
int number3;
int number4;
int number5;
int number6;
int number7;
int number8;
public void init()
{
String firstnumber;
String secondnumber;
String thirdnumber;
String forthnumber;
firstnumber=JOptionPane.showInputDialog("input the first number:");
secondnumber=JOptionPane.showInputDialog("input the second number:");
thirdnumber=JOptionPane.showInputDialog("input the third number:");
forthnumber=JOptionPane.showInputDialog("input the forth number:");
number1=Integer.parseInt(firstnumber);
number2=Integer.parseInt(secondnumber);
number3=Integer.parseInt(thirdnumber);
number4=Integer.parseInt(forthnumber);
init2();
}
public void init2()
{
String firstnumber2;
String secondnumber2;
String thirdnumber2;
String forthnumber2; firstnumber2=JOptionPane.showInputDialog("input the first2 number:");
secondnumber2=JOptionPane.showInputDialog("input the second2 number:");
thirdnumber2=JOptionPane.showInputDialog("input the third2 number:");
forthnumber2=JOptionPane.showInputDialog("input the forth2 number:");
number5=Integer.parseInt(firstnumber2);
number6=Integer.parseInt(secondnumber2);
number7=Integer.parseInt(thirdnumber2);
number8=Integer.parseInt(forthnumber2);
}
public void paint(Graphics g)
{
g.drawRect(number1,number2, number3, number4);
paint2(g);
}
public void paint2(Graphics h)
{
h.drawRect(number5,number6, number7, number8);
}
}