请教各位了!谢谢! 此图为什么不能成功的绘制出来啊??菜鸟跪求指导。
importjavax.swing.JFrame;importjava.awt.Graphics;importjavax.swing.JPanel;publicclass...
import javax.swing.JFrame;
import java.awt.Graphics;
import javax.swing.JPanel;
public class Test extends JFrame{
Body body=new Body();
public Test(){
this.add(body);
setVisible(true);
int H=(int) (this.getToolkit().getScreenSize().height);
int W=(int) (this.getToolkit().getScreenSize().width);
setLocation(W/2-200,H/2-200);
setResizable(false);
setSize(400,400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args){
Test test=new Test();
}
}
class Body extends JPanel{
public Body(){
}
public void paintComponnent(Graphics g){
super.paintComponent(g);
for(int i=100;i<400;i+=20)
{
g.drawLine(0,i,240,i);
}
for(int i=0;i<=240;i+=20)
{
g.drawLine(i,100,i,400);
if(i==240)
g.drawLine(i,0,i,400);
}
}
} 展开
import java.awt.Graphics;
import javax.swing.JPanel;
public class Test extends JFrame{
Body body=new Body();
public Test(){
this.add(body);
setVisible(true);
int H=(int) (this.getToolkit().getScreenSize().height);
int W=(int) (this.getToolkit().getScreenSize().width);
setLocation(W/2-200,H/2-200);
setResizable(false);
setSize(400,400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args){
Test test=new Test();
}
}
class Body extends JPanel{
public Body(){
}
public void paintComponnent(Graphics g){
super.paintComponent(g);
for(int i=100;i<400;i+=20)
{
g.drawLine(0,i,240,i);
}
for(int i=0;i<=240;i+=20)
{
g.drawLine(i,100,i,400);
if(i==240)
g.drawLine(i,0,i,400);
}
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询