Page 2 of 2 FirstFirst 12
Results 21 to 32 of 32
Like Tree1Likes

Thread: Java Event Dispatch Thread (EDT)

  1. #21
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,891
    Rep Power
    25

    Default Re: Java Event Dispatch Thread (EDT)

    Have you done any debugging with the code?
    Is the paintComponent() method in the TransparentPanel class being called?
    If you don't understand my response, don't ignore it, ask a question.

  2. #22
    iFrozen94 is offline Member
    Join Date
    Feb 2014
    Posts
    18
    Rep Power
    0

    Default Re: Java Event Dispatch Thread (EDT)

    1. Have you done any debugging with the code?
    2. Is the paintComponent() method in the TransparentPanel class being called?
    1. Yes, i have done debugging with the code.
    2. No, i do not call paintComponent() method.

  3. #23
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,354
    Rep Power
    6

    Default Re: Java Event Dispatch Thread (EDT)

    That's not what he asked though; he asked if it was being called. Of course you don't call it, Swing itself is supposed to be doing that. And that's the question: is Swing doing that as would be expected?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #24
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,891
    Rep Power
    25

    Default Re: Java Event Dispatch Thread (EDT)

    What did you discover when you debugged the code?
    If you don't understand my response, don't ignore it, ask a question.

  5. #25
    iFrozen94 is offline Member
    Join Date
    Feb 2014
    Posts
    18
    Rep Power
    0

    Default Re: Java Event Dispatch Thread (EDT)

    Quote Originally Posted by Norm View Post
    What did you discover when you debugged the code?
    The code which i debug doesn't related to any appearance of the program, most of them are logic error such as validation. After i debug, i run the program and it works but sometime the problem occur. ( After fix the validation error, i doesn't change or adding any code anymore, i running the same code everytime ).
    Note* My code does not add any components during the run-time.

  6. #26
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,891
    Rep Power
    25

    Default Re: Java Event Dispatch Thread (EDT)

    Were you able to find changes to the code so that the paintComponent() method was called? It is NOT called with the posted code.
    If you don't understand my response, don't ignore it, ask a question.

  7. #27
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,025
    Rep Power
    6

    Default Re: Java Event Dispatch Thread (EDT)

    BTW, your Transparent panel has no size. So it's paintComponent method is not being called.

    Regards,
    Jim
    gimbal2 likes this.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  8. #28
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,025
    Rep Power
    6

    Default Re: Java Event Dispatch Thread (EDT)

    It would appear that unlike FlowLayout which will size the components and display them properly based on position, GridBagLayout will not do that. This is strictly my observation. So you must set a specific size of your Transparent panel. Once you do that, it will become opaque regardless of the frame transparency (which is what you are seeing). So you must setOpaque() to false in your transparent panel for the alpha value to take effect.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  9. #29
    iFrozen94 is offline Member
    Join Date
    Feb 2014
    Posts
    18
    Rep Power
    0

    Default Re: Java Event Dispatch Thread (EDT)

    Quote Originally Posted by jim829 View Post
    It would appear that unlike FlowLayout which will size the components and display them properly based on position, GridBagLayout will not do that. This is strictly my observation. So you must set a specific size of your Transparent panel. Once you do that, it will become opaque regardless of the frame transparency (which is what you are seeing). So you must setOpaque() to false in your transparent panel for the alpha value to take effect.

    Regards,
    Jim
    Owh ... so the transparency effect which i get is from the setBackground(new Color(0,0,0,150)); of JFrame. So, all the subclasses of JComponent which has paintComponent() method will paint itself only? JPanel will only responsible for painting JPanel but doesn't not paint the components which added to it?

  10. #30
    iFrozen94 is offline Member
    Join Date
    Feb 2014
    Posts
    18
    Rep Power
    0

    Default Re: Java Event Dispatch Thread (EDT)

    Quote Originally Posted by Norm View Post
    Were you able to find changes to the code so that the paintComponent() method was called? It is NOT called with the posted code.
    Sorry about that. I'm still a newbie. I think i have understand about how paintComponent() works now. The problem occurred maybe is caused by my own coding problem. By the way, thanks for trying to help me

  11. #31
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,025
    Rep Power
    6

    Default Re: Java Event Dispatch Thread (EDT)

    Actually, I may have been mistaken. It looks like the transparency is a combination of both JFrame and the Transparency panel. But the calling of paintComponent changes when using a different layout manager. I am not certain why. Others may have to provide the exact reason.

    Edit: Hmm, it appears to be a combination when using GridBagLayout for both JFrame and JPanel. Which begs the question. Why are you using GridBagLayout for your JFrame? You aren't specifying any constraints.

    Regards,
    Jim
    Last edited by jim829; 02-05-2014 at 07:46 PM.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  12. #32
    iFrozen94 is offline Member
    Join Date
    Feb 2014
    Posts
    18
    Rep Power
    0

    Default Re: Java Event Dispatch Thread (EDT)

    Quote Originally Posted by jim829 View Post
    Actually, I may have been mistaken. It looks like the transparency is a combination of both JFrame and the Transparency panel. But the calling of paintComponent changes when using a different layout manager. I am not certain why. Others may have to provide the exact reason.

    Edit: Hmm, it appears to be a combination when using GridBagLayout for both JFrame and JPanel. Which begs the question. Why are you using GridBagLayout for your JFrame? You aren't specifying any constraints.

    Regards,
    Jim
    No, that was not your mistake. The transparency effect was come from JFrame only. I have tested add System.out.println("Painted"); to the paintComponent() of TransparentPanel and "Voilah" , the paintComponent() method doesn't been called. After i change the layout of JFrame to BorderLayout then "YES", the paintComponent() of TransparentPanel has been called.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Cant dispatch event or listener?
    By heatblazer in forum Advanced Java
    Replies: 5
    Last Post: 05-25-2013, 10:58 PM
  2. Dispatch event Mousemoved more humanlike
    By coolking in forum AWT / Swing
    Replies: 3
    Last Post: 02-03-2012, 11:36 PM
  3. Replies: 5
    Last Post: 04-14-2010, 06:26 AM
  4. How to send event from thread to GUI?
    By mikeeve in forum New To Java
    Replies: 3
    Last Post: 03-13-2009, 03:33 AM
  5. Error: Exception during event dispatch!
    By Javid in forum AWT / Swing
    Replies: 1
    Last Post: 08-02-2008, 02:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •