| A DropDownGridBox wraps around a GridBox component to provide drop down
features.
Example:
Dialog dlg = new Dialog("DropDownGridBox Test");
dlg.setBounds(25, 25, 400, 200);
final TextField tf = new TextField();
tf.setBounds(275, 25, 100, 20);
dlg.getChildren().add(tf);
DropDownGridBox ddgb = new DropDownGridBox();
ddgb.setBounds(25, 25, 230, 20);
GridBox gb = ddgb.getComponent();
gb.setVisibleHeader(true);
gb.setHeight(120);
GridBox.Column col1 = new GridBox.Column();
col1.setName("Name");
GridBox.Column col2 = new GridBox.Column();
col2.setName("City");
GridBox.Column col3 = new GridBox.Column();
col3.setName("Country");
gb.getColumns().add(col1);
gb.getColumns().add(col2);
gb.getColumns().add(col3);
String[] names = { "Smythe", "Janes", "Warren", "Dempster", "Hilcox" };
String[] cities = { "Tokyo", "Hong Kong", "Lethbridge", "Juarez", "Juneau" };
String[] countries = { "Japan", "China", "Canada", "Mexico", "USA" };
for (int r = 0; r < 5; r++) {
GridBox.Row row = new GridBox.Row();
row.add(names[r]);
row.add(cities[r]);
row.add(countries[r]);
gb.getRows().add(row);
}
((DropDownGridBox.DefaultView) ddgb.getView()).setColumnIndex(2);
ddgb.addPropertyChangeListener(DropDownGridBox.PROPERTY_TEXT,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
tf.setText((String) evt.getNewValue());
}
});
dlg.getChildren().add(ddgb);
dlg.setVisible(true);
Keyboard Navigation:
KEY |
RESPONSE |
NOTE |
Down Arrow |
Drops the Grid Box down. |
Only if the component has focus. |
Esc |
Closes the Grid Box |
Only if the component has focus. |
See GridBox for additional keyboard support.
author: Joshua J. Gertzen author: Ted C. Howard |