誰かが助けてくれることを望んでいました。これは単純な問題であるはずだが、私の人生にとってはうまくいかない。JPanelが追加されたときにJScrollPaneがスクロールしない
問題:ImageIcons
という5つのラベルを含むパネルで構成されるJPanel
を作成しています。 [混乱する音]
このパネルをJScrollPane
に追加します。しかし、それが表示されているときに、画像が表示され、正しく配置されていますが、スクロールして画面外のパネルを見ることができません。ここ
はスクリーンショットです:ここではhttp://img841.imageshack.us/img841/36/screenshot20120510at160.png
は、私は、パネルを移入し、JScrollPane
を追加するために使用していたコードのスニペットです。
private void setSeriesViewContainer(){
container = new BackgroundPanel(backGround, BackgroundPanel.TILED);
//container.setPreferredSize(new Dimension(650,500));
container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));
FlowLayout flowLayout = new FlowLayout();
JPanel[] jp = new BackgroundPanel[10];
for (int i = 0; i < jp.length; i++) {
jp[i] = new BackgroundPanel(backGround, BackgroundPanel.TILED);
jp[i].setLayout(flowLayout);
for (int j = 0; j < 10; j++) {
jp[i].add(new JLabel(new ImageIcon(getClass().getResource("/placeHolder.png"))));
}
}
for (int i = 0; i < jp.length; i++) {
container.add(jp[i]);
}
public void init(){
seriesViewContainer = new javax.swing.JScrollPane(container);
seriesViewContainer.setBorder(null);
seriesViewContainer.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
seriesViewContainer.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
seriesViewContainer.setPreferredSize(new java.awt.Dimension(700, 300));}
解決策については検索しましたが、まだ解決策はありません。
コードの書式設定にもう少し時間がかかることがあります。それは読むのをより容易にし、助けを受けるでしょう。 –
また、[SSCCE](http://sscce.org/)は、スクリーンショットよりもGUIのより完全な「画像」を描くことにも注意してください。 –