关于Java的Graphics2D的问题,我画的直线为什么不显示出来
packagejava_draw;importjava.awt.Color;importjava.awt.Graphics2D;importjava.awt.image....
package java_draw;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
public class draw_line extends JFrame{
public draw_line(){
this.setVisible(true);
this.setBounds(300, 300, 300, 300);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
init();
}
void init(){
BufferedImage image=new BufferedImage(300,300,BufferedImage.TYPE_INT_RGB);
Graphics2D g=(Graphics2D)image.getGraphics();
g.setColor(Color.red);
g.drawLine(0, 0, 300, 300);
}
} 展开
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
public class draw_line extends JFrame{
public draw_line(){
this.setVisible(true);
this.setBounds(300, 300, 300, 300);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
init();
}
void init(){
BufferedImage image=new BufferedImage(300,300,BufferedImage.TYPE_INT_RGB);
Graphics2D g=(Graphics2D)image.getGraphics();
g.setColor(Color.red);
g.drawLine(0, 0, 300, 300);
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询