获取输入并绘制形状 [英] get input and draw the shape

查看:60
本文介绍了获取输入并绘制形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用数据表格输入框(整数)并用收到的数字绘制一个三角形。我可以得到数字,但我似乎可以从静态类中获取它们。

Im trying to use data form input boxes ( integers) and draw a triangle with the numbers received. I can get the numbers fine but I can seem to grab them form the static class.

展开 | 选择 | Wrap | 行号

推荐答案

@xpun


谁或什么应该在你的Triangle类中调用你的静态方法paint()?没有魔法,所以你的静态方法根本就没有被调用。阅读Swing教程并使用非静态paintComponent()方法使三角形类扩展(或委托给)JComponent。 AWT事件调度线程调用这些方法。


亲切的问候,


Jos
@xpun
Who, or what, is supposed to call your static method paint() in your Triangle class? There is no magic involved so your static method isn''t called at all. Read a Swing tutorial and make your triangle class extend (or delegate to) a JComponent with a non-static paintComponent() method. The AWT event dispatch thread calls those methods.

kind regards,

Jos


确实。 ..但我似乎无法称呼它。除非我把null放在ie里面。 Draw.paint(null);
Indeed... but I can''t seem to call it. Unless I place null inside ie. Draw.paint(null);
展开 | 选择 | Wrap | 行号


@xpun


只是让编译器闭嘴,但肯定不会工作;正如我写的:阅读Swing教程,看看绘图机制是如何工作的,即你必须实现的(小)部分以及Swing框架为你做的部分。只是猜测一些paint()方法应该做的工作不起作用。


亲切的问候,


Jos
@xpun
That just keeps the compiler''s mouth shut but most certainly doesn''t work; as I wrote: read a Swing tutorial an see how the drawing mechanism works, i.e. the (small) parts you have to implement and the parts the Swing framework does for you. Just guessing that some paint() method should do the job doesn''t work.

kind regards,

Jos


这篇关于获取输入并绘制形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆