3 Replies Latest reply on Jan 3, 2012 10:32 AM by gimbal2

    Repaint() JApplet from JDialog event?

      Hello, I have a paint() method on a JApplet that display an image from a database in JLabel which you can click and it will display a JDialog so you can edit the image, using another paint() method on it, when you update the image in the database, I'd like to repaint() the void method on the Japplet so it can display the updated image, I already tried using:
      After the image is saved, but nothing happens! If I add a JButton to the JApplet with
      and click it after saving the image, it is repainted, but I'd like to do it automatically when you save the image from JDialog, because as fas as I understand I should be able to repaint the JApplet while the other one is open right? or should I do a repaint() when closing the JDialog? because I already tried and did not work, any help? thanks in advanced!

      EDIT: It works fine when using a JFrame instead of Japplet, everytime I save the image into the database, the JFrame repaints itself since it's reading the image from database, what can I do to make it work from JApplet which I need? Something else I have noticed, both JApplet form and JDialog uses a paint() method, but when I close the JDialog, it opens again, like in a loop, how can I avoit it? I know it's because of both paint methods, because when I remove paint() from JApplet, works fine.

      Edited by: saman0suke on 02-ene-2012 8:19
        • 1. Re: Repaint() JApplet from JDialog event?
          Isn't this a continuation of your thread from a few days earlier?
          How to pass a value from a JApplet to a JDialog?

          By the way, your cross-post to the Swing forum has been deleted.
          Don't multi-post.
          • 2. Re: Repaint() JApplet from JDialog event?
            Yeah, actually I'm with the same project, it's almost done, I have a JApplet wich shows the preview of the original image taken from the database, then I click on it and the JDialog allows you to rotate the image and then update it into the database, but I'd like to repaint the JApplet right after you save the new one to the database or closing the JDialog.

            I initially used a void method to display the preview of the image, but now I'm trying by displaying the image using a paint() method, it works, BUT ONLY if I use a JFrame, it does not work with a JApplet, and it has a strange behavior, because sometimes, when I close the JDialog, it shows up again, like being in a loop, only when I use paint() method on both JApplet and JDialog, any help would be appreciated, thanks!!

            The other thread was deleted, I requested it myself :) I do apologize for the mistake.

            EDIT: I just came up with an alternative, please tell me if it's recommended, everytime I click on the image, I start a thread which receives a value, that value is filled when the image is updated in the database, when the value is received, I execute the void method who generates the image, and I can see the new image on JApplet, could this be a valid method? I haven't experienced any decrease on performance so far, and it's working on JApplet which is I want.

            Ok, I stil have the same problem when I close the JDialog, even using a thread, sometimes it works as it should, but sometimes when I close the JDialog, it reopens itself, this Is what I do to open the JDialog from JApplet:
                        jLabel1.addMouseListener(new java.awt.event.MouseAdapter() {
                            public void mouseClicked(java.awt.event.MouseEvent evt){
                                //Instantiate thread
                                Thread test1 = new Thread(thr1);
                                //Instantiate jDialog since jDialog is a separate class (JDialog form according to Netbeans)
                                jDialog_1 jd1 = new jDialog_1(new javax.swing.JFrame(), true);
                                jd1.setSize(400, 400);
            Any idea?

            Edited by: saman0suke on 02-ene-2012 9:43

            Edited by: saman0suke on 02-ene-2012 9:45
            • 3. Re: Repaint() JApplet from JDialog event?
              dialogs don't "reopen" themselves. Put some logging (like a simple System.out) in that mouse listener, something tells me you'll see two lines of logging in the instances that the dialog magically reappears.