{"id":1555,"date":"2022-08-30T15:17:30","date_gmt":"2022-08-30T15:17:30","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/27\/problem-about-repaint-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:17:30","modified_gmt":"2022-08-30T15:17:30","slug":"problem-about-repaint-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/problem-about-repaint-collection-of-common-programming-errors\/","title":{"rendered":"problem about repaint-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c0075f2fa25c9d2fec33295ab3bf1119?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nLennart Schoch<br \/>\njava swing actionlistener repaint<br \/>\nEDIT: Now it works fine, but when i switch to the &#8220;game&#8221; JPanel, the KeyListener is not working \ud83d\ude41 Any way to fix this?i&#8217;m just programming a java game and there is a problem with the repaint() method: I wanna get from the menu to the game so i remove the menu panel and add the game panel (&#8220;Zeichnen&#8221; extends JPanel) But every time i try to repaint, eclipse gives me the following error: &#8220;The method repaint() is undefined for the type new ActionListener(){}&#8221; Can anyone please help me? :(Code:impor<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a62aea56f0834853a2310e8691c8911e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmKorbel<br \/>\njava swing paint repaint jcomponent<br \/>\nI am new on java. I want to create an abstract factory in java. I have a class point and I want to extend other classes ( circle, rectangle ) from this. Here is my code. It says repaint is undefined..import javax.swing.*; import java.awt.*; import java.awt.Component; import javax.swing.*;public class Circle extends Point {public void Draw() {repaint(); }public void paint(Graphics g) { g.drawOval(this.x, this.y, 10, 10);}&#8230;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/88fd507087a8b5e0081f5d554320b6a7?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nOmar Munoz<br \/>\njava swing jlabel repaint event-dispatch-thread<br \/>\nHi I am trying to create a gui that will update the temperature every time the temperature sensor sends back a signal and update the jlabel value. Right now I am able to update the gui label by pressing the update button, however i want it to update automatically without pressing the &#8220;update button&#8221;. I have tried a lot of method including repaint(), and revalidate(), and using different type of swing timers but still cannot get it to work. Can someone please help me out here? Thanks I will post<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/AuY9o.png?s=32&amp;g=1\" \/><br \/>\nAndrew Thompson<br \/>\njava swing jpanel jlabel repaint<br \/>\nWhen I repaint() the panel, where I&#8217;m placing my JLabels on, I get errors, but it still works. I tried putting the panel.repaint(); code in a try statement and that didn&#8217;t help. Anyone else having problems with repaint() for JPanels?Error message (copied from the comments):Exception in thread &#8220;AWT-EventQueue-0&#8221; java.lang.ArrayIndexOutOfBoundsException: No such child: 21 at java.awt.Container.getComponent(Unknown Source) at javax.swing.JComponent.rectangleIsObscured(Unknown Source) at javax.<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2013-11-27 05:10:34. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Lennart Schoch java swing actionlistener repaint EDIT: Now it works fine, but when i switch to the &#8220;game&#8221; JPanel, the KeyListener is not working \ud83d\ude41 Any way to fix this?i&#8217;m just programming a java game and there is a problem with the repaint() method: I wanna get from the menu to the game so i [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1555","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1555","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1555"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1555\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1555"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1555"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}