Comments on: Customizing uicontrol border https://undocumentedmatlab.com/blog_old/customizing-uicontrol-border Charting Matlab's unsupported hidden underbelly Fri, 21 Apr 2023 18:07:53 +0000 hourly 1 https://wordpress.org/?v=4.4.1 By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/customizing-uicontrol-border#comment-348772 Sun, 03 May 2015 06:46:36 +0000 https://undocumentedmatlab.com/?p=1947#comment-348772 As I said, If you wish me to spend some time to investigate this, contact me by email for a private consulting.

]]>
By: liuhttps://undocumentedmatlab.com/blog_old/customizing-uicontrol-border#comment-348764 Sun, 03 May 2015 01:10:16 +0000 https://undocumentedmatlab.com/?p=1947#comment-348764 What happens is that depending on button presses editboxes are dynamically created, customized, removed all the time.

Essentially, I just need to keep new ones at the back of old components. The problem is that new ones always appear on top, and a single ‘uistack’ call removes all previous border changes.

To cut the long way with codes, could you give a quick tip (or keywords) on:
Is it possible to add new components right to the back with java? Or can we set some java ‘always on top’ property? (similar to TooltipString behavior)

(Thanks a lot for all your time and prompt response!)

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/customizing-uicontrol-border#comment-348762 Sat, 02 May 2015 23:13:46 +0000 https://undocumentedmatlab.com/?p=1947#comment-348762 I do not accept your claim. You can always store the findjobj-ed handle in some variable and then use it immediately after uistack to reset the border.
I don’t know what the specific problem with the z-order is.
If you wish me to spend some time to investigate this, contact me by email for a private consulting.

]]>
By: liuhttps://undocumentedmatlab.com/blog_old/customizing-uicontrol-border#comment-348761 Sat, 02 May 2015 23:08:15 +0000 https://undocumentedmatlab.com/?p=1947#comment-348761 😉 Unfortunately, it is impossible in the actual code, where I need this. I’ve shown a very simplified demo-script. The actual code does not allow to permute those operations. Is there a way to fix ‘z-Order’ solution in the previous code? Thank you!

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/customizing-uicontrol-border#comment-348760 Sat, 02 May 2015 22:46:36 +0000 https://undocumentedmatlab.com/?p=1947#comment-348760 @Liu – why not simply move the uistack command before findjobj, then modify the border?

]]>
By: liuhttps://undocumentedmatlab.com/blog_old/customizing-uicontrol-border#comment-348759 Sat, 02 May 2015 22:43:53 +0000 https://undocumentedmatlab.com/?p=1947#comment-348759 Hello. I noticed that ‘uistack’ call cancels border changes made with the suggested java method. Is there a way to change stack order but still keep customized border?
I’m trying ‘findjobj’ & ‘setComponentZOrder’ combination. The latter works well, but when I attempt to close the figure I get ‘NullPointerException’ error. See the code below. (Thanks a lot!!)

 
% --- Figure with listbox and editbox
f = figure; 
hList = uicontrol(f,'style','listbox','position',[10 10 400 20]);  
hEdit = uicontrol(f,'style','edit','position',[10 10 200 50]); 
 
% --- Change border of the editbox
jEdit = findjobj(hEdit);
jEdit.Border = javax.swing.border.LineBorder(java.awt.Color(0.3,0.3,0.3),3,true);
jEdit.repaint;             
 
% --- Method 1 - listbox to front - cancels border change
%uistack(hList,'top');
 
% --- Method 2 - listbox to front - java error on figure closing
jObj = findjobj(hList); 
jPar = jObj.getParent;
jPar.getParent().setComponentZOrder(jPar, 0);
jPar.getParent().revalidate;
]]>
By: Lemikainenhttps://undocumentedmatlab.com/blog_old/customizing-uicontrol-border#comment-73086 Thu, 02 Feb 2012 09:35:44 +0000 https://undocumentedmatlab.com/?p=1947#comment-73086 thx for quick reply, already tried method you suggest yesterday but had some troubles and noticeable delay before changes are applied. Especially if i try to change border and background at the same time, it only changes one property and i have to rerun it to change all… (changing foreground and background at the same time works)

Do you have any idea how to minimalize the delay before applying changes?
here is the code i use
**************************************************************

lineColor = java.awt.Color(1,1,1); 
thickness = 1; 
roundedCorners = false;
newBorder = javax.swing.border.LineBorder(lineColor,thickness,roundedCorners);
 
backgroundColor=java.awt.Color(0.141,0.518,1);
foregroundColor=java.awt.Color(1,1,1);
jButton = findjobj('class','pushbutton');       
length(jButton)
 
for i=1:1:length(jButton)
   set(jButton(i), 'Background', backgroundColor, 'Foreground', foregroundColor, 'Border', newBorder);
end
]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/customizing-uicontrol-border#comment-73050 Wed, 01 Feb 2012 16:49:00 +0000 https://undocumentedmatlab.com/?p=1947#comment-73050 FindJObj *cannot* work in the GUIDE-created *_OpeningFcn because the figure is not yet visible at this time and so the Java components have still not rendered and therefore cannot be found.

Try placing your call to FindJObj *after* the figure has become visible and all the controls have completed rendering, for example by moving your FindJObj call to the *_OutputFcn function, hopefully after a call to drawnow to ensure that everything has completed rendering.

]]>
By: Lemikainenhttps://undocumentedmatlab.com/blog_old/customizing-uicontrol-border#comment-73049 Wed, 01 Feb 2012 16:44:34 +0000 https://undocumentedmatlab.com/?p=1947#comment-73049 Hi,
I´m having some troubles combining this way of setting parameters with GUI created using matlab GUIDE. Guide really doesn´t offer much customisation especially for button borders, colors and so on.

My problem is, that i don´t know where exactly should i place the code, which changes button border… At first, I placed it logically into main figure opening function (executed before figure actually appears), but findjobj doesn´t find any java objects (it returns just empty array), although handle structure already consist of all matlab gui handles… it works If I change code and press, while app is already launched. (java objects existing…)

Do you have any suggestions how to solve my problem?

]]>
By: marcohttps://undocumentedmatlab.com/blog_old/customizing-uicontrol-border#comment-55441 Wed, 31 Aug 2011 12:23:11 +0000 https://undocumentedmatlab.com/?p=1947#comment-55441 unfortunatly it really bothers me!! :(
because i build a complex gui, with panels that are updating if the user interact with it, adding or removing for examples some line or plots. In this panels there are for example text and check boxes…and when there are too many, a slider is implemented. there is a function to grid the visualization when the figure is resized or no. So when a slider is called and the user move it, the uitext and other objects on that panels are ”flying” in the figure…..
any idea or suggestion to solve it?

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/customizing-uicontrol-border#comment-55437 Wed, 31 Aug 2011 11:24:03 +0000 https://undocumentedmatlab.com/?p=1947#comment-55437 @Marco – in theory this should be done by the Clipping property, which is ‘on’ by default. Unfortunately, as the documentation states: “This property has no effect on uicontrol objects“. You can play around with the Z-Order (see uistack), or you can trap and fix this programmatically (mouse motion callback etc.), if it really bothers you.

]]>
By: marcohttps://undocumentedmatlab.com/blog_old/customizing-uicontrol-border#comment-55427 Wed, 31 Aug 2011 07:52:35 +0000 https://undocumentedmatlab.com/?p=1947#comment-55427 hello,
regarding borders i got a question: suppose to have a figure, put inside a panel, put inside this panel a uitext. suppose now to put a slider, to move the text in the panel. When the uitext reaches the borders of the panel, it won’t hide, but it overlap the panel’s borders, going outside it, over the figure ground.
Instead if you got a panel inside the another panel, and you move it, it is hiding itself when it go out the borders of its parents. It is a ”bug” of matlab or is there any property to set to the uitext? (it happen also with buttons etc…). Any solution?
see the example here:
%creating the figure, the panel and uitext
fig=figure();

pnl1 = uipanel(‘parent’,fig,’units’,’normalized’,’position’,[.1 .1 .5 .5],’BackgroundColor’,[.5 .8 .8]);

txt1 = uicontrol(‘parent’,pnl1,’style’,’text’,’string’,’hello’,…
‘BackgroundColor’,[.9 .7 .8],’units’,’normalized’,’position’,[.2 .2 .5 .5]);
%trying to move the text
set(txt1,’position’,[.3 .8 .5 .5])

%same example with a panel
pnl2 = uipanel(‘parent’,pnl1,’BackgroundColor’,[.9 .1 .8],’units’,’normalized’,’position’,[.2 .2 .5 .5]);

set(pnl2,’position’,[.7 .2 .5 .5])

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/customizing-uicontrol-border#comment-21770 Wed, 03 Nov 2010 19:41:39 +0000 https://undocumentedmatlab.com/?p=1947#comment-21770 @Jos – it is indeed possible to include icon images in tabs. For example, an ‘x’ button to close the tab, as in modern browsers. I’ll write about this in next week’s post.

– Yair

]]>
By: Jos von Asmuthhttps://undocumentedmatlab.com/blog_old/customizing-uicontrol-border#comment-21714 Wed, 03 Nov 2010 08:02:58 +0000 https://undocumentedmatlab.com/?p=1947#comment-21714 Hi Yair,

Thanks for sharing all this knowledge! A uicontrol customization I would be interested in, is related to tabpanels. Although they could be very userfull, I am not very satisfied with the way uitabs look and function in Matlab. In particular, I would like to incorporate bitmap pictures in uitabs, comparable to how they can be incorporated in buttons or toolbars. Is that possible?

Thanks in advance,
Jos

]]>