scrollPane.setHorizontalScrollBarPolicy(ScrollBarPolicy.FILL);
scrollPane.setVerticalScrollBarPolicy(ScrollBarPolicy.FILL_TO_CAPACITY);
scrollPane.setRepaintAllViewport(true); // workaround for pivot-738, needed only in in some cases
boxPane.add(scrollPane);
final ListView listView = new ListView();
List<String> listData = new ArrayList<String>();
for (int i = 0; i < 50; ++i) {
listData.add("List Item " + i);
}
listView.setListData(listData);
scrollPane.setView(listView);
listView.getListViewSelectionListeners().add(new ListViewSelectionListener.Adapter() {
@Override
public void selectedItemChanged(ListView listViewArgument, Object previousSelectedItem) {
System.out.println("selectedItemChanged : " + listViewArgument.getSelectedItem());
}
});
listView.getComponentMouseButtonListeners().add(new ComponentMouseButtonListener.Adapter() {
@Override
public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
System.out.println("mouseClick : " + count);
if (count == 2) {
System.out.println("double click, now open a detail frame");
Frame detailFrame = new Frame();
detailFrame.setTitle("Detail Frame");
detailFrame.setPreferredSize(400, 300);
int selectedIndex = listView.getSelectedIndex();
detailFrame.setLocation(80 + (selectedIndex * 10), 80 + (selectedIndex * 10));
detailFrame.getStyles().put("padding", new Insets(0, 0, 0, 0));
BoxPane boxPaneLocal = new BoxPane();
boxPaneLocal.getStyles().put("fill", true);
boxPaneLocal.setOrientation(Orientation.VERTICAL);
detailFrame.setContent(boxPaneLocal);
String selectedItem = listView.getSelectedItem().toString();
Label label = new Label("Selected Item is \"" + selectedItem + "\"");
boxPaneLocal.add(label);
boxPaneLocal.add(new Label("")); // spacer
boxPaneLocal.add(new Label("Click inside the text input to focus it"));
TextInput textInput = new TextInput();
textInput.setText("Focusable component");
boxPaneLocal.add(textInput); // workaround for pivot-811: add a focusable element inside the frame
detailFrame.open(displayArgument);
// workaround for pivot-811: force the focus on the first focusable element inside the frame
detailFrame.requestFocus();
// textInput.requestFocus(); // or use this ...
}
return true;
}
});
listFrame.open(displayArgument);
listView.setSelectedIndex(0);
listView.requestFocus();
}