2013-06-27 111 views
0

我試圖將JGoodies面板放入只有垂直滾動條的JScrollPane中;任何大於當前JScrollPane寬度的元素都應該被截斷。但是我不能想出一個辦法,使這項工作的我要爲 Good example將JGoodies面板的最大寬度設置爲JScrollPane大小

我不希望發生 bad example

我當前的代碼是什麼效果

例主要有:

FormLayout locationsLayout = new FormLayout("15dlu, pref, 5dlu, pref, 5dlu, pref:grow", ""); 
    locationsBuilder = new DefaultFormBuilder(locationsLayout) 
      .background(Color.WHITE) 
      .lineGapSize(Sizes.ZERO); 
    locationsPane = new JScrollPane(locationsBuilder.getPanel()); 
    locationsPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); 
    locationsPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); 

    //...Sometime later, the user adds a folder... 
    FormLayout headerLayout = new FormLayout("pref, pref", "pref"); 
    DefaultFormBuilder headerBuilder = new DefaultFormBuilder(headerLayout) 
      .background(Color.WHITE) 
      .lineGapSize(Sizes.ZERO); 
    headerBuilder.add(curContainer.getGuiHeader(), CC.xy(1, 1)); 
    headerBuilder.add(curContainer.getGuiTablePrefix(), CC.xy(2, 1)); 
    locationsBuilder.leadingColumnOffset(0); 
    locationsBuilder.append(headerBuilder.getPanel(), 6); 

事情我已經試過

  • 是min,pref的各種排列生長,填充等沒有什麼改變了這種行爲
  • 傳遞實現滾動到locationsBuilder DefaultFormBuilder構造爲自訂的JPanel記錄herehere,或here
  • 嘗試另一垂直滾動JScrollPane上的酒吧選項

我不知道還有什麼我可以嘗試。有人有任何建議嗎?

回答

1

我永遠無法找到這個特定設置的確切答案。我的猜測是,JGoodies死了一點處理嵌套佈局非常好。

我最終通過在整個位置滾動窗格中只使用一個面板來「解決」這個問題。這使得佈局有點複雜:多個單元現在不得不跨越列,我不得不手動調整列偏移量。但最終它的作品