// add some sleep to let users see the warning messages in console ...
Thread.sleep(2000);
final CardPane cardPane = new CardPane();
cardPane.getStyles().put("selectionChangeEffect", CardPaneSkin.SelectionChangeEffect.HORIZONTAL_SLIDE);
final Window window = new Window(cardPane);
window.open(display);
DesktopApplicationContext.scheduleRecurringCallback(new Runnable() {
@Override
public void run() {
Thread.currentThread().setName("switcher-thread");
System.out.println("Run num " + num++); // temp
/*
//
// method 1:
//
// Seems to be working just fine
final GridPane grid = new GridPane(3);
grid.getRows().add(createGridRow());
grid.getRows().add(createGridRow());
grid.getRows().add(createGridRow());
*/
//
// method 2:
//
try {
// Before the fixes for PIVOT-861 (part two) it was causing out of memory ...
//
// Note that this has been moved to another issue, but the problem is due to the usage
// of dataRenderer tags (and then instancing ButtonDataRenderer) in the loaded bxml,
// so probably even this test will be updated ...
//
final GridPane grid = (GridPane) new BXMLSerializer().readObject(Pivot894.class, "btn_grid.bxml");
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
Iterator<Component> iterator = cardPane.iterator();
List<Component> deprecated = new ArrayList<Component>();
while (iterator.hasNext()) {
Component card = iterator.next();
if (!card.isShowing()) {
deprecated.add(card);
}
}
for (Component card : deprecated) {
cardPane.remove(card);
}
cardPane.setSelectedIndex(cardPane.add(grid));
System.out.println(cardPane.getSelectedIndex());
}
});
} catch (Exception e) {
e.printStackTrace();
}