Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Java property to make edit text have no border?

Subject: Java property to make edit text have no border?

From: Becky

Date: 12 Feb, 2009 17:36:01

Message: 1 of 4

I downloaded the user contributed file "findjobj" and am using it to make an editable text box "Not Editable". Here is my code:

jEdit=findjobj(handles.text_Testing, 'nonmenu');
set(jEdit, 'Editable',0);

This works great. Now, I'd like to remove the border around the text box so that it looks more like a static text but remains editable. Is tehre a Java Swing property I can set that removes the border or a way to set the border color to the background color?

Thank You,
Becky McDermott

Subject: Java property to make edit text have no border?

From: Yair Altman

Date: 13 Feb, 2009 12:07:02

Message: 2 of 4

"Becky " <bmcdermott@phdx.com> wrote in message...
> I downloaded the user contributed file "findjobj" and am using it to make an editable text box "Not Editable". Here is my code:
>
> jEdit=findjobj(handles.text_Testing, 'nonmenu');
> set(jEdit, 'Editable',0);
>
> This works great. Now, I'd like to remove the border around the text box so that it looks more like a static text but remains editable. Is tehre a Java Swing property I can set that removes the border or a way to set the border color to the background color?
>
> Thank You,
> Becky McDermott


jEdit.setBorder('');

Alternately, you can use the standard 'text' uicontrol style, instead of the 'edit' style. This gives you a similar appearance as a non-editable no-border edit box.

BTW, you have a typo in your snippet: it's 'nomenu', not 'nonmenu'...

Yair Altman

Subject: Java property to make edit text have no border?

From: Becky

Date: 13 Feb, 2009 16:02:33

Message: 3 of 4

I tried the jEdit.setBorder(''); and got the following message:

??? No appropriate method, property, or field setBorder for class handle.handle.

I also tried :
set(JEdit, 'Border', '')
and didn't get any errors but my textbox still had a border around it.

I really want the editable text box because I want the user to be able to select the text in the box with the mouse. By setting the 'Editable' property on jEdit to 0, I prevent the text from being changed. But, I'd like the text box to have the appearance of a 'text' uiobject (hence why I want to remove the border).

I do have the uiproperties of max set to 2 and min set to 0 so that the text box would wrap. Could this be a problem?

Thanks,
Becky


"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message <gn3np6$rsc$1@fred.mathworks.com>...
> "Becky " <bmcdermott@phdx.com> wrote in message...
> > I downloaded the user contributed file "findjobj" and am using it to make an editable text box "Not Editable". Here is my code:
> >
> > jEdit=findjobj(handles.text_Testing, 'nonmenu');
> > set(jEdit, 'Editable',0);
> >
> > This works great. Now, I'd like to remove the border around the text box so that it looks more like a static text but remains editable. Is tehre a Java Swing property I can set that removes the border or a way to set the border color to the background color?
> >
> > Thank You,
> > Becky McDermott
>
>
> jEdit.setBorder('');
>
> Alternately, you can use the standard 'text' uicontrol style, instead of the 'edit' style. This gives you a similar appearance as a non-editable no-border edit box.
>
> BTW, you have a typo in your snippet: it's 'nomenu', not 'nonmenu'...
>
> Yair Altman

Subject: Java property to make edit text have no border?

From: Yair Altman

Date: 14 Feb, 2009 20:51:02

Message: 4 of 4

"Becky " <bmcdermott@phdx.com> wrote in message...
> I tried the jEdit.setBorder(''); and got the following message:
> ??? No appropriate method, property, or field setBorder for class handle.handle.
>
> I also tried :
> set(JEdit, 'Border', '')
> and didn't get any errors but my textbox still had a border around it.

State your Matlab version and how you created the textbox and perhaps we can help. The following code works perfectly ok in Matlab 7.7 (R2008b):

>> hEdit = uicomponent('style','edit');
>> jEdit = findjobj(hEdit,'nomenu')
jEdit =
javahandle_withcallbacks.com.mathworks.hg.peer.EditTextPeer$hgTextField
>> set(jEdit,'Border',''); % or jEdit.setBorder(''); => border disappears

 
> I do have the uiproperties of max set to 2 and min set to 0 so that the text box would wrap. Could this be a problem?

Apparently (this is undocumented anywhere and I could be wrong) Matlab creates a new underlying java object whenever some uicontrol properties (like min/max) are modified. Therefore, if you set min/max after clearing the border, the border returns because new editboxes have the border on by default. To fix, simply find the new jEdit *AFTER* setting min/max, then clear the border as above.

Yair

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us