• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Colored text output????

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Following are the codes i've used to output my sequence in the main() method. It does give me the sequence that i want, but since i'm not femiliar with Swing stuffs, can anyone help with how to get the sequence(String) in colored text. Your help would be greatly appreciated.

//a part of my code in the main() method.
for(int x=0; x<myseq.length(); x=x+60) {
if((x+60)<=myseq.length()){
System.out.print(myseq.substring(x, x+60)+ "\t");
System.out.println((myseq.substring(x, x+60)).length()+x);
}
else{
System.out.print(myseq.substring(x, myseq.length())+ "\t");
System.out.println(myseq.substring(x, myseq.length()).length()+x);
}
}
Thanks a lot in advance.
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
based on your code snippet, you are displaying your output on the console, not using swing.

if you decide to use swing, you can look into using jcomponents that support rich text (eg JLabel using HTML markup).

if you stick with the console display, you can only output colored characters if your operating system supports colored console chars, and if you know the OS control codes to trigger the color attributes ... not a recommended strategy but there have been those who've done it:-)

hth
reply
    Bookmark Topic Watch Topic
  • New Topic