pcl2004_27 发表于 2006-10-30 14:27:50

WinRunner:JComboBox in a JTable

Description

      How to select a JcomboBox item from a JTable cell.


Solution

      ##################################################################
# This function selects an item from a JComboBox in JTable cell.
# PARAMETERS DESCRIPTION:
# Obj -> The logical name of the table
# row -> The number of the row (first is 0)
# col -> The number of the column (first is 0)
# item -> The number of the item to select (first is 0)
###################################################################

public function select_comb_item(in Obj, in row, in col, in item)
{
auto editor;
auto comboB;
auto colName;
auto retVal;
auto hasCh;

java_activate_method(Obj,"getCellEditor",editor,row,col);
java_activate_method(editor,"getComponent",comboB);
tbl_get_column_name(Obj,col,colName);
tbl_click_cell(Obj, "#"&row, colName);
java_activate_method(comboB,"setSelectedIndex",retVal,item);
java_activate_method(comboB,"selectedItemChanged",hasCh);
jco_free_all();
}

#EXAMPLE
set_window("SwingSet", 4);
select_comb_item("Inter-cell spacing:_1",0,2,4);
页: [1]
查看完整版本: WinRunner:JComboBox in a JTable