GroupLayout给出了java swing的错误 [英] GroupLayout giving error with java swing

查看:622
本文介绍了GroupLayout给出了java swing的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到了很多错误。任何人都可以通过 <$向我建议我出错的地方c $ c> GroupLayout

I am getting a long list of errors. Can anyone suggest to me where I am going wrong with GroupLayout.

layout.setHorizontalGroup(
    layout.createSequentialGroup()
        .addComponent(new JLabel("Enter Book Name"))
        .addComponent(new JTextField("TextField", 20))
);

错误:


    Exception in thread "main" java.lang.IllegalStateException:
        javax.swing.JTextField[,0,0,0x0,invalid,layout=javax.swing.
            plaf.basic.BasicTextUI$UpdateHandler,alignmentX=0.0,
            alignmentY=0.0,border=javax.swing.plaf.BorderUIResource$
            CompoundBorderUIResource@3d0bbf9e,flags=296,maximumSize=,
            minimumSize=,preferredSize=,caretColor=sun.swing.
            PrintColorUIResource[r=51,g=51,b=51],disabledTextColor=javax
            .swing.plaf.ColorUIResource[r=184,g=207,b=229],editable=true
            ,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,
            bottom=0,right=0],selectedTextColor=sun.swing.
            PrintColorUIResource[r=51,g=51,b=51],selectionColor=javax.
            swing.plaf.ColorUIResource[r=184,g=207,b=229],columns=20,
            columnWidth=0,command=,horizontalAlignment=LEADING]
            is not attached to a vertical group
            at javax.swing.GroupLayout.checkComponents(Unknown Source)
            at javax.swing.GroupLayout.prepare(Unknown Source)


推荐答案

使用GroupLayout时,必须指定水平和垂直布局。每个组件必须在每个组中指定一次。不执行此操作会导致此错误。

When you use GroupLayout, you have to specify a Horizontal and a Vertical layout. Each component must be specified exactly once in each group. Not doing this causes this error.

此外,请确保正确填充每个项目。如果你正在制作网格,请确保两个方向都是平行序列,反之亦然。如果你要制作一排按钮或其他东西,请确保它们是单向并行顺序的。

Additionally, make sure you cross hatch each item properly. If you're making.a grid, be sure that both directions are sequences of parallels or vice versa. If you are making one row of buttons or something, make sure they are parallel one way and sequential another.

这篇关于GroupLayout给出了java swing的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆