2
votes

Background

We are migrating our matlab codebase from R2013b to R2014b and we're experiencing many small issues especially with GUIs (well this was quite we feared because of new the graphic system HG2).

Issue

One of the issue we have is for some buttons we customized using tips and tricks from Undocumented Maltab website and the findjobj routine from @yair-altman . We customized these buttons to have transparency effect and have buttons to look like hyperlinks. The code below works with R2013b, but with R2014b the border reappears any time the figure is resized with the mouse:

function [] = MigrationTransparency() 
%[
    figure(42); clf;
    hBtn = uicontrol('String', '<html><a href ="">Edit reconstruction grid</a></html>', 'Position', [10 10 170 25]);

    jBtn = findjobj(hBtn);
    jBtn.setCursor( java.awt.Cursor(java.awt.Cursor.HAND_CURSOR) );
    jBtn.setContentAreaFilled(0); % R2013b ==> No issue (the btn border is removed)
                                  % R2014b ==> The btn border reappears if figure is resized.
%]
end

NB1: The findjobj version we're using is the very last one (both for R2013b and R2014b ==> $Revision: 1.43 $ $Date: 2014/10/20 04:24:43 $).

NB2: We also tried modifying other java properties but without effect:

jBtn.setOpaque(0);
jBtn.setBorderPainted(0);
jBtn.setContentAreaFilled(0); 

Anybody having same trouble and/or guidance to workaround the issue ?

1

1 Answers

0
votes

Well, we found a workaround even if not so clear for us...

If we create the java component first (instead of finding it with findjobj) it works:

function [] = MigrationTransparency() 
%[
    figure(42); clf;
    doCreateJavaObjectFirst = true;

    if (doCreateJavaObjectFirst)

        % Is ok with R2013a and R2014b

        % 1) Create java object 
        jBtn = javax.swing.JButton('<html><a href ="">Edit reconstruction grid</a></html>');
        jBtn.setCursor(java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jBtn.setContentAreaFilled(0);

        % 2) Place component in the figure
        hBtn = javacomponent(jBtn, [10 10 170 25]);

    else

        % Is not ok with R2014b (border reappears on resize)

        % 1) Create matlab control
        hBtn = uicontrol('String', '<html><a href ="">Edit reconstruction grid</a></html>', 'Position', [10 10 170 25]);

        % 2) Find underlying java object 
        jBtn = findjobj(hBtn);
        jBtn.setCursor(java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jBtn.setContentAreaFilled(0);
        disp(jBtn); % To display data type

    end
%]
end

Debug

Looking deeply to what is returned by findjobj for the uicontrol in R2013b and R2014b (and using same reversion of findjobj $1.43 in R2013b and R2014b):

  • javahandle_withcallbacks.com.mathworks.hg.peer.PushButtonPeer$1