Manuel Elaraj
7 Jun 2008, 7:13 AM
It seems like i cannot get all the components that i add to the content panel to show. If i collapse and expand the panel manually it renders correctly. Am i doing something wrong or is this a bug??
The attachment shows the panel before manually collapsing and expanding the panel. The second picture shows after.
Here is the code for the content panel:
public class ClaimGrid
{
public ContentPanel getGrid()
{
final NumberFormat currency = NumberFormat.getCurrencyFormat();
final NumberFormat number = NumberFormat.getFormat("0.00");
List<TableColumn> columns = new ArrayList<TableColumn>();
TableColumn col = new TableColumn("Company", 180);
col.setMinWidth(75);
col.setMaxWidth(300);
columns.add(col);
col = new TableColumn("Symbol", 75);
columns.add(col);
col = new TableColumn("Last", 75);
col.setMaxWidth(100);
col.setAlignment(Style.HorizontalAlignment.RIGHT);
col.setRenderer(new NumberCellRenderer(currency));
columns.add(col);
col = new TableColumn("Change", 75);
col.setAlignment(Style.HorizontalAlignment.RIGHT);
col.setRenderer(new CellRenderer()
{
public String render(String property, Object value)
{
double val = (Double) value;
String style = val < 0 ? "red" : "green";
return "<span style='color:" + style + "'>" + number.format(val) + "</span>";
}
});
columns.add(col);
col = new TableColumn("Last Updated", 100);
col.setAlignment(Style.HorizontalAlignment.RIGHT);
col.setRenderer(new DateTimeCellRenderer("MM/d/y"));
columns.add(col);
TableColumnModel cm = new TableColumnModel(columns);
Table tbl = new Table(cm);
tbl.setSelectionModel(new RowSelectionModel(Style.SelectionMode.MULTI));
tbl.setHorizontalScroll(true);
List<Stock> stocks = TestData.getStocks();
for (int i = 0; i < stocks.size(); i++)
{
Stock stock = stocks.get(i);
Object[] values = new Object[5];
values[0] = stock.getName();
values[1] = stock.getSymbol();
values[2] = stock.getLast();
values[3] = stock.getLast() - stock.getOpen();
values[4] = stock.getLastTrans();
TableItem item = new TableItem(values);
tbl.add(item);
}
ContentPanel panel = new ContentPanel();
panel.setCollapsible(true);
panel.setFrame(true);
panel.setAnimCollapse(false);
panel.setButtonAlign(Style.HorizontalAlignment.CENTER);
panel.setIconStyle("icon-table");
panel.setHeading("Claim Search");
panel.setLayout(new RowLayout());
panel.add(tbl);
panel.setSize(600, 500);
// built in support for top component
TextBoxToolItem txtSearch = new TextBoxToolItem();
TextToolItem btnSearch = new TextToolItem("Search Claims");
txtSearch.textField.setEmptyText("Enter Rx # To Search");
ToolBar toolBar = new ToolBar();
toolBar.add(txtSearch);
toolBar.add(btnSearch);
//panel.setTopComponent(toolBar);
// add buttons
SearchListner searchlistener = new SearchListner()
{
public void componentSelected(ComponentEvent ce)
{
Button btn = (Button) ce.component;
//Info.display("Click Event", "The '{0}' button was clicked.", btn.getText());
String iData = (String) this.searchTextField.textField.getValue();
Info.display("Action","Searching for Rx #" + iData);
}
};
searchlistener.searchTextField=txtSearch;
btnSearch.addSelectionListener(searchlistener);
Button btnSave = new Button("Save");
panel.addButton(btnSave);
panel.addButton(new Button("Cancel"));
// txtSearch.textField.focus();
return panel;
}
private class SearchListner extends SelectionListener
{
public TextBoxToolItem searchTextField;
}
} //ClaimGrid
I appreciate any help greatly...
Manuel
The attachment shows the panel before manually collapsing and expanding the panel. The second picture shows after.
Here is the code for the content panel:
public class ClaimGrid
{
public ContentPanel getGrid()
{
final NumberFormat currency = NumberFormat.getCurrencyFormat();
final NumberFormat number = NumberFormat.getFormat("0.00");
List<TableColumn> columns = new ArrayList<TableColumn>();
TableColumn col = new TableColumn("Company", 180);
col.setMinWidth(75);
col.setMaxWidth(300);
columns.add(col);
col = new TableColumn("Symbol", 75);
columns.add(col);
col = new TableColumn("Last", 75);
col.setMaxWidth(100);
col.setAlignment(Style.HorizontalAlignment.RIGHT);
col.setRenderer(new NumberCellRenderer(currency));
columns.add(col);
col = new TableColumn("Change", 75);
col.setAlignment(Style.HorizontalAlignment.RIGHT);
col.setRenderer(new CellRenderer()
{
public String render(String property, Object value)
{
double val = (Double) value;
String style = val < 0 ? "red" : "green";
return "<span style='color:" + style + "'>" + number.format(val) + "</span>";
}
});
columns.add(col);
col = new TableColumn("Last Updated", 100);
col.setAlignment(Style.HorizontalAlignment.RIGHT);
col.setRenderer(new DateTimeCellRenderer("MM/d/y"));
columns.add(col);
TableColumnModel cm = new TableColumnModel(columns);
Table tbl = new Table(cm);
tbl.setSelectionModel(new RowSelectionModel(Style.SelectionMode.MULTI));
tbl.setHorizontalScroll(true);
List<Stock> stocks = TestData.getStocks();
for (int i = 0; i < stocks.size(); i++)
{
Stock stock = stocks.get(i);
Object[] values = new Object[5];
values[0] = stock.getName();
values[1] = stock.getSymbol();
values[2] = stock.getLast();
values[3] = stock.getLast() - stock.getOpen();
values[4] = stock.getLastTrans();
TableItem item = new TableItem(values);
tbl.add(item);
}
ContentPanel panel = new ContentPanel();
panel.setCollapsible(true);
panel.setFrame(true);
panel.setAnimCollapse(false);
panel.setButtonAlign(Style.HorizontalAlignment.CENTER);
panel.setIconStyle("icon-table");
panel.setHeading("Claim Search");
panel.setLayout(new RowLayout());
panel.add(tbl);
panel.setSize(600, 500);
// built in support for top component
TextBoxToolItem txtSearch = new TextBoxToolItem();
TextToolItem btnSearch = new TextToolItem("Search Claims");
txtSearch.textField.setEmptyText("Enter Rx # To Search");
ToolBar toolBar = new ToolBar();
toolBar.add(txtSearch);
toolBar.add(btnSearch);
//panel.setTopComponent(toolBar);
// add buttons
SearchListner searchlistener = new SearchListner()
{
public void componentSelected(ComponentEvent ce)
{
Button btn = (Button) ce.component;
//Info.display("Click Event", "The '{0}' button was clicked.", btn.getText());
String iData = (String) this.searchTextField.textField.getValue();
Info.display("Action","Searching for Rx #" + iData);
}
};
searchlistener.searchTextField=txtSearch;
btnSearch.addSelectionListener(searchlistener);
Button btnSave = new Button("Save");
panel.addButton(btnSave);
panel.addButton(new Button("Cancel"));
// txtSearch.textField.focus();
return panel;
}
private class SearchListner extends SelectionListener
{
public TextBoxToolItem searchTextField;
}
} //ClaimGrid
I appreciate any help greatly...
Manuel