Info

此问题已关闭。 请重新打开它进行编辑或回答。

Matlab is returing recently created Java table, though i try to get old jva table.

2 次查看(过去 30 天)
Hello,
I have created a java table and trying to invoke the same on to my matlab figure.
If i create only one java table on my Matlab figure, I am able to set the values and color on it with out any problem.
If i try to create more than one java table, Matlab always points to the handle of the recently created java table though i use different variables for all the tables.
Please find the snippet of the code below.
%-------------------------------------------- function TableTest global GD GD.fgH = figure(2); Gridbag('setLayout',GD.fgH,[3 300 3],... %it is not matlab function. [0 1 0],... [3 100 3 100 3 100 3],... [0 0.4 0 0.3 0 0.3 0],[],10, 10); set(GD.fgH ,'ResizeFcn',@(hObject,eventdata)fgH_ResizeFcn);
import('com.bosch.dgs.etb.proptable.*'); %This is my java table
%% Table 1 GD.autoEvalpnl1 = uipanel('parent',GD.fgH,... 'tag','pnlAutoEvalView1',... 'units','normalized',... 'visible','on',... 'BorderType','etchedout'); Gridbag('setConstraint',GD.autoEvalpnl1,2,1,6,1); Gridbag('setLayout',GD.autoEvalpnl1,[3 250 3],... [0 1 0],... [3 90 3],... [0 1 0],[],10, 10); set(GD.autoEvalpnl1 ,'ResizeFcn',@(hObject,eventdata)autoEvalpnl1_ResizeFcn);
GD.tblMapData1 = javaObjectEDT('com.bosch.dgs.etb.proptable.PropTable'); [hJTable, htblMapData1] = javacomponent(GD.tblMapData1.getScrTable,[1,1,1,1],GD.autoEvalpnl1); Gridbag('setConstraint',htblMapData1,2,1,2,1,[0 0 0 0], 'BOTH','CC');
%% Table 2 GD.autoEvalpnl2 = uipanel('parent',GD.fgH,... 'tag','pnlAutoEvalView1',... 'units','normalized',... 'visible','on',... 'BorderType','etchedout'); Gridbag('setConstraint',GD.autoEvalpnl2,2,1,4,1); Gridbag('setLayout',GD.autoEvalpnl2,[3 250 3],... [0 1 0],... [3 90 3],... [0 1 0],[],10, 10); set(GD.autoEvalpnl2 ,'ResizeFcn',@(hObject,eventdata)autoEvalpnl2_ResizeFcn);
GD.tblMapData2 = javaObjectEDT('com.bosch.dgs.etb.proptable.PropTable'); [hJTable, htblMapData1] = javacomponent(GD.tblMapData2.getScrTable,[1,1,1,1],GD.autoEvalpnl2); Gridbag('setConstraint',htblMapData1,2,1,2,1,[0 0 0 0], 'BOTH','CC'); end
function autoEvalpnl1_ResizeFcn() global GD Gridbag('resize', GD.autoEvalpnl1); end %end of 'autoEvalpnl2_ResizeFcn'
function fgH_ResizeFcn() global GD Gridbag('resize', GD.fgH); end %end of 'mapDatapnl1_ResizeFcn'
function autoEvalpnl2_ResizeFcn() global GD Gridbag('resize', GD.autoEvalpnl2); end %end of 'mapDatapnl1_ResizeFcn' %-------------------------------------------------
%% Change the color of the cell in java table using below command.
GD.tblMapData1.getTableObject.getTableModel.setCellColor(java.awt.Color.red, 3, 7)
Though i try to change the color of the cell in table 1, changes get affects on table 2, since table 2 is created recently.
Please help me, why it is happening so?. I am understanding.
Thanks!

回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by