flextable的对应删除

com.google.gwt.user.client.ui.FlexTable

A flexible table that creates cells on demand. It can be jagged (that is, each row can contain a different number of cells) and individual cells can be set to span multiple rows or columns.

可以往 flexible 中加入String 或 Widget ,

setText(int row, int column, String text);

setWidget(int row, int column, Widget widget)

删除

removeRow(int row)

getRowCount() //Gets the number of rows.

//start

package com.bnu.client;

import java.util.ArrayList;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
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.Widget;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class yjy implements EntryPoint {

  /**
   * This is the entry point method.
   */
 private VerticalPanel mainPanel = new VerticalPanel();
 private FlexTable stock = new FlexTable();
 private HorizontalPanel addPanel = new HorizontalPanel();
 private TextBox txt = new TextBox();
 private Button addbutton = new Button("Add");
 private Label lab= new Label("");
 private ArrayList<String> stockList = new ArrayList<String>();
 private int currow;
  public void onModuleLoad() {
   stock.setText(0, 0, "name");
   stock.setText(0, 4, "remove");
   currow = stock.getRowCount();
  // Window.alert(""+currow);
   addPanel.add(txt);
   addPanel.add(addbutton);
   mainPanel.add(stock);
   mainPanel.add(addPanel);
   mainPanel.add(lab);
   addbutton.addClickListener(new ClickListener()
   {
  public void onClick(Widget sender) {
   // TODO Auto-generated method stub
   final String str = txt.getText().trim();
   if (!stockList.contains(str))
   {
    stockList.add(str);
    stock.setText(currow, 0, str);
    Button cross = new Button("X");
    cross.addClickListener(new ClickListener()
    {
     //@Override
     public void onClick(Widget sender) {
      // TODO Auto-generated method stub
      int reind = stockList.indexOf(str);
      stockList.remove(reind);
     // Window.alert(reind+"");
      stock.removeRow(reind+1);
      currow=stock.getRowCount();
     }
    });
    stock.setWidget(currow, 4,cross );
    txt.setText("");
    currow = stock.getRowCount();
    txt.setFocus(true);
   }
  }
   });
   RootPanel.get().add(mainPanel);
   txt.setFocus(true);
  }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值