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

### printing in bold and colors

• Email
• Follow

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 (30) 6/21/2007 3:44:52 PM

See related articles to this posting

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");

controlling terminal output, see http://en.wikipedia.org/wiki/
ANSI_escape_code.

 0

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");
>
> controlling terminal output, see http://en.wikipedia.org/wiki/
> ANSI_escape_code.


 0

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

> I do not know, I am using JBuilder.

Ansi control code works only on Win9x.

On more recent Windows relaease (NT, 2000, XP), you need to use a JNI
routine.

Bye.
--
* Java, Javascript, VBScript and PowerBuilder code snippets
* http://www.rgagnon.com/howto.html
* http://www.rgagnon.com/bigindex.html

 0

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.

>
> On more recent Windows relaease (NT, 2000, XP), you need to use a JNI
> routine.
>

Or run the program in an ANSI console.  Works fine for me on Win XP.

--
Lew

 0

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.
--
* Java, Javascript, VBScript and PowerBuilder code snippets
* http://www.rgagnon.com/howto.html
* http://www.rgagnon.com/bigindex.html

 0

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.

--
The Java Glossary
http://mindprod.com

 0

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.):

> 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

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.
--
The Java Glossary
http://mindprod.com

 0

15 Replies
543 Views

Similar Articles

12/10/2013 9:48:29 PM
page loaded in 41665 ms. (0)

Similar Artilces:

HP Deskjet 935C and no color printing?
I have refilled the color cartridges with Nu-kote refill kit and the 3 colors. When I run a HP test page, it only prints black, never the color. I bought another refill kit by NU-Kote and refilled another cartridge, still only black. I have in the past refilled color cartridges and never had problems. What could it be this time??? I am using AMD 1100, 512 Mb ram, Windows XP and have the latest driver from the windows site. You posted this NON XP question to all those NGs. WHY? Go to the site of the ink seller and ask them, or HP. --=20 Just my =A2 worth Jeff __________in...

Newbie confused about color space, outside printing and size of file
I'm trying to work out the "right" way to handle color profiles in Photoshop and prepare for outside printing, Win XP Pro and Photoshop 7 I'm using a Sony CRT - I have icm files for this monitor. Should I use the Sony icm for my color setting? And if so, can I just choose it in PS or do I have to load it beforehand? What working space should I use? I'm using tiff files I created by scanning 35mm negatives 24 bit and high resolution. I open the file in PS What color profile do I use while I'm working on the file? Do I "assign" this color profile o...

Can't print to HP LaserJet printer via Windows Printing
I can print to one of the HP LaserJet 2100tn printers via AppleTalk. But when I try to add the printer (via the Printer Setup Utility), I can't see it. 1. I click the Add button 2. I select Windows Printing from the drop-down list 3. I select a workgroup from the lower drop-down list No printers show up in the list. There are 2 HP LJ printers on the net, but none of them show up under Windows Printing. Am I doing something wrong? Also, I tried adding a printer via IP Printing. But when I try to print, I get no indication that the printer has received the job; no output. Maybe...

cost of printing
Does anyone have any information on the true cost of printing with the Epson 2200? The cartriges seem to run dry very quickly. Olie "U. Link" <iul@delete_telus.net> wrote in message news:kWfod.176663$df2.31698@edtnps89... > Does anyone have any information on the true cost of printing with the > Epson 2200? The cost per sheet of paper is easily calculable. Ink cost varies by the amount used per print. The cartridges run about$10 each. > The cartriges seem to run dry very quickly. They sure do! Dane That is how Epson and other companies make their m...

network and printing
hi, I have 2 computers networked together, the main one is an HP pavilion desktop, and the one connected to it is an Acer laptop. All seems to be working fine, I can see both computers in network places etc. apart from, I am having problems sharing the printer. I have an hp psc 2110 all-in-one, I have allowed printer sharing on the desktop and added the printer on the laptop. The first document printed fine, but I have not been able to print since. When I click the print icon on the laptop nothing happpens, I can see the printer but can't seem to activate it anymore. Any thoughts?? ...

Printing from OpenGL
Hi, I'm creating my first OpenGL app under Windows and am trying to get it to render to a printer DC. The screen output is fine, but when I switch to a printer DC I get no output of any kind rendered. I have tried various PixelFormat settings, creating a new render context, various double buffer settings, and anything else I can think of, but not a single dot appears. The reference books I have don't mention printing at all. Does anyone have any suggestions or a trivial Windows OpenGL app that prints? Thanks, Chris > The reference books I have don't mention printing...

Print all but the filename
I need to do a long listing, then eliminate the filenames so I can work with just the directory listings. How can I use awk to filter out the filename since it's not going to be a common length each time? Many thanks in advance. On Wed, 28 Jun 2006 20:18:02 GMT, "Jeff Kloek" <newham@kloek.com> wrote: >I need to do a long listing, then eliminate the filenames so I can work with >just >the directory listings. How can I use awk to filter out the filename since >it's not going to be a common length each time? Many thanks in advance. > It's some...

Printing from iCal
Is there any way to get iCal to print calendar weeks in portrait mode rather than landscape? I would like to print out a weekly diary with the days running downwards rather than across the page, and can't see if it is possible. -- Sally in Shropshire, UK bed and breakfast near Ludlow: http://www.stonybrook-ludlow.co.uk Burne-Jones/William Morris window in Shropshire church: http://www.whitton-stmarys.org.uk Sally Thompson <sallynewsgroup@yahoo.co.uk> wrote: > Is there any way to get iCal to print calendar weeks in portrait mode rather > than landscape? I would lik...

Print queue configuration
Hi, I need to restore print queue config from one AIX machine (4.3.3) to another AIX machine (4.3.3). I haven't got access to the machine with the config already (i'm hopefully going to extract the required files using a mksysb) To do this I need to know the config files that store this config. I have found /etc/qconfig but this doesn't store the printer characteristics (like paper size, lines, columns, etc). Where can I find the config file that hold this information? Thanks, Garry On 22 Mrz., 17:09, "Garry Harthill" <gazz...@gmail.com> wrote: > Hi, > I ...

Minor Printing Issue
Hi all, I and running HP's jetadmin on a Solaris 9 box and am having a couple of issues that are annoying the users. First one has to do with the banner page. The old printer server (also running an earlier version of jetadmin) used to print the user's userid in big, bold letters at the top of the banner page. Now it does not. I cannot seem to find where this would get set. Any ideas? The second issue has to do with the users receiving an email whenever they print to a certain printer. It is a non-standard printer and I had to use a generic laserjet driver. It prints just fine...

printing postscrip with emacs
Hi all, emacs has an option in the File menu to postscrip print buffer. If there are more than one printers attached in the network, how do we make it print postscript to a printer other than the default one? Thanks, SuSe 9.1 rsina <rsina.no-ssppaamm@earthlink.net> writes: > emacs has an option in the File menu to postscrip print buffer. If there are > more than one printers attached in the network, how do we make it print > postscript to a printer other than the default one? I usually do C-u M-x ps-print-buffer-with-faces, that saves the text as postscript to file which I ...

Hey folks, I recently discover sinedots and can't leave them alone. I have provided a link to a page that show the colorizing of the sinedots? How is this done. How do you make multi-color sinedots like those in the pics? http://www.rosiehardman.com/sinedot2codes.htm Thanks Oh, damn, please excuse attachment-- thought I was in Jasc forum "E-Lou" <louis.beach@nospam.worldnet.att.net> wrote in message news:_KUkc.16607\$Xj6.277218@bgtnsc04-news.ops.worldnet.att.net... > Hey folks, > > I recently discover sinedots and can't leave them alone. > > I have...

Printing PDF bigger
I have a poster from a medical meeting that, when I try to print it, is done so in a type size that makes it about impossible for my old eyes to read even with a magnifying glass. Anything available for free or included with the computer (and 10.4) that can get it to print at a decent size?? In article <kurtullman-5040E2.14173714082008@70-3-168-216.area5.spcsdns.net>, Kurt Ullman <kurtullman@yahoo.com> wrote: > I have a poster from a medical meeting that, when I try to print it, > is done so in a type size that makes it about impossible for my old eyes > to...

printing with gimp 1784
Hi, I have to print a file which sizes are greater than a A4 paper: can I print it in a A4 paper without modify its sizes? If yes, how? I haven't found how in print options. Thank you! Matteo On Sat, 28 Aug 2004 08:42:34 +0000, TEO wrote: > Hi, > I have to print a file which sizes are greater than a A4 paper: can I print > it in a A4 paper without modify its sizes? If yes, how? I haven't found how > in print options. > Thank you! > Matteo It depends on your print manager. I have a canon bjc 3000 and can 'fit to size' just a tick in a box. -- neil delet...

Printing problems 2240
I am not sure what the problem is exactly But I am not able to print. I do not get any error messages it just won't print it says it is printing but no paper comes out of the printer. I have a PowerMac G4 using OS 9.2.2 and trying to print on a HP P1000 I downloaded the drivers. Am I suppose to do something else? every time I print it says something about spooling page x to disk but nothing happens after that. I am a fairly new Mac user it is probably something stupid that I have not checked Help!! Thanks in advance On Wed, 30 Mar 2005 08:02:58 -0500, Warren Oates wrote (in article ...

Printing from Parallels Desktop
I've installed Parallels Desktop but for reasons unbeknownst (t least to me) I have been unable to print. Any suggestions as to what I am doing wrong will be greatly appreciated. -- James Leo Ryan ..... Austin, Texas ..... taliesinsoft@mac.com Soni tempori elseu romani yeof helsforo nisson ol sefini ill des Tue, 20 Jun 2006 00:24:26 -0500, sefini jorgo geanyet des mani yeof do comp.sys.mac.misc, yawatina tan reek esk TaliesinSoft <taliesinsoft@mac.com> fornis do marikano es bono tan el: >I've installed Parallels Desktop but for reasons unbeknownst (t least to me) >I...

Is Report Successfully Printed ?
While making Vouchers in a form, I have a POST button which validates & posts the transaction to the main Accounts File. I also have a PRINT button which provides the user with a preview of the "to be printed" Voucher & then prints it onto paper. When the user clicks PRINT ... my code validates the voucher & prints it. Now I have to POST the transaction ... but how do I know if the voucher has printed correctly ? i.e. no paper jam or some such other problem. Rgds, Prakash On Fri, 29 Feb 2008 10:53:48 -0800 (PST), prakashwadhwani@gmail.com wrote: > While making Vo...

printing Christmas envelopes
I made the leap from Windows & Outlook to a MacBook Pro over the summer. It's time for Christmas cards again, I've entered addresses in the Address book for everybody - well sort of. For a family, I use "John & Debbie" instead of creating two cards. So how do I print the envelopes? I would think this would be a common operation, no doubt the answer is staring me in the face but I'm missing it. I thought I could use Applescript, but I couldn't make heads or tails out of the pair of books I got. I no longer remember enough details to make a reasonable ...

Printing From Pages
It seems that if you select "Print" when using Pages that the options to print only a single page and/or to print multiple copies are not available unless you select "Preview" from the Print dialog and then from Preview select the desired options. Why you just can't do this directly in the Print dialog has me somewhat boggled. -- James Leo Ryan --- Austin, Texas --- taliesinsoft@me.com In article <0001HW.C75139E10002373CB02A89BF@News.Individual.NET>, TaliesinSoft <taliesinsoft@me.com> wrote: > It seems that if you select "Print&...

wx Just Print!
I'm using Python 2.6.5. I would like to be able to print an RTF file, with no prompts for printers or anything like that. Here's the code so far: import wx.richtext rtp = wx.richtext.RichTextPrinting() rtp.PrintFile('C:\\path\\to\\file.rtf') When I run it, it says: ... assert "(wxThePrintPaperDatabase*) NULL) failed ... What is the fix? I think you need to create a wxApp first. Try adding app = wx.PySimpleApp() at the beginning. ...