SmartGWT - can't click into items into windows modal - gwt

I have one problem using Window with setIsModal(true).
I have this code:
#Override
public void onModuleLoad() {
Button tester = new Button("Tester");
tester.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
#Override
public void onClick(ClickEvent event) {
final com.smartgwt.client.widgets.Window win = new com.smartgwt.client.widgets.Window();
win.setTitle("Ventana Tester");
win.setWidth(900);
win.setHeight(600);
win.setIsModal(true);
win.setShowModalMask(true);
win.centerInPage();
win.setMinimized(false);
win.addCloseClickHandler(new CloseClickHandler() {
#Override
public void onCloseClick(CloseClientEvent event) {
win.destroy();
}
});
PlanBoard pb = new PlanBoard();
win.addItem(pb);
win.show();
}
});
vlPrincipal.addMember(tester);
RootPanel.get("main").add(vlPrincipal);
}
and this is PlanBoard class:
public class PlanBoard extends VLayout{
private CaptionPanel contentDetallePlan = new CaptionPanel("DETALLES DEL PLAN");
private CaptionPanel contentAtributosPlan = new CaptionPanel("ATRIBUTOS DE PLAN");
private CaptionPanel contentSeccionesPlan = new CaptionPanel("SECCIONES");
public PlanBoard(){
contentDetallePlan.setStyleName("estiloCaptionPanel");
contentAtributosPlan.setStyleName("estiloCaptionPanel");
addMember(contentDetallePlan);
addMember(contentAtributosPlan);
addMember(contentSeccionesPlan);
preparaDetallePlan();
preparaAtributosPlan();
}
private void preparaDetallePlan(){
VLayout contenedorSeccion = new VLayout();
FlexTable table1 = new FlexTable();
FlexTable table2 = new FlexTable();
FlexTable table3 = new FlexTable();
Label np = new Label("Nombre de Plan:");
Label npText = new Label("Plan B");
Label tc = new Label("Tipo de Carta:");
DynamicForm tcForm = new DynamicForm();
ComboBoxItem tcBox = new ComboBoxItem();
tcBox.setWidth(250);
tcBox.setShowTitle(false);
tcForm.setItems(tcBox);
Label pr = new Label("Periodo:");
DynamicForm prForm = new DynamicForm();
ComboBoxItem prBox = new ComboBoxItem();
prBox.setWidth(150);
prBox.setShowTitle(false);
prForm.setItems(prBox);
Label dp = new Label("Descripcion:");
DynamicForm dpForm = new DynamicForm();
TextAreaItem dpText = new TextAreaItem();
dpText.setShowTitle(false);
dpText.setWidth(600);
dpForm.setItems(dpText);
table1.setWidget(0, 0, np);
table1.setWidget(0, 1, npText);
table2.setWidget(0, 0, tc);
table2.setWidget(0, 1, tcForm);
table2.setWidget(0, 2, pr);
table2.setWidget(0, 3, prForm);
table3.setWidget(0, 1, dp);
table3.setWidget(1, 1, dpForm);
contenedorSeccion.addMember(table1);
contenedorSeccion.addMember(table2);
contenedorSeccion.addMember(table3);
contentDetallePlan.add(contenedorSeccion);
}
private void preparaAtributosPlan(){
VLayout contenedorSeccion = new VLayout();
FlexTable table1 = new FlexTable();
Label fe = new Label("Firma Electornica:");
CheckboxItem feCheck = new CheckboxItem();
DateItem feFechaIni = new DateItem();
DateItem feFechaFin = new DateItem();
feFechaIni.setUseTextField(true);
feCheck.setShowTitle(false);
DynamicForm feForm = new DynamicForm();
feForm.setItems(feCheck,feFechaIni,feFechaFin);
table1.setWidget(0, 0, fe);
table1.setWidget(0, 1, feForm);
contenedorSeccion.addMember(table1);
contentAtributosPlan.add(contenedorSeccion);
}
The problem is when I try to click on CheckBoxItem or DateItem, I can't edit them, but when I don't use setIsModal(true), it works fine.
I don't know how to set the Window to modal(true), and have those items working on that window.

Here is your code cleaned (a little bit) and improved so that what you want to achieve (which is the modal window with selectable/actionable controls):
PlanBoard.java
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.CheckboxItem;
import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
import com.smartgwt.client.widgets.form.fields.DateItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.form.fields.TextAreaItem;
import com.smartgwt.client.widgets.layout.VLayout;
public class PlanBoard extends VLayout {
public PlanBoard(){
preparaDetallePlan();
preparaAtributosPlan();
preparaSecciones();
}
private void preparaDetallePlan(){
StaticTextItem np = new StaticTextItem("id2", "Nombre de Plan:");
StaticTextItem npText = new StaticTextItem("id2", "Plan B");
ComboBoxItem tcBox = new ComboBoxItem();
tcBox.setTitle("Tipo de Carta");
tcBox.setWidth(250);
ComboBoxItem prBox = new ComboBoxItem();
tcBox.setTitle("Periodo");
prBox.setWidth(150);
StaticTextItem dp = new StaticTextItem("id3", "Descripcion:");
TextAreaItem dpText = new TextAreaItem();
dpText.setShowTitle(false);
dpText.setWidth(600);
dpText.setStartRow(true);
dpText.setEndRow(true);
dpText.setColSpan(2);
DynamicForm form = new DynamicForm();
form.setItems(np, npText, tcBox, prBox, dp, dpText);
form.setIsGroup(true);
form.setGroupTitle("DETALLES DE PLAN");
addMember(form);
}
private void preparaAtributosPlan(){
StaticTextItem fe = new StaticTextItem("id4", "Firma Electornica:");
CheckboxItem feCheck = new CheckboxItem();
feCheck.setShowTitle(false);
DateItem feFechaIni = new DateItem();
DateItem feFechaFin = new DateItem();
feFechaIni.setUseTextField(true);
DynamicForm form = new DynamicForm();
form.setItems(fe, feCheck, feFechaIni, feFechaFin);
form.setIsGroup(true);
form.setGroupTitle("ATRIBUTOS DE PLAN");
addMember(form);
}
private void preparaSecciones(){
DynamicForm form = new DynamicForm();
form.setIsGroup(true);
form.setGroupTitle("SECCIONES");
addMember(form);
}
}
TestCases.java (rename to your EntryPoint class name, which you don't specify):
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.events.CloseClickEvent;
import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.layout.VLayout;
import com.google.gwt.core.client.EntryPoint;
public class TestCases implements EntryPoint {
public void onModuleLoad() {
IButton tester = new IButton("Tester");
tester.addClickHandler(new ClickHandler() {
#Override
public void onClick(ClickEvent event) {
final Window win = new Window();
win.setTitle("Ventana Tester");
win.setWidth(900);
win.setHeight(600);
win.setIsModal(true);
win.setShowModalMask(true);
win.centerInPage();
win.setMinimized(false);
win.addCloseClickHandler(new CloseClickHandler() {
#Override
public void onCloseClick(CloseClickEvent event) {
win.destroy();
}
});
PlanBoard pb = new PlanBoard();
win.addItem(pb);
win.show();
}
});
VLayout vlPrincipal = new VLayout();
vlPrincipal.addMember(tester);
vlPrincipal.draw();
}
}
Some notes:
Don't mix GWT and SmartGWT widgets unless absolutely necessary and only when you really know what you are doing (because it will generated unexpected results, as the one you are experiencing). In your case, the mixing is unnecessary!!
You can add the titles to the different controls you are using, and they will display as labels. You can specify if the title label appears above or to one side, per control.
Take a look at this SmartGWT demo to learn how to configure and use the different types of DynamicForm controls. Many of the things you were trying to do, you were doing more difficult than necessary.
On the "stylistic" aspect, don't write your code using Spanglish. I speak Spanish, so I understand, but it limits a lot the feedback you get, because your code is so much more difficult to understand. Use English (at least for code you intend to post in SO).

Related

programmatically scroll ScrolledComposite TableViewer item

I have a dialog with large table viewer that lays on ScrolledComposite.
I need programmatically scroll ScrolledComposite to select item from TableViewer.
Looks like a easy task but I really got stack.
I tried number of thinks and non of them are working.
There is my sample code:
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TableItem;
/**
* Scroll a Viewer 99th element
*
*/
public class Snippet008RevealElement {
public class MyModel {
public int counter;
public MyModel(int counter) {
this.counter = counter;
}
#Override
public String toString() {
return "Item " + this.counter;
}
}
public Snippet008RevealElement(Shell shell) {
ScrolledComposite scrolledComposite = new ScrolledComposite(shell, SWT.V_SCROLL | SWT.H_SCROLL);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
scrolledComposite.setLayoutData(data);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
Composite main = new Composite(scrolledComposite, SWT.NONE);
main.setLayout(new GridLayout());
main.setLayoutData(new GridData(GridData.FILL_BOTH));
final TableViewer v = new TableViewer(main);
v.setLabelProvider(new LabelProvider());
v.setContentProvider(ArrayContentProvider.getInstance());
MyModel[] model = createModel();
v.setInput(model);
v.getTable().setLinesVisible(true);
// v.reveal(model[99]);
// v.getTable().setSelection(99);
TableItem[] items = v.getTable().getItems();
TableItem item = items[99];
scrolledComposite.getVerticalBar().setSelection(item.getBounds().y);
scrolledComposite.setContent(main);
scrolledComposite.setMinSize(main.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
private MyModel[] createModel() {
MyModel[] elements = new MyModel[100];
for( int i = 0; i < 100; i++ ) {
elements[i] = new MyModel(i);
}
return elements;
}
/**
* #param args
*/
public static void main(String[] args) {
Display display = new Display ();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
new Snippet008RevealElement(shell);
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
the real challenge or a bug is to find real bounds for TableItem item = items[99]; that not visible on composite.
You can use the setOrigin method of ScrolledComposite for this using something like:
scrolledComposite.setContent(main);
scrolledComposite.setMinSize(main.computeSize(SWT.DEFAULT, SWT.DEFAULT));
// Need to run the calculations after all size calculations have been done
// So do asynchronously.
final Display display = scrolledComposite.getDisplay();
display.asyncExec(() ->
{
final Table table = v.getTable();
final TableItem item = table.getItem(99);
Rectangle itemBounds = item.getBounds();
// Convert to be relative to scrolled composite
itemBounds = display.map(viewer.getTable(), scrolledComposite, itemBounds);
scrolledComposite.setOrigin(0, itemBounds.y);
});
Note: The bounds calculations are not accurate if you call this code during the initialization of the controls so I have shown it being done asynchronously here. The asyncExec is not needed if you run the code from a Button or something like that.

Multiple RadioButtons Simulator

I'm trying to make a sort of simple soccer simulator. This is the code I created after watching tutorials and i know its pretty bad. All i want to do is add a value to the team, like 1 for the best team and 10 for the worst, and when i click simulate a pop up would show up telling me which team would win given the teams value. But i cant figure out how to do it.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;
public class sim extends JPanel {
public sim() {
// JFrame constructor
super(true);
JRadioButton chelsea, arsenal, chelsea2, arsenal2;
this.setLayout(new GridLayout(3,0));
ButtonGroup group = new ButtonGroup();
ButtonGroup group2 = new ButtonGroup();
// takes image and saves it the the variable
Icon a = new ImageIcon(getClass().getResource("a.PNG"));
Icon c = new ImageIcon(getClass().getResource("c.JPG"));
chelsea = new JRadioButton("Chelsea",c);
chelsea.setHorizontalTextPosition(AbstractButton.CENTER);
chelsea.setVerticalTextPosition(AbstractButton.BOTTOM);
arsenal = new JRadioButton("Arsenal",a);
arsenal.setHorizontalTextPosition(AbstractButton.CENTER);
arsenal.setVerticalTextPosition(AbstractButton.BOTTOM);
group.add(chelsea);
group.add(arsenal);
JLabel label = new JLabel("");
TitledBorder titled = new TitledBorder("Team 1");
label.setBorder(titled);
chelsea.setBorder(titled);
arsenal.setBorder(titled);
JButton button = new JButton("Simulate");
button.setHorizontalAlignment(JButton.CENTER);
add(button, BorderLayout.CENTER);
chelsea2 = new JRadioButton("Chelsea",c);
chelsea2.setHorizontalTextPosition(AbstractButton.CENTER);
chelsea2.setVerticalTextPosition(AbstractButton.BOTTOM);
arsenal2 = new JRadioButton("Arsenal",a);
arsenal2.setHorizontalTextPosition(AbstractButton.CENTER);
arsenal2.setVerticalTextPosition(AbstractButton.BOTTOM);
group2.add(chelsea2);
group2.add(arsenal2);
JLabel label2 = new JLabel("");
TitledBorder titled2 = new TitledBorder("Team 2");
label2.setBorder(titled2);
chelsea2.setBorder(titled);
arsenal2.setBorder(titled);
add(label);
add(chelsea);
add(arsenal);
add(button);
add(chelsea2);
add(arsenal2);
HandlerClass handler = new HandlerClass();
chelsea.addActionListener(handler);
}
private class HandlerClass implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
//JOptionPane.showMessageDialog(null, String.format("%s", e.getActionCommand()));
}
}
public static void main(String[] args) {
JFrame frame = new JFrame("Final");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1920, 1080);
frame.setContentPane(new sim());
frame.setVisible(true);
}
}
Put the ActionListener into the sim class.
public void actionPerformed(ActionEvent e)
{
JButton clicked = (JButton)e.getSource();
if(clicked == button)
{
JOptionPane.showMessageDialog(null, "this team will win");
}
}
You need to decrees the amount of code to just amount needed you dont need to show us all the raidio

How to create a click event search button in Eclipse using?

How to create a click event search button in Eclipse?? Can someone help me. This is the code im working with.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search);
listContent1 = (ListView)findViewById(R.id.lFoodlist1);
mySQLiteAdapter = new SQLiteAdapter(this);
mySQLiteAdapter.openToRead();
Cursor cursor = mySQLiteAdapter.queueAll();
startManagingCursor(cursor);
String[] from = new String[]{SQLiteAdapter.KEY_FOODNAME,SQLiteAdapter.KEY_CALORIES};
int[] to = new int[]{R.id.tv1, R.id.tv2};
SimpleCursorAdapter cursorAdapter =
new SimpleCursorAdapter(this, R.layout.row, cursor, from, to);
listContent1.setAdapter(cursorAdapter);
//listContent.setOnItemClickListener(listContentOnItemClickListener);*/
}
This code was taken from Here and was modified/commented to help the poseter with his scenario.
You can implement swing to help with the GUI aspect of your application. Others may prefer AWT
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
public class myTest {
public static void main(String[] args) {
//This will create the JFrame/JPanel/JButton
final JFrame frame = new JFrame();
JPanel panel = new JPanel();
JButton button1 = new JButton();
//Add your panel and button and make them visable
frame.add(panel);
panel.add(button1);
frame.setVisible(true);
//This adds the actionListener to the Button
button1.addActionListener(new ActionListener() {
//When the button is clicked this action will be performed
public void actionPerformed(ActionEvent arg0) {
//Add your code here.
}
});
}
}

ExpandBar in Eclipse View Part

I am trying to add an expand bar to an Eclipse viewpart. When I click the expand button I would like the viewpart to move items below the expand bar down and show the expanded items. What currently happens is the expand bar items just disappear below the items below the expand bar. Any thoughts?
final ExpandBar expandBar = new ExpandBar(parent, SWT.NONE);
expandBar.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
expandBar.setSpacing(0);
fd_toolBar.top = new FormAttachment(expandBar, 6);
FormData fd_expandBar = new FormData();
fd_expandBar.top = new FormAttachment(0, 62);
fd_expandBar.left = new FormAttachment(0, 3);
expandBar.setLayoutData(fd_expandBar);
formToolkit.paintBordersFor(expandBar);
final ExpandItem xpndtmWarningDetails = new ExpandItem(expandBar, SWT.NONE);
xpndtmWarningDetails.setExpanded(true);
xpndtmWarningDetails.setText("Warning Details");
final Composite composite_1 = new Composite(expandBar, SWT.NONE);
composite_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_YELLOW));
xpndtmWarningDetails.setControl(composite_1);
formToolkit.paintBordersFor(composite_1);
xpndtmWarningDetails.setHeight(xpndtmWarningDetails.getControl().computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
Label lblTest = new Label(composite_1, SWT.NONE);
lblTest.setBounds(10, 10, 55, 15);
lblTest.setText("Test");
expandBar.addExpandListener(new ExpandListener(){
#Override
public void itemCollapsed(ExpandEvent e) {
expandBar.setSize(expandBar.getSize().x, xpndtmWarningDetails.getHeaderHeight());
parent.layout(true);
}
#Override
public void itemExpanded(ExpandEvent e) {
expandBar.setSize(expandBar.getSize().x, 300);
expandBar.layout(true);
parent.layout(true);
}
});
I think the ExpandBar works best when used like it is in this example...
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet343.java
... with several expand bars stacked on top of each other, and nothing else mixed in.
I think the functionality your looking for can be accomplished with an ExpandableComposite object. It depends on what else is going on in your ViewPart.
Here's a quick example of an ExpandableComposite.
package com.amx.designsuite.rcp;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
public class ExpandableCompositeExample extends Composite {
/**
* Create the composite.
* #param parent
* #param style
*/
public ExpandableCompositeExample(final Composite parent, int style) {
super(parent, style);
FormToolkit toolkit;
toolkit = new FormToolkit(parent.getDisplay());
final ScrolledForm form = toolkit.createScrolledForm(parent);
form.setText("Title for Form holding Expandable Composite (optional)");
TableWrapLayout layout = new TableWrapLayout();
form.getBody().setLayout(layout);
ExpandableComposite expandableCompsite = toolkit.createExpandableComposite(form.getBody(), ExpandableComposite.TREE_NODE | ExpandableComposite.SHORT_TITLE_BAR);
toolkit.paintBordersFor(expandableCompsite);
expandableCompsite.setText("Expandable Composite Title (Optional)");
expandableCompsite.setExpanded(true);
Text txtMyNewText = toolkit.createText(expandableCompsite, "Text to show when composite is expanded", SWT.NONE);
expandableCompsite.setClient(txtMyNewText);
}
#Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
}

windowbuilder tutorial not functioning

I am trying to do a tutorial that allows one to Add and Remove stocks and witness their price and change. This tutorial demonstrates how to use the GUI builder, GWT Designer, to create and design a Stock Watcher application based on the GWT tutorial.
http://code.google.com/webtoolkit/tools/gwtdesigner/tutorials/stockwatcher.html#design_ui
So far I have SW.java:
package edu.gatech.client;
import java.util.ArrayList;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.event.dom.client.KeyPressHandler;
import com.google.gwt.event.dom.client.KeyPressEvent;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class SW implements EntryPoint {
private RootPanel rootPanel;
private FlexTable stocksFlexTable;
private HorizontalPanel addPanel;
private VerticalPanel mainWindow;
private TextBox newSymbolTextBox;
private Button addButton;
private Label lastUpdatedLabel;
private ArrayList <String> stocks = new ArrayList<String>(); //Add this line
public void onModuleLoad() {
rootPanel = RootPanel.get();
mainWindow = new VerticalPanel();
rootPanel.add(mainWindow, 10, 10);
mainWindow.setSize("267px", "175px");
FlexTable stocksFlexTable = new FlexTable();
//Add these lines
stocksFlexTable.setText(0, 0, "Symbol");
stocksFlexTable.setText(0, 1, "Price");
stocksFlexTable.setText(0, 2, "Change");
stocksFlexTable.setText(0, 3, "Remove");
mainWindow.add(stocksFlexTable);
addPanel = new HorizontalPanel();
rootPanel.add(addPanel, 10, 200);
addPanel.setSize("267px", "68px");
newSymbolTextBox = new TextBox();
newSymbolTextBox.addKeyPressHandler(new KeyPressHandler() {
public void onKeyPress(KeyPressEvent event) {
if (event.getCharCode() == KeyCodes.KEY_ENTER){
addStock();
}
}
});
addPanel.add(newSymbolTextBox);
newSymbolTextBox.setWidth("211px");
addButton = new Button("Add");
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
addStock();
}
});
addPanel.add(addButton);
lastUpdatedLabel = new Label("New Label");
rootPanel.add(lastUpdatedLabel, 48, 274);
}
private void addStock() {
final String symbol = newSymbolTextBox.getText().toUpperCase().trim();
newSymbolTextBox.setFocus(true);
// Stock code must be between 1 and 10 chars that are numbers, letters, or dots.
if (!symbol.matches("^[0-9A-Z\\.]{1,10}$")) {
Window.alert("'" + symbol + "' is not a valid symbol.");
newSymbolTextBox.selectAll();
return;
}
newSymbolTextBox.setText("");
// don't add the stock if it's already in the watch list
if (stocks.contains(symbol))
return;
// add the stock to the list
int row = stocksFlexTable.getRowCount();
stocks.add(symbol);
stocksFlexTable.setText(row, 0, symbol);
// add button to remove this stock from the list
Button removeStock = new Button("x");
removeStock.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
int removedIndex = stocks.indexOf(symbol);
stocks.remove(removedIndex);
stocksFlexTable.removeRow(removedIndex + 1);
}
});
stocksFlexTable.setWidget(row, 3, removeStock);
}
}
When I run the web application, I cannot Add a stock. The program does, however, distinguish between bad stock names and acceptable ones. Instead I get an "uncaught exception escaped" error and the program doesn't really do anything. How do I troubleshoot this?
Use the debugger and single step through the code. Set a breakpoint on addStock's first line and find which line crashes. Once you find which line you then instrument the line to find out what aspect is causing the problem - assuming you can't deduce the problem by looking at the line.