我有一个文本窗格,我想添加到JscrollPane。但我看不到文本框。这有什么不对?
crimepanel.setBounds(new Rectangle(660, 250, 295, 35));
scroll.setBounds(new Rectangle(655, 240, 305, 55));
scroll.add(crimepanel);
this.getContentPane().add(scroll, null);
this.getContentPane().add(crimepanel, null);
答案 0 :(得分:1)
我明白了!正确的代码是:
scroll.getViewport().add(crimepanel, null);
this.getContentPane().add(scroll, null);