I need to integrate radiobuttons in uitable control

2 views (last 30 days)
Hi,
As we can change the column-format property to checkbox, popupmenu options in the uitable, I need help for changing the column-format property to radiobutton.
Regards, Sai.

Answers (2)

Jakob Thumm
Jakob Thumm on 3 Jul 2017
Hi,
I had a similar problem. So I created my own little table, but it´s not a uitable. I just draw a bunch of lines to create a simple looking clean table. As radiobuttons I used javacomponents. Here is my example. I hope, that it helps some of you guys.
f = figure();
%%seperator lines
a = axes;
set(a, 'Parent', f);
set(a, 'Visible', 'off');
%# Stretch the axes over the whole figure.
set(a, 'Position', [0, 0, 1, 1]);
%# Switch off autoscaling.
set(a, 'Xlim', [0, 1], 'YLim', [0, 1]);
% create lines (table)
startX = 0.2;
cellWidth = 0.2;
y1=0.9;
y2=0.6;
line([startX, startX], [y1, y2], 'Parent', a,'Color','black');
line([startX+cellWidth, startX+cellWidth], [y1, y2], 'Parent', a,'Color','black');
line([startX+2*cellWidth, startX+2*cellWidth], [y1, y2], 'Parent', a,'Color','black');
line([startX+3*cellWidth, startX+3*cellWidth], [y1, y2], 'Parent', a,'Color','black');
startY = 0.8;
cellHeight = 0.07;
x1 = 0.05;
x2 = 0.95;
line([x1, x2], [startY, startY], 'Parent', a,'Color','black');
line([x1, x2], [startY-cellHeight, startY-cellHeight], 'Parent', a,'Color','black');
line([x1, x2], [startY-2*cellHeight, startY-2*cellHeight], 'Parent', a,'Color','black');
% create buttons
bStartX = 150;
bDistX = 110;
bStartY = 310;
bDistY = 30;
myListOfLists = java.util.ArrayList();
myGroupList = java.util.ArrayList();
nullString = java.lang.String('');
for i=0:2
myList = java.util.ArrayList();
group1 = javax.swing.ButtonGroup();
for j=0:3
if j==0
aRButton = javax.swing.JRadioButton(nullString,1);
else
aRButton = javax.swing.JRadioButton(nullString,0);
end
[bComp,bContainer] = javacomponent(aRButton,[bStartX+j*bDistX,bStartY-i*bDistY,25,25],f);
set(bContainer, 'Units','norm');
group1.add(aRButton);
myList.add(aRButton);
end
myListOfLists.add(myList);
myGroupList.add(group1);
end
% get selected item at position 1/1
list0 = myListOfLists.get(0);
listItem00 = list0.get(0);
listItem00.isSelected()

Walter Roberson
Walter Roberson on 14 Oct 2011
That is not supported. If it can be done, it would have to be done at the Java level. You could try looking for information on http://undocumentedmatlab.com
  2 Comments
Sainath
Sainath on 15 Oct 2011
ThankQ for your time....
As I don't have knowledge in Java, can you help me how to code it.
Walter Roberson
Walter Roberson on 15 Oct 2011
The required changes are beyond my knowledge. Looking at Yair's pages such as http://undocumentedmatlab.com/blog/uitable-sorting/ I would speculate that if what you want could be done, it would have to be by way of a custom cell renderer. Yair does not appear to have an example of that on his web site, but you can order a detailed report about customizing Uitables from him; see http://undocumentedmatlab.com/blog/uitable-customization-report/
Yair does ask a fee for his uitable report. I have complete confidence that if you need to customize uitables, that the report is well worth paying for: Yair does very detailed work.
I have never had the need myself to customize uitable ... or to use them for must of anything.
If you could explain more about your reasons for wanting to put a radio button inside a uitable, someone might be able to suggest an alternative (which might perhaps not involve uitable at all, and might perhaps not look nearly as nice as a uitable might... but if the main point of what you are doing is the functionality and the users are likely to be lenient about the appearance, then sometimes it is best to switch to more primitive technologies that at least get the job done.)

Sign in to comment.

Categories

Find more on App Building in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!