简体   繁体   English

如何使用Netbeans源代码视图并仍然使用我自己的paint()方法

[英]How to use netbeans Source view and still use my own paint() method

i stumbled upon a small problem. 我偶然发现了一个小问题。 I designed some elements in my JFrame using netbeans Source view, and now i want to paint some elements(etc. circles). 我使用netbeans Source视图在JFrame中设计了一些元素,现在我想绘制一些元素(例如圆圈)。 I know its done using the paint() method where i do graphics.draw(circle) etc., but that overrides the paint() method generated by netbeans and none of the elements i styled using source view is now shown. 我知道它是使用paint()方法完成的,其中我执行graphics.draw(circle)等,但是它覆盖了netbeans生成的paint()方法,并且现在没有显示使用源视图设置样式的元素。 Can it be done so that i can use both Source view and my own paint method? 可以做到这一点,以便同时使用Source视图和我自己的绘制方法吗? or do i need to create everything manually and paint it on my own? 还是我需要手动创建所有内容并自己绘画?

call super.paint() in your paint() mehod 在paint()方法中调用super.paint()
or if it doesnt work call paintComponent() method of the container 或者如果它不起作用,请调用容器的paintComponent()方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM