public SplitPaneTest() {
super(SplitPane.ORIENTATION_HORIZONTAL, new Extent(250, Extent.PX));
setStyleName("DefaultResizable");
Column groupContainerColumn = new Column();
groupContainerColumn.setCellSpacing(new Extent(5));
groupContainerColumn.setStyleName("TestControlsColumn");
add(groupContainerColumn);
ButtonColumn controlsColumn;
controlsColumn = new ButtonColumn();
controlsColumn.add(new Label("Add / Remove Panes"));
groupContainerColumn.add(controlsColumn);
controlsColumn.addButton("Remove Pane 0", new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (testPane.getComponentCount() >= 1) {
testPane.remove(0);
}
}
});
controlsColumn.addButton("Remove Pane 1", new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (testPane.getComponentCount() >= 2) {
testPane.remove(1);
}
}
});
controlsColumn.addButton("Replace Pane 0", new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (testPane.getComponentCount() >= 1) {
testPane.remove(0);
}
testPane.add(createPaneLabel("Replacement for Pane 0"), 0);
}
});
controlsColumn.addButton("Replace Pane 1", new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (testPane.getComponentCount() >= 2) {
testPane.remove(1);
}
testPane.add(createPaneLabel("Replacement for Pane 1"));
}
});
controlsColumn.addButton("Add at Beginning", new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (testPane.getComponentCount() < 2) {
testPane.add(createPaneLabel("Added at Beginning"), 0);
}
}
});
controlsColumn.addButton("Add at End", new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (testPane.getComponentCount() < 2) {
testPane.add(createPaneLabel("Added at End"));
}
}
});
controlsColumn.addButton("Add Row", new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (testPane.getComponentCount() < 2) {
Row row = new Row();
row.setBorder(new Border(new Extent(1), Color.BLACK, Border.STYLE_SOLID));
row.setCellSpacing(new Extent(5));
row.setInsets(new Insets(10, 5));
row.add(new Label("Alpha"));
row.add(new Label("Bravo"));
row.add(new Label("Charlie"));
testPane.add(row);
}
}
});
controlsColumn.addButton("Add-Remove-Add", new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (testPane.getComponentCount() < 2) {
Label label = createPaneLabel("Added at End, Removed, Re-Added");
testPane.add(label);
testPane.remove(label);
testPane.add(label);
}
}
});
controlsColumn.addButton("Add Button", new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (testPane.getComponentCount() < 2) {
Button testButton = new Button("Test Button");
SplitPaneLayoutData layoutData = new SplitPaneLayoutData();
layoutData.setInsets(new Insets(10));
testButton.setLayoutData(layoutData);
testButton.setStyleName("Default");
testPane.add(testButton);
}
}
});
controlsColumn = new ButtonColumn();
controlsColumn.add(new Label("Configure SplitPane"));
groupContainerColumn.add(controlsColumn);
controlsColumn.addButton("Set Separator Position = null", new ActionListener() {
public void actionPerformed(ActionEvent e) {
testPane.setSeparatorPosition(null);
}
});
controlsColumn.addButton("Set Separator Position = 300px", new ActionListener() {
public void actionPerformed(ActionEvent e) {
testPane.setSeparatorPosition(new Extent(300));
}
});
controlsColumn.addButton("Set Orientation = Leading/Trailing", new ActionListener() {
public void actionPerformed(ActionEvent e) {
testPane.setOrientation(SplitPane.ORIENTATION_HORIZONTAL_LEADING_TRAILING);
}
});
controlsColumn.addButton("Set Orientation = Trailing/Leading", new ActionListener() {
public void actionPerformed(ActionEvent e) {
testPane.setOrientation(SplitPane.ORIENTATION_HORIZONTAL_TRAILING_LEADING);
}
});
controlsColumn.addButton("Set Orientation = Left/Right", new ActionListener() {
public void actionPerformed(ActionEvent e) {
testPane.setOrientation(SplitPane.ORIENTATION_HORIZONTAL_LEFT_RIGHT);
}
});
controlsColumn.addButton("Set Orientation = Right/Left", new ActionListener() {
public void actionPerformed(ActionEvent e) {
testPane.setOrientation(SplitPane.ORIENTATION_HORIZONTAL_RIGHT_LEFT);
}
});
controlsColumn.addButton("Set Orientation = Top/Bottom", new ActionListener() {
public void actionPerformed(ActionEvent e) {
testPane.setOrientation(SplitPane.ORIENTATION_VERTICAL_TOP_BOTTOM);
}
});
controlsColumn.addButton("Set Orientation = Bottom/Top", new ActionListener() {
public void actionPerformed(ActionEvent e) {
testPane.setOrientation(SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP);
}
});
controlsColumn.addButton("Disable Resize", new ActionListener() {
public void actionPerformed(ActionEvent e) {
testPane.setResizable(!testPane.isResizable());
((Button) e.getSource()).setText(testPane.isResizable() ? "Disable Resize" : "Enable Resize");
}
});
groupContainerColumn.add(new PaneControlsColumn(0));
groupContainerColumn.add(new PaneControlsColumn(1));
testPane = new SplitPane(ORIENTATION_VERTICAL, new Extent(200, Extent.PX));
testPane.setStyleName("DefaultResizable");
add(testPane);
}