|
Hello all,
I have been searching for some time for a solution to focus
issues when using java components in a matlab GUI.
I can't seam to find a way to programmatically set the focus
on a given field. See below example.
Example:
function Focus_Issue()
screenSize = get(0,'ScreenSize');
gui = figure();
hiight = 200;
width = 300;
set(gui, 'Position', [screenSize(3)/2 screenSize(4)/2 width
hiight] );
set(gui, 'Tag', 'main_gui' );
set(gui, 'MenuBar', 'none' );
set(gui, 'NumberTitle','off');
set(gui, 'Name', 'Graphical User Interface' );
lowPos = [50 35 200 20];
middlePos = [50 80 200 20];
highPos = [50 125 200 20];
pwField1 = javax.swing.JPasswordField(20);
pwField2 = javax.swing.JPasswordField(20);
pwField3 = javax.swing.JPasswordField(20);
javacomponent(pwField1, lowPos);
javacomponent(pwField2, middlePos);
javacomponent(pwField3, highPos);
%pwField1.requestFocus
% Does nothing, returns false.
%uicontrol(pwField1);
% returns following error:
% ??? Error using ==> uicontrol
% Arguments may only include figure, uicontainer, or
uicontrol handle and param/value pairs.
Any suggestions would be appreciated.
|