Displaying String in two colors.....

Hello....
I'm working on chat project. How can i show string in different colors in JTextArea control.
Hope you understand my question.
Thanks in advance

You may use a JTextPane - here is an example:
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JTextPane;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
public class Frame3 extends JFrame {
     public Frame3(){
          super("Frame1");
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          JTextPane field = new JTextPane();
          //field.setContentType("text/html");
          add(field);
          try{
               SimpleAttributeSet style1 = new SimpleAttributeSet();
               StyleConstants.setForeground(style1,Color.BLUE);
               SimpleAttributeSet style2 = new SimpleAttributeSet();
               StyleConstants.setForeground(style2,Color.RED);    
               field.getDocument().insertString(0, "first\n",style1);
               field.getDocument().insertString(0, "second\n",style2);
          catch(Exception exc){
               exc.printStackTrace();
          setSize(200,200);
     public static void main(String args[]){
          new Frame3().setVisible(true);
}

Similar Messages

  • Display string to LCD TV

    Hello.
    I need help again. This time about : How to display string  from LabVIEW  to LCD TV?  I have two LCD TV, and want to show some "string1" cycle from LabVIEW to first LCD TV1 and "string2" cycle display to LCD TV2.
    Any idea?

    GerdW wrote:
    use a graphics cards, that supports 3 outputs simultanuously, and connect all three displays to your computer.
    Simple, eh?
    Yup and if you have a laptop you want to use which doesn't have 3 outputs, look into a low cost USB graphics card.  The cheap ones aren't good for streaming HD video but work well for normal PC use.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • Displaying Alternate row as colored in Cross tab

    Hi,
    I have a report where I need to display alternate rows as colored.
    There is some data in detail section followed by a cross tab in the report header section.
    While I am able to display alternate rows as colored in Detail secction for displaying alternate colored rows in Cross tab data I need some help.
    Data in cross tab is like this
                  history geography
    Tammy   90          60
    Sid         80          50
    Julia       70        40
    In cross tab for displaying alternate colored rows ie for alternate student names  I am using two formulas
    - for displaying row values I am using this one
    whileprintingrecords;
    numbervar d;
    d := iif(d=100,255,100);
    color(255,255,d);
    For displaying alternate colored inner cells ie marks  I am using this formula
    whileprintingrecords;
    numbervar c;
    c := iif(c =255,100,255);
    color(255,255,c)
    I got these formulas after doing Googling
    My cross tab is present in report footer and in the generated report it comes separeated in two pages.
    In the first page data for Tammy and Sid is displayed while Julia is displayed on next page.
    Now the Tammy is coming as yellow colored and as expected Sid is coming as white colored. However Julia which is on next page is coming as white , but logically it should have come as yellow. On the other hand my column data ie marks column is coming fine. Data for tammy and sid is coming as alternately colored and data is Julia on the next page is coming as yellow(as data for Sid is in white)
    I am not able to understand why this is happening and what is the correct way to do alternate row coloring in cross tabs
    Edited by: thunderball10 on Aug 26, 2010 11:57 AM
    Edited by: thunderball10 on Aug 26, 2010 12:00 PM

    Where is your variable c being reset.
    If in page header or group header and you have repaet group header on new page then c will be reset on each page.
    If In groupheader try adding this to reset formula
    if not inrepeatedgroupheader then
    Ian

  • Displaying data in Two line in ALV report

    Hi,
    I want to know how to display the data in alv in two lines for Fild name as well as for fild value
    like in below case
    wa_fieldcata-fieldname  = 'WRBTR'.
       wa_fieldcata-seltext_l  = 'AMOUNT IN DOCUMENT CURRENCY'.
       wa_fieldcata-outputlen  = 18.
       wa_fieldcata-DO_SUM     = 'X'.
       APPEND wa_fieldcata TO it_fieldcat.
       CLEAR wa_fieldcata.
    by this on alv COLUMN headig is coming as 'AMOUNT IN DOCUMENT CURRENCY' in one linw  i want to display  'AMOUNT IN '   in first line and then 'DOCUMENT CURRENCY' below that
    'AMOUNT IN
    DOCUMENT CURRENCY' ***
    similarly how to display value of three fidls in one column
    like for a vendor   I have one column  Vandor name in that column i want to display from table LFA1, 
    NAME1
    NAME2
    NAME3
    NAME4,
    in one column only how to do it.
    regards,
    zafar

    Hi,
    Ref . early reply  can u help me how to uset his in ALV code  and can u give some example for this  how to display it in two lines  as my column heading is of 60 characters 5 word i want to display it in two line in one column only  .
    How to use : SLIS_EV_AFTER_LINE_OUTPUT
    to get this.
    or is there any other method.
    regards,
      zafar

  • Display Display value in Red Color in Pop Up List of value Item

    Dear All,
    i have created an Pop up List of Value item.I need to display Display value in Red Color in Pop Up List of value Item.
    What should i pass in HTML Form Element Attributes .I have try using
    style="font-color:red";That code.
    How can i display Display Value in Red Color.
    Thanks

    Is this what you are looking for?
    http://apex.oracle.com/pls/apex/f?p=42778:12
    If so..
    * Go to Shared Components -> Templates -> Select Type as "Popup List of Values"
    * Edit Popup LOV template
    * See the class name being used for div under Result Set section. In My case, its t1PopupBody
    * Under Page Attributes -> Page HTML Head section append following CSS
    <style>.t1PopupBody a{color:red;}</style>* Apply Changes
    If its not working, then inspect the pop-up lov with firebug and update CSS definition accordingly.
    Regards,
    Hari

  • Photoshop CC 2014 No Longer Displaying Blue In The Color Picker Or Workspace, Only Purples.

    Photoshop CC 2014 is no longer displaying blue in the color picker and on screen, only purple, violet, magenta, etc. I think it started about 3 days ago. Our current model 2.9 GHz iMac with NVIDIA GeForce GT 750M 1024 MB Graphics Card and 8 GB RAM is calibrated to 100% via Spyder 4 Express, and reflects that in every application except Photoshop CC 2014, so I know it isn't the monitor. Blue is the primary color we use in many of our designs, so this is of upmost importance. I really appreciate any help you could provide, If this isn't fixed ASAP, I don't know what we'll do.
    Thank you so much!

    Ok, so old files are purple, but new files are blue.
    I took a screenshot of my Photoshop work are using Cmd-Shift-3 and it places the screen shot as a png file on my desktop, which I upload with my reply via the Camera icon in the forum reply toolbar.
    I loaded a new RGB/8 file, set the bottom status bar to indicate the color profile (sRGB) and made sure the file tab on the top is visible, so I can see it is RGB/8. Then I used Cmd-shift-k to show my Color Settings before taking the screenshot. The point is to try and see where the problem is coming from, so make a screenshot just like mine with your old purple file.

  • Satellite A300-202 - External display turned a strange color

    Hi,
    I have a Satellite A300-202 with a ATI Mobility Radeon HD 3650, and after upgrade from vista to windows 7, my external display turned a strange color, seemed to lose the red color. Never show the white color, in which should show the white color shows the color blue.
    I have uninstalled and installed again the graphic card drivers and update the new drivers but dont solved this trouble. My external monitor it's ok because I have tried with other laptop and don't have this trouble. I have also tried my laptop with other monitor and have the same trouble.
    Anybody ever had this problem, someone who can help me?
    Thanks,

    Hi Xardas,
    Yes I have problems only with the external monitor.
    I tried both. Now I have the new beta version to the windows 7 64bits, downloaded from the amd/ati site, but I have tried also with the version available in the toshiba drivers page to my A300-202, and had the same problem.
    Yes I have installed the new version of the BIOS too.
    Thanks,
    Message was edited by: Zagga

  • New iMac display problem(?) - weird colors and grain

    Hello,
    I'm a fresh mac user, made the switch this monday (August 27th) when my 24" iMac 2.4GHz C2D arrived. After using it for a while, I noticed a handful of dead pixels, and a semi-bright green stuck one. I thought I'd wait and see how disturbing I would find them before raising an issue about them.
    Well, yesterday I decided to make my first backup of the whole system to my external 500GB Lacie drive (connected with FW800) using Super Duper!, which to my understanding is a reasonably sturdy and reliable backup application.
    During the first backup iteration I started to notice some alterations in color in the top middle part of the display. I then returned to whatever I was doing (not on the mac, I had no other applications running, just Super Duper!), and after a while took another look at the display. The weird colored area had expanded, and the whole display had become somewhat grainy. Also, the backup process had slowed down quite a bit (from ~30MB/s to ~7-8MB/s).
    So I cancelled the backup operation and logged out and back in again. No change. Then I restarted the whole system, which booted just fine, with none of the aforementioned problems. Even the second backup iteration went without problems.
    Still, it's a new (and with my budget, quite expensive) computer, and if I get this kind of problem during the first week, I cannot continue using it happily in the fear of these problems reoccurring time and again.
    I took a couple of pictures of this, one during and one after the problem. The quality of these are quite lousy, they're taken with my Nokia 9500 Communicator.
    During the problem:
    http://iki.fi/aita/imac/01notok.jpg
    After rebooting:
    http://iki.fi/aita/imac/02_ok.jpg
    The images are taken in the same light conditions, but from slightly different viewing points. Note: The first image does not present reflections, it's how the screen looked (actually, in real life it looked somewhat worse)
    What do you think?
    Could this be a driver related issue or have I received bad hardware?
    My drivers and Apple software should be up to date (at least OS X informs me that everything is, and I haven't found newer graphics drivers anywhere).
    If anyone has had the same or related problems or know how I should proceed with this matter, I would be grateful.
    Thank you in advance!
    -Aidan from Finland

    A few people, myself included, have experienced the same thing. Check these threads: http://discussions.apple.com/thread.jspa?threadID=1082181&tstart=15
    http://discussions.apple.com/thread.jspa?threadID=1100912&tstart=30
    http://discussions.apple.com/thread.jspa?threadID=1090395&tstart=60
    So far the only fix suggested has been to call apple and get a replacement. I'm still.....still waiting for mine to make it slowly across the ocean from China, so I don't know how the new one is working. I'd call Apple and request a new one.

  • How can I preserve display string (convert DOB to Age) upon excel export?

    I am using the following code to convert DOB to age within Display String (Format Field/Common tab):
    if
    //months
    (datediff('yyyy',{CDCLIENT.DOB},currentdate)-(if datepart('y',currentdate)>datepart('y',{CDCLIENT.DOB}) then 0 else 1))<2 then
    totext(datediff('mm',{CDCLIENT.DOB},currentdate),0,'') & ' months'
    else
    //years
    totext((datediff('yyyy',{CDCLIENT.DOB},currentdate)-(if datepart('y',currentdate)>datepart('y',{CDCLIENT.DOB}) then 0 else 1)),0,'') //& ' years'
    When I export to excel/csv/ttx.. it doesn't export the display string (Age), but reverts back to the DOB. How do I preserve this upon export?

    Hi Dominic,
    The 'display string' formatted values are not exported to Excel Data Only.
    Create a 'formula field' as a workaround.
    -Abhilash

  • Firefox is not displaying the correct font color on my blog, but other browsers are.

    I have a web designer issue. Firefox is not displaying the correct font color on the header in my blog. Explorer, Chrome, and Safari have no problems. The page is in css but this particular section has html code o designate color. The code is as follows:
    <font face="helvetica" color="FF9966" size="1">blog</font>
    Though all other browsers display the light orange color designated, Firefox displays white. Strangely, if if retype the code by spelling out a color, Firefox displays it correctly. i.e.
    <font face="helvetica" color="black" size="1">blog</font>
    ... will give me black. You can see the effect by viewing the link below and looking at the word "blog" in the header, which should be light orange but is not in Firefox.

    Actually it also seems to work in the current Firefox 4 beta as it is.
    The code is not right though - the correct syntax for the color attribute with hex values is with a # at the start, so:
    color="#FF9966"
    It might work in Firefox 3.x if you change that.

  • Cover flow displays the same two pieces of artwork for all videos.

    I've been adding a collection of tv series I have on DVD to iTunes 9.1.1, it all worked fine initially, I opened each video up of a series of tv programs and used the "Set Poster Frame" option to capture a frame of the program to use as the artwork for that program.
    I normally have the programs sorted by what tv program they belong to, so Cover flow only displays the first episode of a series' artwork. I'm not sure why though but something I did yesterday appears to have caused cover flow to blow a fuse.
    If I chose to sort by name before, cover flow would display all the artwork for each episode, and it showed all the different artworks correctly. Now though after some fiddling I did which I cannot seem to recount my steps back to, it only displays the same two pieces of artwork from two particular episodes for all the videos when it is sorted via name:
    http://img257.imageshack.us/img257/3052/tvprogcoverflow.png
    I've tried removing all the artwork, but there doesn't seem to be an option to delete the poster frame and the poster frame artwork doesn't show up under the artwork tab for the individual videos so I can't delete anything from there. If I select all the videos and then right click and get info, then select the artwork check box and click OK it seemingly deletes all the artwork... Then replaces it again with the exact same artwork!
    Although cover flow shows each video has having the same artwork if I Get Info each video it clearly shows it having the correct artwork so why cover flow is messing around like this I don't know.
    I've tried deleting the album artwork cache in the itunes folder, didn't work. I even tried deleting my entire itunes folder which I have separate from my library and the hidden prefs file in my actual library, but that didn't work either.
    Interestingly enough, if I re-add all the videos they automatically get listed as films and go under the film tab. When looking at them under their cover flow correctly shows every episode with the right artwork:
    http://img200.imageshack.us/img200/8234/filmcoverflow.png
    As soon as I change the Get Info options tab from Film to TV program either for one video or all of them, then cover flow screws up again.
    Any idea how to fix this annoyance?

    The weird thing is, it worked before. I encoded all the videos previously and had them all listed and didn't encounter this problem, but I noticed I'd forgotten to decomb/detelecine the videos so I deleted everything and re-encoded it all. AFter filling the tags out and setting poster frames again I was thinking of making life easier by just pasting the same artwork for every episode, so I did, but didn't like the results so I deleted it again (I selected every video, used Get Info and pasted the artwork that way).
    I think it was after this that the problem started to occur. In any case I've been through every episode and made sure the name, series, episode and episode id fields are all filled in with incremental values and they are. I even made sure the Sort Name field was filled in on every video. But this didn't work either.
    So, thinking another restart was needed I deleted every video again. Re-encoded them all, again. Set the tags for every video and poster frame again. Finished it all off nicely, checked cover flow and was highly annoyed to find it was STILL showing the same two pieces of art work for every video as shown in that image I posted.
    Ultimately, I wouldn't care so much that cover flow is screwing up like this as I always intended to sort by program anyway so it would only ever display one piece of artwork for an entire series of videos, however where-as when it was working it picked the artwork for the first episode of a series to display, its instead picking one of the latter episodes. I can't seem to find any way of choosing what artwork I want displayed.

  • How to display string with XML content in 4.6?

    Hi,
    I`d like to know how to display string with XML content in it for 4.6.
    4.6 has not method parse_string.
    And example like this is not helpful:
      DATA: lo_mxml    TYPE REF TO cl_xml_document.
      CREATE OBJECT lo_mxml.
      CALL METHOD lo_mxml->parse_string
        EXPORTING
          stream = gv_xml_string.
      CALL METHOD lo_mxml->display.
    Thank you.

    Hi,
    May be you can use fm SAP_CONVERT_TO_XML_FORMAT. But it have some issues with memory usage, the program consumed tons of memory during convert.

  • How to display string message real time in a string area?

    I want to display string message on String indicator in screen real time, message is updating realtime when test application runing, i want to see the newest message display on screen real time instead of by drag down the vertical scroll bar manually.
    please give me an idea how to set the attribute of string indicator?thanks

    You can use Text.ScrollPosition property node for autoscrolling.
    Andrey.

  • Two Color Pdf Output Problem - Continued

    From yesterday's post, it was determined that my pdfs were in fact two color, but it turns out the printer is taking the individual pdf pages and marrying them up in printer pagination format using Illustrator. Could this be way the black is converting to RGB? What software should he be using?
    Thank you,
    Tony

    Unproper Color Calibration settings can lead to this problem.
    tomaxxi
    http://indisnip.wordpress.com/

  • Two Color Pdf Output Problem

    I'm new with InDesign coming from a Quark background. I created a 28 page booklet with CMYK cover and two color interior (black & PMS spot color)
    I'm working in CS4 and my print vendor is CS3. I have provided him with both the InDesign file saved down to .inx as well as high quality pdf with no color conversion so that the spot color will print as is.
    My print vendor is telling me that the black screens/gradients are separating as RBG. I'm trying to figure out if the problem is my inexperience or his. I don't know what more to do with the file? Please advise.
    Thank you,
    Tony

    Okay, I'm back to this issue. Apparently the printer is taking the individual pdf pages and marrying them up to printer pagination using Illustrator. Could this be why the Black is converting to RGB? What software should he be using to maintain the two colors?
    Thank you,
    Tony

Maybe you are looking for

  • 5.1 for games from X-Fi Music through home recei

    using the digital coax doesn't give me true 5. for games (not dvds) when i go through my receiver to speakers. do i have to somehow connect 6 analog cables to my receiver? if so, what device do i need to buy so i can run those cables from the soundca

  • How to set a default output device for FAX outputs

    Hi Experts, Business requires to set a default output device for fax outputs ( Medium as 2 Fax medium ). as fas as print output ( medium as 1 print medium ) is considered we can maintain output device in condition record--> communication I tried main

  • Web App Built in RAD/WebSphere try to Delpoy in BEA

    I have a web application that was written and deployed in RAD and WebSphere. I need to know have it work on BEA. I have gotten to the point where I can deploy the application to the BEA Server (I get an error) and can pull the application update and

  • Filters without Groups / Smart Objects

    I want to add a layer of scratches and dust marks that is at the top of the composition without having to create a group or smart object.  I tried creating a black layer with the opacity to 0 then applying a scratches and dusts mark, I also tried a e

  • How to use JEditorPanel to display an HTML page from a String?

    Hi, I need to store a report in HTML format which is store in String and when I use JEditorPane.setText to insert the string and JeditorPane refused to display and content or just the String "<HTML> <HEAD>..." in plain text. SHould I use other method