Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1055251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:32:03+00:00 2026-05-16T17:32:03+00:00

Hi guys I have a problem that makes me really confused, I have ‘writeMethod’

  • 0

Hi guys I have a problem that makes me really confused, I have ‘writeMethod’ which is a type of Method class, ‘dpv’ which is a type of a propertyDescriptor, i retrieved the writeMethod of the object by getWriteMethod(), now my problem is how to set ‘writeMethod’ to write on a property of an object (e.g. JLabel, JButton) here is my code :

 if(dpv.getPropertyType().isPrimitive() 
         || dpv.getPropertyType().isInstance("Integer") )
        {
            Method writeMethod = dpv.getWriteMethod();

            //setWriteMethod(writeMethod);<---------- Not sure about this part (doesn't work)

            System.out.println(writeMethod);
            PropertyValue.setEnabled(true);
            SetButton.setEnabled(true);
        }
        else{

            PropertyValue.setEnabled(false);
            SetButton.setEnabled(false);
        }

Thanks for your help guys

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:32:03+00:00Added an answer on May 16, 2026 at 5:32 pm

    To use the method to write the propery, you have to invoke it. Simple properties take a single value – the value of the property, so you invoke the method with a single argument. The following code sets the property on a button to the value 42:

    Method writeMethod = dpv.getWriteMethod();    
    JButton button = ...; // the target to write to
    
    try
    {
       writeMethod.invoke(button, 42);
    }
    catch (IllegalAccessException ex)
    {
      // handle these as appropriate
    }
    catch (IllegalArgumentException ex)
    {
    }
    catch (InvocationTargetException ex)
    {
    }
    

    It’s unlikely you have them, but if the property is the seldom-used indexed property type, then you need to use the method like this:

    writeMethod.invoke(target, index, propertyValue);
    

    This corresponds to the setter method

    setIndexProperty(int index, PropertyType value);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys, I have a weird problem. I have an update system that refreshes
Ok guys, I have a serious problem with this. I have a static class
hey guys having this really simple problem but cant seem to figure out have
Hey guys, I have another really annoying problem in IE. I am using a
Hey guys, I'm getting a really strange error. I have a program that needs
Hi guys i have a problem i my code i set a datepicker with
guys. I have a strange problem. I try to write unit-tests to web-app. I
I hope some of you guys can help me with this problem.... I have
I have a method which have this signature public static IList<T> GetBy<T>(System.Linq.Expressions.Expression<Func<T, bool>> expression)
I always have an class which needs to set up a timer for as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.