Hi,
How would I print out the following in bold and in red.
System.out.printf("Sum of Parts " + "\n");
How would I do it.
TIA
Roy
|
|
0
|
|
|
|
Reply
|
royng (13)
|
6/21/2007 3:44:52 PM |
|
On Thu, 21 Jun 2007 11:44:52 -0400, Roy Gourgi wrote:
> Hi,
>
> How would I print out the following in bold and in red.
> System.out.printf("Sum of Parts " + "\n");
>
> How would I do it.
>
> TIA
>
> Roy
Assuming you are outputting to an ANSI-compliant terminal (e.g., xterm,
etc.):
System.out.println("\x1B[1mBOLD\x1B[0m\t\x1B[31mRED\x1B[0m");
will print BOLD in bold and RED in red. For more information about
controlling terminal output, see http://en.wikipedia.org/wiki/
ANSI_escape_code.
|
|
0
|
|
|
|
Reply
|
Joshua
|
6/21/2007 3:55:52 PM
|
|
Thanks Joshua,
There is no easier way than that?
It looks pretty cluttered. :)
I am using JBuilder
Roy
"Roy Gourgi" <royng@videotron.ca> wrote in message
news:02xei.88$we4.8410@wagner.videotron.net...
> Hi,
>
> How would I print out the following in bold and in red.
> System.out.printf("Sum of Parts " + "\n");
>
> How would I do it.
>
> TIA
>
> Roy
>
>
|
|
0
|
|
|
|
Reply
|
Roy
|
6/21/2007 4:03:48 PM
|
|
Roy Gourgi wrote:
>>
>> How would I print out the following in bold and in red.
>> System.out.printf("Sum of Parts " + "\n");
GIYF
http://www.javaworld.com/javaworld/javaqa/2002-12/02-qa-1220-console.html
>>
>> How would I do it.
>>
GIYF
http://www.javaworld.com/javaworld/javaqa/2002-12/02-qa-1220-console.html
|
|
0
|
|
|
|
Reply
|
Ian
|
6/21/2007 4:21:13 PM
|
|
Roy Gourgi wrote:
> There is no easier way than that?
> It looks pretty cluttered.
Such is the nature of ANSI escape sequences. You think that's cluttered?
Take a look at printer control streams sometime.
Bear in mind that by hard-coding ANSI escape sequences you are limiting your
program to run on consoles that support those escape sewquences, which cuts
you down to what I would guess to be 90% or more of the consoles you'd
encounter. Regardless of the actual proportion it's less than 100%, so you'll
be sacrificing the "Write Once, Run Anywhere" philosophy of Java. That might
be acceptable if you know you can assure ANSI compatibility on all targeted
consoles.
If you can think up an easier way let us know. Just remember that these
escape sequences are defined externally to Java; they're data, not code.
--
Lew
|
|
0
|
|
|
|
Reply
|
Lew
|
6/21/2007 4:33:17 PM
|
|
Hi Joshua,
I get the error message that x1B is an illegal escape character?
How can I fix that?
Roy
"Joshua Cranmer" <Pidgeot18@verizon.net> wrote in message
news:ccxei.2959$AR5.330@trnddc06...
> On Thu, 21 Jun 2007 11:44:52 -0400, Roy Gourgi wrote:
>
>> Hi,
>>
>> How would I print out the following in bold and in red.
>> System.out.printf("Sum of Parts " + "\n");
>>
>> How would I do it.
>>
>> TIA
>>
>> Roy
>
> Assuming you are outputting to an ANSI-compliant terminal (e.g., xterm,
> etc.):
>
> System.out.println("\x1B[1mBOLD\x1B[0m\t\x1B[31mRED\x1B[0m");
>
> will print BOLD in bold and RED in red. For more information about
> controlling terminal output, see http://en.wikipedia.org/wiki/
> ANSI_escape_code.
|
|
0
|
|
|
|
Reply
|
Roy
|
6/21/2007 4:51:29 PM
|
|
Roy Gourgi wrote:
[reordered top-down]
> "Joshua Cranmer" <Pidgeot18@verizon.net> wrote in message
> news:ccxei.2959$AR5.330@trnddc06...
>>Assuming you are outputting to an ANSI-compliant terminal (e.g., xterm,
>>etc.):
>>
>>System.out.println("\x1B[1mBOLD\x1B[0m\t\x1B[31mRED\x1B[0m");
>>
>>will print BOLD in bold and RED in red. For more information about
>>controlling terminal output, see http://en.wikipedia.org/wiki/
>>ANSI_escape_code.
> Hi Joshua,
>
> I get the error message that x1B is an illegal escape character?
>
> How can I fix that?
>
> Roy
Write \u001B instead \x1B
--
Thomas
|
|
0
|
|
|
|
Reply
|
Thomas
|
6/21/2007 5:02:19 PM
|
|
Hi Thomas,
That did not work either.
Here is what I entered:
System.out.println("\u001B[1mBOLD\u001B[0m\t\u001B[31mRED\u001B[0m");
And here is the output that I got
[1mBOLD[0m [31mRED[0m
Roy
"Thomas Fritsch" <i.dont.like.spam@invalid.com> wrote in message
news:newscache$vnwzjj$8w6$1@news.ops.de...
> Roy Gourgi wrote:
> [reordered top-down]
>> "Joshua Cranmer" <Pidgeot18@verizon.net> wrote in message
>> news:ccxei.2959$AR5.330@trnddc06...
>>>Assuming you are outputting to an ANSI-compliant terminal (e.g., xterm,
>>>etc.):
>>>
>>>System.out.println("\x1B[1mBOLD\x1B[0m\t\x1B[31mRED\x1B[0m");
>>>
>>>will print BOLD in bold and RED in red. For more information about
>>>controlling terminal output, see http://en.wikipedia.org/wiki/
>>>ANSI_escape_code.
>> Hi Joshua,
>>
>> I get the error message that x1B is an illegal escape character?
>>
>> How can I fix that?
>>
>> Roy
> Write \u001B instead \x1B
>
> --
> Thomas
|
|
0
|
|
|
|
Reply
|
Roy
|
6/21/2007 5:14:25 PM
|
|
Roy Gourgi wrote:
> That did not work either.
>
> Here is what I entered:
>
> System.out.println("\u001B[1mBOLD\u001B[0m\t\u001B[31mRED\u001B[0m");
>
> And here is the output that I got
> [1mBOLD[0m [31mRED[0m
Please do not top post.
Does your console use ANSI escape sequences?
--
Lew
|
|
0
|
|
|
|
Reply
|
Lew
|
6/21/2007 5:21:29 PM
|
|
I do not know, I am using JBuilder.
How can I find out?
Roy
"Roy Gourgi" <royng@videotron.ca> wrote in message
news:02xei.88$we4.8410@wagner.videotron.net...
> Hi,
>
> How would I print out the following in bold and in red.
> System.out.printf("Sum of Parts " + "\n");
>
> How would I do it.
>
> TIA
>
> Roy
>
>
|
|
0
|
|
|
|
Reply
|
Roy
|
6/21/2007 5:24:57 PM
|
|
> I do not know, I am using JBuilder.
Ansi control code works only on Win9x.
http://www.rgagnon.com/javadetails/java-0047.html
On more recent Windows relaease (NT, 2000, XP), you need to use a JNI
routine.
http://www.rgagnon.com/javadetails/java-0469.html
Bye.
--
Real Gagnon from Quebec, Canada
* Java, Javascript, VBScript and PowerBuilder code snippets
* http://www.rgagnon.com/howto.html
* http://www.rgagnon.com/bigindex.html
|
|
0
|
|
|
|
Reply
|
Real
|
6/22/2007 2:59:34 AM
|
|
Real Gagnon wrote:
>> I do not know, I am using JBuilder.
>
> Ansi control code works only on Win9x.
Huh. Works fine on my Linux console. Works fine in my Cygwin console in Win
XP also.
> http://www.rgagnon.com/javadetails/java-0047.html
>
> On more recent Windows relaease (NT, 2000, XP), you need to use a JNI
> routine.
>
> http://www.rgagnon.com/javadetails/java-0469.html
Or run the program in an ANSI console. Works fine for me on Win XP.
--
Lew
|
|
0
|
|
|
|
Reply
|
Lew
|
6/22/2007 3:19:14 AM
|
|
Lew <lew@lewscanon.nospam> wrote in
news:__GdnaMWN9QvoubbnZ2dnUVZ_oLinZ2d@comcast.com:
> Real Gagnon wrote:
>>> I do not know, I am using JBuilder.
>>
>> Ansi control code works only on Win9x.
>
> Huh. Works fine on my Linux console. Works fine in my Cygwin console
> in Win XP also.
My comments were for regular CMD.EXE or COMMAND.COM DOS shell.
Bye.
--
Real Gagnon from Quebec, Canada
* Java, Javascript, VBScript and PowerBuilder code snippets
* http://www.rgagnon.com/howto.html
* http://www.rgagnon.com/bigindex.html
|
|
0
|
|
|
|
Reply
|
Real
|
6/22/2007 3:56:35 AM
|
|
On Thu, 21 Jun 2007 11:44:52 -0400, "Roy Gourgi" <royng@videotron.ca>
wrote, quoted or indirectly quoted someone who said :
>How would I print out the following in bold and in red.
>System.out.printf("Sum of Parts " + "\n");
You can't do it with System.out. You write the code that would
display it on screen, then feed it to a printer rendering engine. See
http://mindprod.com/jgloss/printing.html
Another way is to generate HTML, then feed it too a browser to print.
another way is to generate some sort of metafile then feed it to a C++
utility to print.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
|
|
0
|
|
|
|
Reply
|
Roedy
|
6/22/2007 6:05:04 AM
|
|
Real Gagnon wrote:
> Lew <lew@lewscanon.nospam> wrote in
> news:__GdnaMWN9QvoubbnZ2dnUVZ_oLinZ2d@comcast.com:
>
>> Real Gagnon wrote:
>>>> I do not know, I am using JBuilder.
>>> Ansi control code works only on Win9x.
>> Huh. Works fine on my Linux console. Works fine in my Cygwin console
>> in Win XP also.
>
> My comments were for regular CMD.EXE or COMMAND.COM DOS shell.
The person who suggested ANSI control codes in the first place was careful to
exclude those.
Joshua Cranmer said:
> Assuming you are outputting to an ANSI-compliant terminal (e.g., xterm,
> etc.):
So that point was already covered. Plus, I asked,
> Does your console use ANSI escape sequences?
Interestingly there was no answer to that question. I also pointed out
> Bear in mind that by hard-coding ANSI escape sequences you are limiting your program to run on consoles that support those escape sewquences,
It is helpful to the OP to know that the command shells you mentioned do not
fit into the target space for the advice. The issue that the suggestion is
not portable was well covered, however.
--
Lew
|
|
0
|
|
|
|
Reply
|
Lew
|
6/22/2007 11:36:51 AM
|
|
On Fri, 22 Jun 2007 06:05:04 GMT, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :
>>How would I print out the following in bold and in red.
>>System.out.printf("Sum of Parts " + "\n");
>
>You can't do it with System.out. You write the code that would
>display it on screen, then feed it to a printer rendering engine. See
>http://mindprod.com/jgloss/printing.html
>
>Another way is to generate HTML, then feed it too a browser to print.
>
>another way is to generate some sort of metafile then feed it to a C++
>utility to print.
Another way is to generate PostScript and then feed that to a PS
printer or software PS rendering engine.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
|
|
0
|
|
|
|
Reply
|
Roedy
|
6/23/2007 11:04:41 AM
|
|
|
15 Replies
359 Views
(page loaded in 0.009 seconds)
Similiar Articles: printing in bold and colors - comp.lang.java.helpHi, How would I print out the following in bold and in red. System.out.printf("Sum of Parts " + "\n"); How would I do it. TIA Roy ... How to print (write) an arraw in excel from Matlab in colors FollowHi all, I would like to print my results (arrays) to excel from matlab, but ideally I would like to have, for example, the headers in bold and in a different color ... win32console changes Windows cmd.exe colors - comp.lang.ruby ...printing in bold and colors - comp.lang.java.help win32console changes Windows cmd.exe colors - comp.lang.ruby ... printing in bold and colors - comp.lang.java.help... Tw Cen MT Condensed Extra Bold - comp.fontsREQ: Helvetica Neue Condensed Black - comp.fonts printing in bold and colors - comp.lang.java.help... need font cmbx10 urgently - comp.fonts Tw Cen MT Condensed ... ... Fonts in merge fields - comp.databases.filemakerprinting in bold and colors - comp.lang.java.help Fonts in merge fields - comp.databases.filemaker > > I put the same field as a merge field on a print layout ... user ... bold upright Greek and vector - comp.text.texThis approach is desirable if possible, because another journal or your personal style may require \Vec{} to print bold slanted symbols and you want to switch between ... custom legend: different data series with the same colors - comp ...How to print (write) an arraw in excel from Matlab in colors ..... headers in bold and in a different color ... custom legend graphics - comp.soft-sys ... Ttk widgets: changing the background colour? - comp.lang.tcl ...Ttk widgets: changing the background colour? - comp.lang.tcl ... How to print (write) an arraw in excel from Matlab in colors ..... the headers in bold and in a different ... How can we make one particular option's text bold in html. - comp ...I want to make a particular option's text bold within a ... to do this. but these didnt work. only text color or ... window.print() not printing whole page - comp.lang ... IBM mainframe printer typeface - equivalent font? - comp.fonts ...I'll post the set (there's a bold, italic, and bold italic, too) in alt ... or electric bills, and a page printer is too inflexible for the type of color printing a ... Swing Copy Problem - comp.lang.java.gui... Border line = BorderFactory.createLineBorder(Color.black); Font fnt = new Font("Times New Roman", Font.BOLD ... Problems Refreshing with JPanels; Problems printing ... can u suggest me to do better than this? - comp.lang.awk ...... column of each '-' and 'r' pairs of same id and print ... in the space between two parallel lines with a color ... ... bold upright Greek and vector - comp.text.tex (I'm sure ... font smoothing - comp.graphics.api.opengl... hDC, *hRC ); } as you can see i'm specifying 24 color ... at that point featured Normal, Book, Medium, Bold and ... ... with a hammer hitting a ribbon, whereas page printing has ... changing font for particular cell in JTable - comp.lang.java.help ...... the contents of a particular row in the JTable to BOLD ... printing a JLabel text above a JTable - comp.lang.java.gui ... Welcome to JavaWorld.com How can I set the color (or font ... regionprops problem.. - comp.soft-sys.matlabblobECD = zeros(1, numberOfBlobs); % Print header ... num2str(k), 'FontSize', fontSize, 'FontWeight', 'Bold ... did study your color detection and simple color detection ... printing in bold and colors - comp.lang.java.help | Computer GroupHi, How would I print out the following in bold and in red. System.out.printf("Sum of Parts " + "\n"); How would I do it. TIA Roy ... printing in bold and colors - Application Forum at ObjectMix.comprinting in bold and colors - Java . This is a discussion on printing in bold and colors - Java; Hi, How would I print out the following in bold and in red. 7/24/2012 1:11:40 PM
|