私はSWINGを使用しており、単純なグループレイアウトで書いています
レイアウト用に次のコードを書きました。
JPanel unterPanel = new JPanel();
GroupLayout layout = new GroupLayout(unterPanel);
unterPanel.setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
layout.setHorizontalGroup(
layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(header)
.addComponent(tableG)
.addGroup(layout.createSequentialGroup()
.addComponent(b3)
.addComponent(b4)
.addComponent(b5)
.addComponent(b6)
))
);
layout.setVerticalGroup(
layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(b3)
.addComponent(b4)
.addComponent(b5)
.addComponent(b6)
)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(header)
.addComponent(tableG))
);
layout.linkSize(SwingConstants.HORIZONTAL, b3, b4, b5, b6);
return unterPanel;
しかし、コードをコンパイルすると、次のようになります。
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Component must be non-null
at javax.swing.GroupLayout$ComponentSpring.<init>(GroupLayout.java:2878)
at javax.swing.GroupLayout$ComponentSpring.<init>(GroupLayout.java:2858)
at javax.swing.GroupLayout$Group.addComponent(GroupLayout.java:1490)
at javax.swing.GroupLayout$ParallelGroup.addComponent(GroupLayout.java:2414)
at javax.swing.GroupLayout$ParallelGroup.addComponent(GroupLayout.java:2384)
at javax.swing.GroupLayout$Group.addComponent(GroupLayout.java:1471)
at javax.swing.GroupLayout$ParallelGroup.addComponent(GroupLayout.java:2406)
at gui.guimain.Produktmaingui(guimain.java:97)
at gui.guimain.showStart(guimain.java:306)
at gui.guimain$1.run(guimain.java:410)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
なんで?
あなたの答えに感謝します!!!