COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Underlining text in JLabel

• Email
• Follow

Hi
I am looking for an example code on how to underline text displayed in JLabel.

thanks for any help
Hari

 0

See related articles to this posting

In article <f4ce927d.0309230814.1c2dfade@posting.google.com>,
hari.motati@gs.com (Hari) wrote:

>:Hi
>:I am looking for an example code on how to underline text displayed in
>:JLabel.
>:
>:thanks for any help
>:Hari

You can't actually underline text in a JLabel.  You can set its font, so
perhaps you can some up with a font that includes underlines.  But an
even simpler possibility would be to use HTML.  Let's see -- don't you
underline text in HTML with <u> and </u> tags?  Then your JLabel's text
value could be "<html><u>some text here</u></html>" and it should work.

= Steve =
--
Steve W. Jackson
Montgomery, Alabama

 1

hari.motati@gs.com (Hari) writes:

> I am looking for an example code on how to underline text displayed
> in JLabel.

theLabel.setText("<html>Look at the <u>underline</u>!");

Note that this causes HTML rendering instead of the JLabel's normal
font setting, so it will look out of place unless you start playing
with stylesheets.

 0

In article <u7k3ze7l2.fsf@broadpark.no>,

>:hari.motati@gs.com (Hari) writes:
>:
>:> I am looking for an example code on how to underline text displayed
>:> in JLabel.
>:
>:theLabel.setText("<html>Look at the <u>underline</u>!");
>:
>:Note that this causes HTML rendering instead of the JLabel's normal
>:font setting, so it will look out of place unless you start playing
>:with stylesheets.

Why do you say that?  I've seen no evidence of it in our app's usage.
We set the font on numerous JLabel or JButton instances, and in a small
number we set the actual text using HTML (though we always close the
tags).  And none have exhibited any unusual appearance or behavior.

= Steve =
--
Steve W. Jackson
Montgomery, Alabama

 0

On 23 Sep 2003 09:14:24 -0700, hari.motati@gs.com (Hari) wrote:

>Hi
>I am looking for an example code on how to underline text displayed in JLabel.
>
>thanks for any help
>Hari

JLabel lbl = new JLabel("Blahblah");
lbl.setFont(new Font("Tahoma", Font.UNDERLINE, 10);

I don't know if this is correct, but I think it should work along those lines.

 -1

In article <eqa1nvgjudtfit16975n4o1rohhtggfsfi@4ax.com>,
Kevin Pors <krpors@yahoo.deletethisportion.co.uk> wrote:

>:On 23 Sep 2003 09:14:24 -0700, hari.motati@gs.com (Hari) wrote:
>:
>:>Hi
>:>I am looking for an example code on how to underline text displayed in
>:>JLabel.
>:>
>:>thanks for any help
>:>Hari
>:
>:JLabel lbl = new JLabel("Blahblah");
>:lbl.setFont(new Font("Tahoma", Font.UNDERLINE, 10);
>:
>:I don't know if this is correct, but I think it should work along those
>:lines.

Unfortunately, no.  There's no such thing as "Font.UNDERLINE" in the
Font class definition.  The only styles are PLAIN, BOLD, and ITALIC, and
the last two can be added to get both styles.

= Steve =
--
Steve W. Jackson
Montgomery, Alabama

 -1

"Steve W. Jackson" wrote:

> Why do you say that?  I've seen no evidence of it in our app's
> usage.  We set the font on numerous JLabel or JButton instances,
> and in a small number we set the actual text using HTML (though we
> always close the tags).  And none have exhibited any unusual
> appearance or behavior.

When HTML labels were introduced, they indeed came up with a different
font and alignment then the normal font on the the label. This was the
case for a long time, and only fixed in recent VMs.

You still need HTML like

button.setText("<html><font face=Dialog size=1><b>"
+ text +
+ "</b></font></html>");

on older VMs.

 0

In article <Xns940051F81FCFDhhtoken@194.97.5.9>,
Harald Hein <speechless@gmx.de> wrote:

>:"Steve W. Jackson" wrote:
>:
>:> Why do you say that?  I've seen no evidence of it in our app's
>:> usage.  We set the font on numerous JLabel or JButton instances,
>:> and in a small number we set the actual text using HTML (though we
>:> always close the tags).  And none have exhibited any unusual
>:> appearance or behavior.
>:
>:When HTML labels were introduced, they indeed came up with a different
>:font and alignment then the normal font on the the label. This was the
>:case for a long time, and only fixed in recent VMs.
>:
>:You still need HTML like
>:
>:    	button.setText("<html><font face=Dialog size=1><b>"
>:    	    	    	+ text +
>:			+ "</b></font></html>");
>:
>:on older VMs.

That might explain why one of our uses of HTML on a JButton has
something similar.  It was done quite some time ago, and I couldn't
remember the rationale, since the person who actually coded it isn't
with our team any longer.

= Steve =
--
Steve W. Jackson
Montgomery, Alabama

 0

7 Replies
4387 Views

Similar Articles

11/30/2013 6:44:46 AM
page loaded in 5193 ms. (0)

Similar Artilces:

Text
I have pasted a MS word text doc into FM. Most of it is ok, but one area will not format correctly, it looks ok in Browse and layout but appears different in preview & print! Does the font have anything to do with this, I am using Arial? The text I am entering is below and line a is causing problems. Mortgage does not fit on the line and goes over to the next line but does not indent correctly. I tried inserting spaces and tabing but none of this works! a) Full advice and recommendation so we can make an informed decision with you about the choice of your new mortgage. b) Information on different types of mortgage products available to allow you to make a choice. c) Information on a single product only, where no advice is given. Any suggestions? Ernie

text
Hello, I want to distribute a program which displays a lot of text in various text or label controls. I aim to set the text within the program itself, rather than reading it from a txt file. I know how to do this OK, but are there any tips or tricks for writing out / handling / storing long text strings within the code? Thanks KK Start a resource file for the project. (The Resource Editor can be opened via the toolbar button that looks like the Regedit icon.) In the Res. editor: Double-click the "abc" icon to open the string table. In the string table window click the left-most icon to create a new row. You'll get a text field numbered 101 where you can enter and save a string. In your program, when you want to use that string: s = LoadResString(101) -- _____________________________ mayayXXana1a@mindYYspring.com For return email remove XX and YY. _____________________________ KK <trebor@yeleek.nospam.freeserve.co.uk> wrote in message news:cs33su$p78$1@newsg1.svr.pol.co.uk... > Hello, > > I want to distribute a program which displays a lot of text in various text > or label controls. I aim to set the text within the program itself

Highlighy text in Text Box
Using an InputBox, there is the option to *suggest* text (Default). It appears highlighted and can be accepted or replaced by the user. I am attempting to create my own input form which has one Text Box, one command button (cmdAccept ) and a simple label to tell the user to make an entry. What I cannot do is to mimic that suggested default input string. Can someone show me how to do it? The following code is from a test program with two forms. '#### this is on FrmMain Private Sub Option1_Click() ' Other Event selected - 14 character maximum With FrmBGOther...$5N3.2631@bgtnsc05-news.ops.worldnet.att.net... > Using an InputBox, there is the option to *suggest* text (Default). It appears highlighted and can > be accepted or replaced by the user. I am attempting to create my own input form which has one Text > Box, one command button (cmdAccept ) and a simple label to tell the user to make an entry. What I > cannot do is to mimic that suggested default input string. Can someone show me how to do it? > > The following code is from a test program with two forms. > > '#### this is on FrmMain > > Private Sub Option1_Click() > > matrix and text to a text file Hi, I know some similar question have been solved before but I have been reading for a while and I didn't find the answer of my question so, I ask you. I want to create a text-file (.txt) where I will have some text and some matrixs. The format that i want is something like that: -Title- Name1. Name2. power(dbm): big matrix (12000X400) aprox frequency(hz) vector(1x12) aprox So, i created a m-file that can do this writing with fprintf every single character on the file using lots of for loops. It works good but if the matrix is that size it could take a time (about 7 minutes) to create the text file. I have read about dlmwrite and I thought it was ok for me because you can put the matrix wherever you want in the text file, but before it deletes the text that it was in the file. So, that's what I want, create a text file with some lines of text that introduces numeric matrices. Thanks in advance, Juanxu "Juan Xu!" wrote in message <jahgba$csh$1@newscl01ah.mathworks.com>... > Hi, I know some similar question have been solved before but I have been reading for a while and I didn't find the answer of my question so, I ask you. > > I want Selecting text in a text box When I attempt to select text in a text box, the text from the cursor position to the end of the text is instantly selected as soon as I click the mouse down. There seems to be no way to select just a small portion of the text in a text box. This seems pretty basic. What am I missing? I'm using Access 97 on an XP system. Steve Richfield First, (I don't remember if this is an option in 97) check Tools|Options|Keyboard tab, Behavior Entering Field. This setting will adjust the behavior for all forms and controls. Next, you would need to click at the start of the area you want to highlight and drag over the rest of the area you want to highlight while holding down the left mouse button until you reach the end of the desired text. If you will always want to highlight the same section of text, then in the control's Got Focus event you can select text using code. Check the SelStart and SelLength properties in the VBA help file. -- Wayne Morgan MS Access MVP "Steve Richfield" <google@smart-life.net> wrote in message news:785c9c16.0411052022.261ec5e2@posting.google.com... > When I attempt to select text in a text box, the text from the cursor Fit text in a Text Box Hello friends, I have a curious doubt, imagine I have a text box, and inside, a text that I dont know the lenght. Depending on the box's size and letter's size, I can fit the box. But the box's size is fixed, so I just can modify the size's letter. How can I be right with letter's size, if I dont know the lenght of string (text)? Is there any simple function for this case? Thanks in advance, greetings. Pedro Moreno On 10-08-31 04:25 PM, pedro moreno wrote: > I have a curious doubt, imagine I have a text box, and inside, a text > that I dont know the lenght. Depending on the box's size and letter's > size, I can fit the box. But the box's size is fixed, so I just can > modify the size's letter. How can I be right with letter's size, if I > dont know the lenght of string (text)? Is there any simple function for > this case? Temporarily set the width of the text uicontrol to bigger than you could possibly need, and start with the desired FontSize. get() the control's String property and store that in a variable. Now, [junk, recommended] = textwrap(TextboxHandle, DesiredString); recommended(3) will now Scanned text I want to scan a magazine article and paste it into text edit so it reads the article to me. Is this possible?? Any other programs?? On 23 May 2005 11:42:47 -0700, "CBSIV" <blakeman22@hotmail.com> wrote: >I want to scan a magazine article and paste it into text edit so it >reads the article to me. Is this possible?? Any other programs?? first you'll have to OCR the scan to convert it text. You'll need to get this program or something similar: http://www.pugh.co.uk/Products/scansoft/omnipagepromac-X.htm or just search google for "Mac OCR programs" and you might find something cheaper. I use Omnipage and it gives the best accuracy out of all the ones I've used. Image to Text Hi there, I am trying to convert a jpeg image into text, so that I can save it into a database. The reason is, our database already has few million images in the form of String, fed though a PHP script that uses ob_get_contents() function in PHP... http://us.php.net/manual/en/function.ob-get-contents.php I am trying to accomplish the same task using java. Any help would be appreciated. cheers, ozz Ozz wrote: .. >..convert a jpeg image into text, .. See <http://www.google.com/search?q=ocr+java> HTH -- Andrew Thompson http://www.athompson.info/andrew/ Message posted via JavaKB.com http://www.javakb.com/Uwe/Forums.aspx/java-setup/200706/1 Ozz wrote: >> ..convert a jpeg image into text, .. Andrew Thompson wrote: > See <http://www.google.com/search?q=ocr+java> Hm, interesting. I took the post to be a request for how to encode a JPEG (or any binary file) into a String. (Beware: Strings are terrible homes for binary data because they have text character encoding.) Which is it? Are we encoding a binary as a String, or are we extracting Strings from an image via OCR? If it is encoding you want, use Base64 encoding. That produces byte arrays Text labels... Hi I was programming a lot in C When i wanted to make text label i was using something like: #define MY_PROGRAM_RESULTS "Result of the program = %d\n" printf(MY_PROGRAM_RESULTS, result); But this method works only when i use stdio functions... Now i have started using iostream cout<< and cin>> functions... In what way should i store text labels (if i want to display few variables in one line)? [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] In article <1132957160.304033.216360@g14g2000cwa.googlegroups.com>, peter_k <asm3@o2.pl> writes >Hi > >I was programming a lot in C >When i wanted to make text label i was using something like: > >#define MY_PROGRAM_RESULTS "Result of the program = %d\n" >printf(MY_PROGRAM_RESULTS, result); > >But this method works only when i use stdio functions... Now i have >started using iostream cout<< and cin>> functions... > >In what way should i store text labels (if i want to display few >variables in one line)? > #include <iostream> #include <string> Hidden Text OK this may sound too simple to understand but I have created a drawing template and because the linked text (while I was in edit sheet format mode) was overrunning into the next "block" and I couldn't see the text... so I right-clicked on the text that was blocking it, selected HIDE, and *poof* it dissapeared. Now I want it back. I can't seem to figure out how to "unhide" it. I tried the hide/unhide annotation from the view menu, nothing. Other than that I can't seem to find any other way to attempt viewing or selecting the hidden text. Is this a solidworks glitch, or am I just blind? Well after I contacted my vendor, I found out that this is a solidworks "bug" and is slated to be fixed with the updated version.... Dang.... thought I was losing my mind! Text Parser Group, I admit it, I'm a hack. As a test engineer I'm faced with many application problems. Most of the time, I take something that already works, back-engineer it and use it. Now some of my colleagues swear that TCL can be an excellent text parser. Seems like today we collect so much data, but can't seem to manipulate like we would like. Can someone suggest a TCL script that can parse comma separated data? I want to take this data and arrange it so I can use it. Any examples would be fantastic. The data looks something like this. Socket, Time Stamp, Serial... provide more precise > help. "ajocius" <ajocius@insightbb.com> wrote in message news:25CdnYVqy6EkiQ3ZnZ2dnUVZ_omdnZ2d@insightbb.com... > Can someone suggest a TCL script that can parse comma separated > data? I want to take this data and arrange it so I can use it. Any > examples would be fantastic. The data looks something like this. Hi Tony, As others have already stated, Tcl is more than up to the task of manipulating text-based data in any way you might see fit. That said though, as you are specifically interested in manipulating CSV data Text Editor Help, I am unable to open the Text icon in either PSP 6 or 7!! ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via Encryption =---- Text Clustering I have been searching for Text Clustering libraries for two days.I have about 200 txt documents each of which contains 3-4 sentences.What i want to do is cluster them in around 10 categories based on the keyword each document contains.Can anyone suggest me some library , code or some algorithms or any other helpful links. Thank you. prabesh shrestha wrote: > I have been searching for Text Clustering libraries for two days.I > have about 200 txt documents each of which contains 3-4 sentences.What > i want to do is cluster them in around 10 categories based on the > keyword each document contains.Can anyone suggest me some library , > code or some algorithms or any other helpful links. Your multi-post is not necessary, as you received an answer over on clj.help to your question already. -- Lew pdf to text I am looking for a way to convert PDF files into text content. I don't care about layout or formatting, just the plain text that I can use to search against in a database. I've look into the pdftotext tool from: http://www.foolabs.com/xpdf/download.html However, when I use it via the command line, it works fine. If I issue the same command via a system() call, there are major problems that cause the server to crash. (Don't know why, there aren't any error messages been generated anywhere.) I am looking to use this when a PDF file is uploaded via a form and store the text in a database for a search function. TIA -- Justin Justin Koivisto wrote: > > I am looking for a way to convert PDF files into text content. I vaguely remember using Ghostscript for that... Cheers, NC I have not used pdftotext via system(). However you could try different versions of pdftotext. In my experience the version you use can have quite different effects. Different versions should be easily available. It's also possible to use ascii2txt, which depends on Ghostscript I think. When I tried it I got into a muddle of versions though, and pdftotext was much easier Text Patterning... from the coordinates & strings. Basic idea: just stack boxes - left to right accumulating the x position (and compensating for text just placed) and varying the raises, or smash-ing the boxes and using absolute coordinates via \hspace and \raisebox. Defeated again.... code below shows two failed attempts. Anyone see what's wrong? Thanks... Julian \documentclass{minimal} \begin{document} \newlength{\hpad} \newlength{\tpad} Just a line of text\par \vspace{2in}\par % First example - Absolute coordinates; horizontal results approximately OK, but the vertical... was trying to put some words in a circle around a central > short 2 line para (x...1,x...2 in the example below) ... I worked out > a clever way of doing this that involved laying it out in Photoshop, > measuring placements, then putting the results into Excel and > generating LaTeX code from the coordinates & strings. > > Basic idea: just stack boxes - left to right accumulating the x > position (and compensating for text just placed) and varying the > raises, or smash-ing the boxes and using absolute coordinates via > \hspace and \raisebox. > > Text Question to fix this every time it occurs, but I don't know what to look for. Any suggestions on how to find out what's going on in the text or how to fix it? Isaac -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday, 18 November 2013 12:09 -0800, in article <isw-9DE50A.12092018112013@[216.168.3.50]>, isw <isw@witzend.com> wrote: > I collect recipes. Of course, recipes frequently use amounts such as > "1/2" or "1/4". > Sometimes, when I import recipes into Mac Gourmet from certain web > sites, the fraction is sort..., representing one half, one third, two thirds, one quarter and three quarters.) There are plenty of other fractional representation, for one fifth, through seven eighths. These are quite standard representations of digits. > I'd like to write a script to fix this every time it occurs, but I > don't know what to look for. > Any suggestions on how to find out what's going on in the text or > how to fix it? As there's nothing broken in these representations, I'm uncertain it requires a 'fix'. Perhaps choosing a different font or font size Text in plot I am trying to use 'text' to write something in my plot but after running nothing appears Can any one knows what is the problem ? text(1000,1000,'string') .... or text(5*pi/4,sin(5*pi/4),... ['sin(5*pi/4) = ',num2str(sin(5*pi/4))],... 'HorizontalAlignment','center',... 'BackgroundColor',[.7 .9 .7],... 'Margin',10); "roya olyazadeh" <roya2543@gmail.com> wrote in message <ht0po6$2lh\$1@fred.mathworks.com>... > I am trying to use 'text' to write something in my plot > but after running nothing appears > Can any one knows what is the problem ? > > > text(1000,1000,'string') .... > or > > text(5*pi/4,sin(5*pi/4),... > ['sin(5*pi/4) = ',num2str(sin(5*pi/4))],... > 'HorizontalAlignment','center',... > 'BackgroundColor',[.7 .9 .7],... > 'Margin',10); try this plot(0:pi/20:2*pi,sin(0:pi/20:2*pi)) text(pi,0,' \leftarrow sin(\pi)','FontSize',18)

Text in Solidworks
All, How do I get SolidWorks (2004) to display/print text on a sketch as solid text vs. the outline of the letters? I am trying to create camera ready art for a silk screen. My examples have to be displayed in "Courier New" font to look right. They can be pasted into notepad. What I get is like this: ___ / _ \ / / \ \ / / \ \ | /_____\ \ | _____ | | | | | |_| |_| What I want is like this: ### ## ## ## ## ## ## ######### ## ## ## ## Also, SolidWorks insists on saving/printing a small dot at the lower left corner of the text block. Is there a way to suppress that? Thanks so much! I am very green at this program. --Doug Direct Email: D.Canfield [AT] Motorola.Com I don't think Solidworks is the best to use to to artwork going to screen printing. I would generally pick either a 2D CAD program or one of Adobe's Illustrator to do text work, though lots of programs can output good text. Bo 1) extrude the letters into a part, and then make a drawing of the part--this will get rid of the dot 2) in the drawing, use a solid cross hatch, and you'll get