java.awt.Robot command and msgbox incompatability?

1 view (last 30 days)
I had a function script that was working great. Part of it includes a little java.awt.Robot command that creates a custom mouse cursor. The script works exactly as I intended it to, without any bugs/errors so far as I can tell through repeated runnings.
However, I decided to add a msgbox command into the script, which gives the user running the program a couple instructions about what to do to run the program. Adding the msgbox command in seems to deactivate the java.awt.Robot command, even if I use various uiwait related workarounds.
Any idea what the problem is here? msgbox is overriding the Robot command I gave earlier in the function. Is the best option to:
-override msgbox? how do I do this? -use something besides msgbox for a pop-up text window, that won't interfere with java.awt.Robot? what's another option in MATLAB without going into a complicated route with subfigures and uicontrol text boxes?
For the record, here is the function in question (I put asterisks around the relevant parts of the code, that being the java.awt.Robot command and msgbox command for emphasis, they are obviously not part of the real function):
function START_Callback(a,b)
delete(gcf);
nRep = 1;
files = dir(fullfile(matlabroot,'toolbox','semjudge',bpic,'*.png'));
nFiles = numel(files);
combos = nchoosek(1:nFiles, 2);
index = combos(randperm(size(combos, 1)), :);
picture1 = files(index(nRep,1)).name;
picture2 = files(index(nRep,2)).name;
image1 = fullfile(matlabroot,'toolbox','semjudge',bpic,picture1);
image2 = fullfile(matlabroot,'toolbox','semjudge',bpic,picture2);
subplot(1,2,1); imshow(image1);
subplot(1,2,2); imshow(image2);
set(gcf,'Color',[1 1 1]);
uicontrol('Style', 'text',...
'Position', [200 375 200 20],...
'String','How related are these pictures?');
uicontrol('Style', 'text',...
'Position', [50 375 100 20],...
'String','Unrelated');
uicontrol('Style', 'text',...
'Position', [450 375 100 20],...
'String','Closely related');
nxt = uicontrol('Style','pushbutton','String','Next Trial',...
'Position', [250 45 100 20],...
'Callback',{@NextTrial});
set(nxt,'Enable','off');
**P = ones(16);
P(2:16,2:16) = NaN;
set(gcf, 'Pointer', 'custom','PointerShapeCData',P);
jRobot=java.awt.Robot;
x=928;
y=457;
jRobot.mouseMove(x,y);**
h = uicontrol(gcf,...
'Style','slider',...
'Min' ,0,'Max',100, ...
'Position',[100 350 400 20], ...
'Value', 50,...
'SliderStep',[0.02 0.1], ...
'BackgroundColor',[0.8,0.8,0.8],...
'Callback', @SliderCallBackFcn);
set(gcf, 'WindowButtonMotionFcn', @point);
set(gcf, 'WindowScrollWheelFcn', @cb);
**msgbox('INSTRUCTIONS GO HERE');**
lastVal = get(h, 'Value');
end
  1 Comment
Jan
Jan on 2 Apr 2012
Please explain, what "seems to deactivate the java.awt.Robot command" exactly mean. I cannot guess this important detail.
It is recommended to post a small program only, which reproduces the problem. Posting unnecessary information discourage users from answering.

Sign in to comment.

Answers (0)

Categories

Find more on Dialog Boxes in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!