Note that there are some explanatory texts on larger screens.

plurals
  1. PONot sure why this graphics screen is not updating
    primarykey
    data
    text
    <p>This is the screen that im trying to repaint but it is not repainting properly.</p> <pre><code> public class arenaScreenBuild extends JPanel{ int pX=200, pY=150; public void updateScreen(){ repaint(); } public void paintComponent(Graphics g) { g.drawString("x:"+pX, 535, 525); g.drawString("y:"+pY, 535, 545); } public void refreshXY(int x, int y){ pX=x; pY=y; System.out.println("Refreshed X&amp;Y"); updateScreen(); } } </code></pre> <p>This is the screen displaying the graphics. When run, every time i move(press the right arrow key), it displays "Refreshed X&amp;Y" but even though it calls the updateScreen() method, the displayed items are not redrawn. The code, if it had worked, should display x:XVALUE, y:YVALUE after the "refreshed X&amp;Y".</p> <pre><code> public class ArenaKeys extends KeyAdapter { arenaScreenBuild arenaBG = new arenaScreenBuild(); int xPos = 0, playerFace = 4,xPPos = 200, yPPos = 150; public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == e.VK_RIGHT) { if (xPos &lt;= 3250) if (((xPos + xPPos) &gt;= 825) &amp;&amp; ((xPos + xPPos) &lt;= 910) &amp;&amp; (yPPos &gt;= 170) &amp;&amp; (yPPos &lt;= 255)) { } else if (((xPos + xPPos) &gt;= 1325) &amp;&amp; ((xPos + xPPos)&lt;= 1410) &amp;&amp; (yPPos &gt;= 170) &amp;&amp; (yPPos &lt;= 255)) { } else xPos += 5; } arenaBG.refreshXY(xPPos+xPos,yPPos); } } </code></pre> <p><strong>EDIT:</strong> *<em>Turns out that it does work but what i was doing was adding a Drawpanel on top of another drawpanel and this code was for the one underneath so it wasn't letting the bottom code update, i solved this by merging together the two codes for both drawpanels.</em>*</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload