repaint method « Graphics « Java Swing Q&A





1. Using repaint() method    stackoverflow.com

I'm still struggling to create this game : http://stackoverflow.com/questions/2844190/choosing-design-method-for-ladder-like-word-game .I've got it almost working but there is a problem though. When I'm inserting a word and it's correct, the whole ...

2. Java repaint method does not work when called from another class    stackoverflow.com

I have been coding up Java with Netbeans for about a year now, and have written a lot of data manipulation code which plots graphs on-screen. I generally plant a JPanel ...

3. using repaint() method in this code    stackoverflow.com

I am having a problem using the repaint method in the following code.Please suggest how to use repaint method so that my screen is updated for a small animation. This is my ...

4. Cancel a call to the repaint() method    coderanch.com

5. when method repaint is called??    coderanch.com

6. repaint method and graphics    coderanch.com

I think this may be a stupid question, but i made an applet where an image moves around as you move the mouse, and when you click in the same area as another (stationary) image, the stationary image changes. I managed to get the moving image to stop refreshing so fast by, well im not sure. But anyway, when i put ...

7. Help With Repaint Method    coderanch.com

im working on an RPG game and using a JFrame to show the contents of a JPanel(my container), the problem is in my KeyListener THIS IS THE JFRAME import javax.swing.*; import javax.swing.JApplet; import javax.swing.JRootPane; import java.awt.*; import java.awt.event.*; /** * Class setProg - write a description of the class here * * @author (Devin) * @version (1.1) */ class RPGIntroFrame extends ...

8. repaint() method problem    coderanch.com

9. repaint() method? Something's fishy...    coderanch.com

import javax.swing.*; import java.awt.*; public class jFontSizeDemo extends JApplet { Container myCon = getContentPane(); public void init() { myCon.setLayout(new FlowLayout()); } public void paint(Graphics g) { int x = 0; for(int i = 4; i <= 24; i += 2) { Font myFont = new Font("Times New Roman", Font.PLAIN, i); g.setFont(myFont); g.drawString("Patrick Brooks", x, 0); x += g.getFontMetrics().getHeight(); repaint(); } } ...





10. Calling the repaint() method    coderanch.com

I am developing a game called Tic Tac Toe. I first made a standalone application and then converted it into a JApplet. In my game i have a button called as "New Game". Whenever a user presses this button the game is started all over again. The problem is, i have written some logic for it, but it is not working. ...

11. repaint() method help    coderanch.com

i created a character using paintComponent and i want it to move up and down .. here's the code. import java.awt.*; import javax.swing.JPanel; import javax.swing.JFrame; class charColors extends JPanel { public void paintComponent (Graphics a) { int x1[] = {385,485,525,539,583,505,366,288,337,355}; int y1[] = {322,322,365,370,398,446,446,400,372,360}; int x2[] = {575,540,525,575}; int y2[] = {410,438,425,390}; int x3[] = {299,320,340,325}; int y3[] = {414,405,430,434}; a.setColor(new ...

12. Calling revalidate/repaint in the same method?    coderanch.com

public void actionPerformed (ActionEvent e) { if (e.getActionCommand().equals("LoadIndex")) { try { javax.swing.JPanel tempFP = new javax.swing.JPanel(); tempFP.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); tempFP.add(new JLabel(new ImageIcon ("/resources/loading_animation.gif")), new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 50, -1, -1)); tempFP.revalidate(); tempFP.repaint(); jScrollPaneForFramePanel.setViewportView(tempFP); jScrollPaneForFramePanel.revalidate(); jScrollPaneForFramePanel.repaint(); revalidate(); repaint(); String ing = "http://127.0.0.1/bcb/index.html"; try { framepanel.navigate(ing); jScrollPaneForFramePanel.setViewportView(framepanel); } catch (MalformedURLException ex) { System.err.println(ex.getMessage()); } } catch (Exception ex){ System.err.println(ex.getMessage()); } } // other action commands } ...

13. Does the repaint() method run the paintComponent() method automatically?    coderanch.com

If that's true, I don't understand how that works. import java.awt.Graphics; import java.util.*; import java.text.DateFormat; import java.applet.Applet; public class Clock extends Applet implements Runnable { private Thread clockThread = null; public void start() { if (clockThread == null) { clockThread = new Thread(this, "Clock"); clockThread.start(); } } public void run() { Thread myThread = Thread.currentThread(); while (clockThread == myThread) { repaint(); ...

14. repaint() does not recall an override method paintComponent(), why is that?    java-forums.org

My problem is that repaint() doesn't recall a method paintComponent() and I don't understand why is that, because I thought it should happen automatically. The code is an implementation of the game paper soccer and the idea is that it highlights a vector if the cursor appears when the movement is possible and disappears when it's not, but the board still ...

15. Help with using Swing's 'paintComponent' and 'repaint' methods    java-forums.org

Hello! I am new to Java (having used it for only a few weeks), and this is my first post. In short, I am having some trouble making a rectangle move when a button is pressed. I understand the concept of an actionListener and how it is used, but I am having trouble calling 'repaint'. Here is my code for class ...