Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

TUTORIALVaadin lets you build secure, UX-first PWAs entirely in Java.
Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Calling javascript synchronously by Enver Haase, 2 weeks ago
Make Accordion change width to display its contents
How can I make an Accordion automatically change its width to be wide enough to show all of its contents?
Screen shot of Accordion too narrow:
Short example app:
package com.example.dummy;
import com.vaadin.Application;
import com.vaadin.ui.*;
@SuppressWarnings ( "serial")
public class DummyApplication extends Application {
@Override
public void init() {
Accordion accordion = new Accordion();
accordion.addTab( this.makeListSelect(), "Apple", null );
accordion.addTab( this.makeListSelect(), "Banana", null );
accordion.addTab( this.makeListSelect(), "Grape", null );
HorizontalLayout layout = new HorizontalLayout();
layout.setMargin( true );
layout.addComponent( accordion );
// Display on screen. - - - - - - - -
Window window = new Window( "Make Accordion Wide Enough For Content" );
window.setContent( layout );
setMainWindow( window );
}
private ListSelect makeListSelect() {
ListSelect listSelect = new ListSelect( null );
listSelect.addItem( "Very long content in this item" );
listSelect.addItem( "Yet another very long content in this item" );
listSelect.addItem( "Still more long content to be read in this item" );
return listSelect;
}
}
Last updated on Mar, 12th 2012
Currently you cannot.
The Accordion measures its undefined width based on the widest caption width and not based on the content. You will either have to set a size (relative or pixel) for the Accordion, or expand the caption text width.
Last updated on Mar, 13th 2012
Set width and height for both window and accordion.
Example,
window.setSizeFull();
and
accordion.setSizeFull();
Last updated on
You cannot reply to this thread.