2

私は groovy と griffon が初めてで、現在 SwingBuilder で少し遊んでいます。JSplitPane のサブクラスを追加したいと思います ( http://www.formdev.com/blog/swing-tip-jsplitpane-with-zero-size-divider/で説明されているように、細い仕切りを使用します)。

以下に、ビュー定義スクリプトがあります。Container()-Element を使用して、Splitpane サブクラスを追加しました。アプリケーションを開始すると、java.lang.IllegalArgumentException が発生します。これを修正する方法はありますか?


景色:

frame(id:"frame",
 title: 'The new database explorer implemented with groovy/griffon',
 size: [600, 400],
 locationByPlatform:true,
 iconImage: imageIcon('/griffon-icon-48x48.png').image,
 iconImages: [imageIcon('/griffon-icon-48x48.png').image,
              imageIcon('/griffon-icon-32x32.png').image,
              imageIcon('/griffon-icon-16x16.png').image]) {

   panel (id:'mainPanel',
           opaque:false) {
       borderLayout()
       toolBar(id:'toolBar',
               constraints:NORTH,
               floatable:false,
               opaque: false,
               preferredSize: new Dimension(200,50)) {
           hglue()
           textField(id:'search', "clientPropertyJTextField.variant":"search",
                   maximumSize: new Dimension(150,35),
                   preferredSize: new Dimension(150,35))
       }
       panel(id: 'centerPanel',
               constraints: CENTER,
               opaque: true,
               background: new Color(238, 238, 238)) {
           borderLayout()
           container (new SplitPaneWithThinDivider(),
                      id:'mainSplitPane',
                      constraints: CENTER,
                      dividerLocation: 150
                      ) {
               scrollPane(id:'treeScroller', border:null) {
                   tree(id:'explorerTree',
                           rootVisible: false)
               }
               scrollPane(border:null) {
                   textArea()
               }
           }
       }
   }
}

例外:

2012-03-15 06:45:01,778 [AWT-EventQueue-0] エラー org.codehaus.griffon.runtime.builder.UberBuilder - at.rehdie.dbexp.main.ExplorerFrameView@59c87031 のビルド中にエラーが発生しました
java.lang.IllegalArgumentException: レイアウトに追加できません: 不明な制約: null
    java_awt_Container$add.call で (不明なソース)
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod (UberInterceptorMetaClass.groovy:96) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent (不明なソース) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod (UberInterceptorMetaClass.groovy:140) で
    at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4_closure7_closure8.doCall(ExplorerFrameView.groovy:54) で
    at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4_closure7_closure8.doCall(ExplorerFrameView.groovy) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod (UberInterceptorMetaClass.groovy:96) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent (不明なソース) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod (UberInterceptorMetaClass.groovy:140) で
    at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4_closure7.doCall(ExplorerFrameView.groovy:49) で
    at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4_closure7.doCall(ExplorerFrameView.groovy) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod (UberInterceptorMetaClass.groovy:96) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent (不明なソース) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod (UberInterceptorMetaClass.groovy:140) で
    at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4.doCall(ExplorerFrameView.groovy:47) で
    at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4.doCall(ExplorerFrameView.groovy) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod (UberInterceptorMetaClass.groovy:96) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent (不明なソース) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod (UberInterceptorMetaClass.groovy:140) で
    at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2.doCall(ExplorerFrameView.groovy:31) で
    at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2.doCall(ExplorerFrameView.groovy) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod (UberInterceptorMetaClass.groovy:96) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent (不明なソース) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod (UberInterceptorMetaClass.groovy:167) で
    at.rehdie.dbexp.main.ExplorerFrameView.run(ExplorerFrameView.groovy:23) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod (UberInterceptorMetaClass.groovy:151) で
    org.codehaus.griffon.runtime.builder.UberBuilder.build(UberBuilder.groovy:155) で
    org.codehaus.griffon.runtime.core.AbstractMVCGroup$1.run(AbstractMVCGroup.java:129) で
2012-03-15 06:45:01,781 [メイン] エラー griffon.util.GriffonExceptionHandler - キャッチされていない例外
java.lang.RuntimeException: java.lang.IllegalArgumentException: レイアウトに追加できません: 不明な制約: null
    griffon.swing.SwingUIThreadHandler.executeSync (SwingUIThreadHandler.java:46) で
    griffon.core.UIThreadManager.executeSync(UIThreadManager.java:247)で
    org.codehaus.griffon.runtime.core.AbstractMVCGroup.buildScriptMember (AbstractMVCGroup.java:127) で
    org.codehaus.griffon.runtime.core.DefaultMVCGroupManager.initializeMembers (DefaultMVCGroupManager.java:230) で
    org.codehaus.griffon.runtime.core.DefaultMVCGroupManager.buildMVCGroup (DefaultMVCGroupManager.java:149) で
    org.codehaus.griffon.runtime.core.AbstractMVCGroupManager.createMVCGroup (AbstractMVCGroupManager.java:238) で
    org.codehaus.griffon.runtime.core.AbstractMVCGroupManager.createMVCGroup (AbstractMVCGroupManager.java:186) で
    org.codehaus.griffon.runtime.core.AbstractGriffonApplication.createMVCGroup (AbstractGriffonApplication.java:499) で
    org.codehaus.griffon.runtime.core.AbstractGriffonApplication.startup (AbstractGriffonApplication.java:313) で
    griffon.swing.AbstractSwingGriffonApplication.realize (AbstractSwingGriffonApplication.java:78) で
    griffon.swing.AbstractSwingGriffonApplication.run (AbstractSwingGriffonApplication.java:132) で
    griffon.swing.SwingApplication.main(SwingApplication.java:36)
原因: java.lang.IllegalArgumentException: レイアウトに追加できません: 不明な制約: null
    java_awt_Container$add.call で (不明なソース)
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod (UberInterceptorMetaClass.groovy:96) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent (不明なソース) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod (UberInterceptorMetaClass.groovy:140) で
    at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4_closure7_closure8.doCall(ExplorerFrameView.groovy:54) で
    at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4_closure7_closure8.doCall(ExplorerFrameView.groovy) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod (UberInterceptorMetaClass.groovy:96) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent (不明なソース) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod (UberInterceptorMetaClass.groovy:140) で
    at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4_closure7.doCall(ExplorerFrameView.groovy:49) で
    at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4_closure7.doCall(ExplorerFrameView.groovy) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod (UberInterceptorMetaClass.groovy:96) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent (不明なソース) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod (UberInterceptorMetaClass.groovy:140) で
    at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4.doCall(ExplorerFrameView.groovy:47) で
    at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2_closure4.doCall(ExplorerFrameView.groovy) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod (UberInterceptorMetaClass.groovy:96) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent (不明なソース) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod (UberInterceptorMetaClass.groovy:140) で
    at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2.doCall(ExplorerFrameView.groovy:31) で
    at.rehdie.dbexp.main.ExplorerFrameView$_run_closure2.doCall(ExplorerFrameView.groovy) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeFactoryMethod (UberInterceptorMetaClass.groovy:96) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.this$3$invokeFactoryMethod(UberInterceptorMetaClass.groovy) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass$this$3$invokeFactoryMethod.callCurrent (不明なソース) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod (UberInterceptorMetaClass.groovy:167) で
    at.rehdie.dbexp.main.ExplorerFrameView.run(ExplorerFrameView.groovy:23) で
    org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod (UberInterceptorMetaClass.groovy:151) で
    org.codehaus.griffon.runtime.builder.UberBuilder.build(UberBuilder.groovy:155) で
    org.codehaus.griffon.runtime.core.AbstractMVCGroup$1.run(AbstractMVCGroup.java:129) で
4

3 に答える 3

2

野生の、テストされていない推測ですが、次のことを行います。

       widget( new SplitPaneWithThinDivider(),
               id:'mainSplitPane',
               constraints: CENTER,
               dividerLocation: 150,
               leftComponent: scrollPane(id:'treeScroller', border:null) {
                 tree(id:'explorerTree', rootVisible: false )
               },
               rightComponent: scrollPane(border:null) {
                 textArea()
               } )

まったく機能しますか?

于 2012-03-16T12:45:01.197 に答える
0

Griffon 0.9.5-rc2 でコードを試してみましたが、カスタム SplitPaneWithThinDivider コンポーネントにアクセスできないため、frame() の代わりに application() と splitPane() を使用しました。ExplorerFrameView はセカンダリ MVC グループに属していると思います。frame() の代わりに application() を使用してみましたか?

このノードは frame() とほぼ同じ動作をしますが、アプレットの処理方法を認識しているため、ビューごとに同じ数の application() ノードを使用できます。

于 2012-03-16T13:14:07.413 に答える
0

ご回答ありがとうございます。Tim のバージョンは完全に動作します。私も次のことを試しました:

splitPane (new SplitPaneWithThinDivider(),
           id:'mainSplitPane',
           constraints: CENTER,
           dividerLocation: 150,
           "clientPropertyQuaqua.Tree.style": "sideBar",
           border: null) {

   scrollPane(id:'treeScroller', border:null) {
       tree(id:'explorerTree',
            rootVisible: false)
   },           
   scrollPane(border:null) {
       textArea()
   }           
}

しかし、この方法では、スプリットペインの左コンポーネントは常にデフォルトの「左ボタン」でした ( のnew JSplitPane()代わりに使用した場合も同様でしたnew SplitPaneWithThinDivider())。

に変更したところ

splitPane (new SplitPaneWithThinDivider(),
           id:'mainSplitPane',
           constraints: CENTER,
           dividerLocation: 150,
           "clientPropertyQuaqua.Tree.style": "sideBar",
           border: null) {

   scrollPane(id:'treeScroller', border:null) {
       tree(id:'explorerTree',
            rootVisible: false)
   },           
   scrollPane(border:null) {
       textArea()
   }           
}
bean(mainSplitPane, leftComponent: treeScroller)

出来た。

于 2012-03-17T07:05:10.997 に答える