Java 如何通过Spring setter注入设置JFrame的大小?

Java 如何通过Spring setter注入设置JFrame的大小?,java,spring,swing,Java,Spring,Swing,我正在尝试使用Spring初始化JFrame。框架出现了,直到我设置了size属性(MainFrame只是扩展了JFrame) JFrame类有一个setter setSize(维度)和一个getter getSize(维度)。我做错了什么?

我正在尝试使用Spring初始化JFrame。框架出现了,直到我设置了size属性(MainFrame只是扩展了JFrame)


JFrame类有一个setter setSize(维度)和一个getter getSize(维度)。我做错了什么?

有两个重载版本:
setSize(int,int)
setSize(java.awt.Dimension)
。所以spring猜测大小不是bean属性。


<bean id="frame" class="javax.swing.JFrame">
        <property name="title" value="First swing-spring project"/>
                <property name="size"> 
            <bean class="java.awt.Dimension">
                <constructor-arg value="300"/>
                <constructor-arg value="400"/>
            </bean>
        </property>
        <property name="defaultCloseOperation" value="3"/>
        <property name="visible" value="true"/>

    </bean>

这是否是一种好的做法,这不应该奏效吗?
NotWritablePropertyException: Invalid property 'size' of bean class [package.MainFrame]: Bean property 'size' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
<bean id="frame" class="javax.swing.JFrame">
        <property name="title" value="First swing-spring project"/>
                <property name="size"> 
            <bean class="java.awt.Dimension">
                <constructor-arg value="300"/>
                <constructor-arg value="400"/>
            </bean>
        </property>
        <property name="defaultCloseOperation" value="3"/>
        <property name="visible" value="true"/>

    </bean>