2016-08-03 8 views

回答

0

因此,我創建一個滾動容器的BoxLayout沿y軸並試圖利用SpanLabels,但它顯示爲普通標籤。我錯過了什麼嗎?

這是不工作的關鍵。我調用了container.setScrollable(true),它使得它可以在x和y中滾動,所以儘管我使用了SpanLabel,但它仍然顯示在一行上,因爲它可以水平滾動。這個:

this.container.setLayout(new BoxLayout(BoxLayout.Y_AXIS)); 
    this.container.setScrollableY(true); 
    this.container.setScrollableX(false); 

固定它給我。

0
Form f = new Form("Span", BoxLayout.y()); 

f.add(new SpanLabel("Short")); 
f.add(new SpanLabel("Not so short")); 
f.add(new SpanLabel("Not so long as to line break")); 
f.add(new SpanLabel("This should totally line break because it's getting to that length where it should have an effect")); 
f.add(new SpanLabel("Short")); 
f.add(new SpanLabel("Not so short")); 
f.add(new SpanLabel("Not so long as to line break")); 
f.add(new SpanLabel("This should totally line break because it's getting to that length where it should have an effect")); 

f.show();  

enter image description here