初学java,绘图这里很搞不懂
package picture; import javax.swing.*; import java.awt.*; /** * Created by Smith on 2016/10/19. */ public class Study extends JPanel{ public int x = 1; public int y = 1; public static void main(String [] args) { new Study().init(); } public void init() { JFrame jf = new JFrame("图片"); JPanel jp = new JPanel(); jf.add(jp); jf.setSize(600,600); jf.setVisible(true); Graphics g = jp.getGraphics(); for(int i = 1;i<=500;i++) { paint(g); x++; y++; } System.out.println(g); } public void paint(Graphics g) { g.setColor(Color.blue); g.drawString("hello",x,y); repaint(); } }
生成的效果图就是如上,我实际是想要hello进行移动,但repaint()放在这里为什么没有效果
付费偷看金额在0.1-10元之间
一周热门 更多>