How to set two colored text in one textarea

hello friends,
i am busy preparing chat frame which shows messages in textarea, it shows two things, one the name of chatter , the other is the message, i want the two things of different color, you can change the text color of textarea by setForeground(), but what if i want different colored text in same textarea, can anybody help me???

I don't know if this will help u...try make sense of it :
DefaultStyledDocument doc = new DefaultStyledDocument();
JTextPane tp = new JTextPane(doc);
tp.setFont (new java.awt.Font ("Arial", 1, 12));
JScrollPane lscroller = new JScrollPane(tp);
lscroller.setForeground (new java.awt.Color (102, 102, 153));
lscroller.setPreferredSize (new java.awt.Dimension(496, 273));
lscroller.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
jPanel2.add ( lscroller );
prepareAllStyles();
void prepareAllStyles()
aset = new SimpleAttributeSet();
//set bold and red
StyleConstants.setForeground(aset,Color.black);
StyleConstants.setBold(aset,true);
ht.put(BOLDRED,aset);
aset = new SimpleAttributeSet();
//set italic and green
StyleConstants.setForeground(aset,Color.red);
StyleConstants.setBold(aset,true);
ht.put(ITALICGREEN,aset);
AttributeSet current = (AttributeSet)ht.get(BOLDRED);
doc.insertString(doc.getLength(),displaymessage + "\n",current);
tp.setCaretPosition( doc.getLength() );

Similar Messages

  • How to set two different UIE in one cell in ALV table

    Hi all,
    I have a hierachy ALV table. For some reason I want to have two UI elements in one column. For example, the text and a menu next to the text. Is it possiable to do that?
    best regards,
    Wenwen

    Hi,
    thank you for your answer. Yes, now I also find the class CL_SALV_WD_MULTI_CELL_EDITOR which could be used to set different UIE in one cell. But it is quite limited, just the following UIE could be used
    - LinkToAction 
    - LinkToURL    
    - FileDownload 
    - Button       
    - ToggleButton 
    best regards,
    Wenwen

  • How to set two parameter value using one f4 help of 'F4IF_INT_TABLE_VALUE_REQUEST'

    I have two parameters on selection screen .
    P_QTR and P_YEAR
    I have concatenated the Quarter and Year Value to give same f4 on both paramatersto give f4 using 'F4IF_INT_TABLE_VALUE_REQUEST'
    for example Q1 2014
    now when user selects one value i want to set Q1 to P_QTR and 2014 to P_YEAR.
    but it is setting only one value for P_QTR correctly and the value for P_year is not coming on screen although the value is thier inside code in P_year
    i am using same f4 for both events
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_qtr.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_year.
    here is the code i am using
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
          EXPORTING
            retfield        = 'CHAR20'
            window_title    = text-026
            value_org       = 'S'
          TABLES
            value_tab       = mt_input_f4
            return_tab      = mt_return
          EXCEPTIONS
            parameter_error = 1
            no_values_found = 2
            OTHERS          = 3.
        IF sy-subrc <> 0.
          CLEAR mt_input_f4[].
        ENDIF.
        READ TABLE mt_return INTO ms_return INDEX 1.
        IF sy-subrc EQ 0.
          p_qtr = ms_return-fieldval+0(2).
          p_year = ms_return-fieldval+3(4) .
        ENDIF.
    plz chk  attached pics

    i am sorry for delayed update but i fixed it using following approach.
        READ TABLE mt_return INTO ms_return INDEX 1.
        IF sy-subrc EQ 0.
          ls_dynpread-fieldname = 'P_QTR'.
          ls_dynpread-fieldvalue = ms_return-fieldval+0(2).
          APPEND ls_dynpread TO lt_dynpread.
          ls_dynpread-fieldname = 'P_YEAR'.
          ls_dynpread-fieldvalue = ms_return-fieldval+3(4).
          APPEND ls_dynpread TO lt_dynpread.
    **setting the selection screen values
          CALL FUNCTION 'DYNP_VALUES_UPDATE'
            EXPORTING
              dyname               = sy-repid
              dynumb               = '1000'
            TABLES
              dynpfields           = lt_dynpread
            EXCEPTIONS
              invalid_abapworkarea = 1
              invalid_dynprofield  = 2
              invalid_dynproname   = 3
              invalid_dynpronummer = 4
              invalid_request      = 5
              no_fielddescription  = 6
              undefind_error       = 7
              OTHERS               = 8.
          IF sy-subrc <> 0.
            CLEAR lt_dynpread[].
          ENDIF.

  • How to set two DNS domain in one Remote VPN group policy

    Hello experts
    I am using ASA 8.2 to provide IPsec remote VPN for our staff.  And in the group policy I set default domain name which is needed for our DNS server to resolve internal URLs.  But the problem is now we have two domain names on our DNS server, and host names in two domains are differents. So if I setup one domain name in the group policy, URLs in the other domain cannot be resolved when using VPN.  But ADSM seems doesn't allow me to setup two domain names for the attribute 'Default Domain'.  What can I do?
    Thanks a lot.

    Come on Experts, please help.  Any way to achieve that, or it's a mission impossible.

  • How to set different color text in JTabe cell

    Hi
    I have been searching many forums to find how can this be done, but no success.
    I have Custom JTable with MyTableRenderer which is nothing else but alternate the color of rows(cells), CustomTableModel extends DefaultTableModel adding functionality for updateCellContent with different messages.
    I have a column in which cells i want to set these messages in different color.They are not set by user's editing, and by updating the content using the table model.
    Here is the code for that
    public void updateCellContent(HashMap<String, String> messages, int col) {
            for (int row = 0; row < this.dataVector.size() - 1; row++) {
                //This value is hardcoded for now.
                boolean isError = true;
                String filename = getFilename(row);
                String message = messages.get(filename);
                if (message != null) {
                    if (isError) {
                        setErrorMessage(message, row);
                    } else {
                        setMessage(message, row);
        private void setErrorMessage(String message, int row) {
            this.setFileStatus(message, row);
        private void setMessage(String message, int row) {
            String value = (String) this.getValueAt(row, COL_FILE_STATUS);
            ((Vector) this.dataVector.get(row)).setElementAt(value + " " + message, COL_FILE_STATUS);
            fireTableCellUpdated(row, COL_FILE_STATUS);
    public void setFileStatus(String message, int row) {
            setValueAt(message, row, COL_FILE_STATUS);
        }Thanks
    Dimitar

    I have Custom JTable with MyTableRenderer which is nothing else but alternate the color of rows(cells)If I understand you correctly a better way to do this is to override the prepareRenderer(...) method of JTable. You can search the forum for my "Table Prepare Renderer" (without the spaces) example which shows how this can be done.
    I have a column in which cells i want to set these messages in different color.Then you need to use a custom renderer for that column.
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.

  • How to set two radius servers one is window NPS another is cisco radius server

    how to set two radius servers one is window NPS another is cisco radius server
    when i try the following command, once window priority is first , i type cisco radius user name, it authenticated fail
    i can not use both at the same time
    radius-server host 192.168.1.3  is window NPS
    radius-server host 192.168.1.1 is cisco radius
    http://blog.skufel.net/2012/06/how-to-integrating-cisco-devices-access-with-microsoft-npsradius/
    conf t
    no aaa authentication login default line
    no aaa authentication login local group radius
    no aaa authorization exec default group radius if-authenticated
    no aaa authorization network default group radius
    no aaa accounting connection default start-stop group radius
    aaa new-model
    aaa group server radius IAS
     server 192.168.1.1 auth-port 1812 acct-port 1813
     server 192.168.1.3 auth-port 1812 acct-port 1813
    aaa authentication login userAuthentication local group IAS
    aaa authorization exec userAuthorization local group IAS if-authenticated
    aaa authorization network userAuthorization local group IAS
    aaa accounting exec default start-stop group IAS
    aaa accounting system default start-stop group IAS
    aaa session-id common
    radius-server host 192.168.1.1 auth-port 1812 acct-port 1813
    radius-server host 192.168.1.2 auth-port 1812 acct-port 1813
    radius-server host 192.168.1.3 auth-port 1645 acct-port 1646
    radius-server host 192.168.1.3 auth-port 1812 acct-port 1813
    privilege exec level 1 show config
    ip radius source-interface Gi0/1
    line vty 0 4
     authorization exec userAuthorization
     login authentication userAuthentication
     transport input telnet
    line vty 5 15
     authorization exec userAuthorization
     login authentication userAuthentication
     transport input telnet
    end
    conf t
    aaa group server radius IAS
     server 192.168.1.3 auth-port 1812 acct-port 1813
     server 192.168.1.1 auth-port 1812 acct-port 1813
    end

    The first AAA server listed in your config will always be used unless/until it becomes unavailable. At that point the NAD would move down to the next AAA server defined on the list and use that one until it becomes unavailable and then move to third one, and so on. 
    If you want to use two AAA servers at the same time then you will need to put a load balancer in front of them. Then the virtual IP (vip) will be listed in the NADs vs the individual AAA servers' IPs. 
    I hope this helps!
    Thank you for rating helpful posts!

  • How to set background color for selected days in DateChooser

    How to set background color for selected days. I created
    checkbox for each day [Son,Mon,Tue,Wed,Thu,Fri,Sat] and a
    DateChooser, I want to change the background color for the selected
    day when i click on a button after selecting the desired checkboxs
    [ monthly wise/yearly wise]
    Thanks in advance

    There is no button involved in the following code, but it may
    be of use to you:
    <?xml version="1.0"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    creationComplete="init()">
    <mx:Script>
    <![CDATA[
    private var origColor:uint;
    private function init():void {
    origColor = dc.getStyle("selectionColor");
    public function setBackGrdColors(newColor:uint):void {
    dc.setStyle("selectionColor", origColor);
    if(dc.selectedDate){
    var dayOfWeek:Number = dc.selectedDate.day;
    else{
    return;
    switch(dayOfWeek) {
    case 0:
    if(sun.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    case 1:
    if(mon.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    case 2:
    if(tue.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    case 3:
    if(wed.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    case 4:
    if(thu.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    case 5:
    if(fri.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    case 6:
    if(sat.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    default:
    break;
    ]]>
    </mx:Script>
    <mx:VBox horizontalAlign="center" verticalGap="20">
    <mx:DateChooser id="dc" textAlign="left"
    change="setBackGrdColors(cellColor.selectedColor)"/>
    <mx:HBox width="100%" horizontalAlign="center">
    <mx:CheckBox id="sun" label="Sun"/>
    <mx:CheckBox id="mon" label="Mon"/>
    <mx:CheckBox id="tue" label="Tue"/>
    <mx:CheckBox id="wed" label="Wed"/>
    </mx:HBox>
    <mx:HBox width="100%" horizontalAlign="center">
    <mx:CheckBox id="thu" label="Thu"/>
    <mx:CheckBox id="fri" label="Fri"/>
    <mx:CheckBox id="sat" label="Sat"/>
    </mx:HBox>
    <mx:HBox width="300" horizontalAlign="center">
    <mx:Label text="Background Color" />
    <mx:ColorPicker id="cellColor"
    selectedColor="#FF00FF"/>
    </mx:HBox>
    </mx:VBox>
    </mx:Application>

  • How can i see the text of one view?

    I want to see the text of one view stored in my Oracle DB, then i run the next query:
    SELECT TEXT FROM ALL_VIEWS WHERE VIEW_NAME = view_name;
    The problem is that the information return me truncated.
    How can i see the text of one view?
    Sorry, my English is terrible.
    I'm from Argentina.

    Use 'set long 100000000' at sql prompt. Run your query again.

  • How to set two attributes as  a primary key in database ?

    how to set two attributes as a primary key?
    Take COffeesbreak as an example ,
    let's suppose that there are cof_name ,sup_id,price and so on;
    the same cof_name may be suplied by more sup_ids,
    and one sup_id may suply more cof_names.
    so the Primary key should be set the cof_name and sup_id ,
    how to set ?
    (of course that i konw if I set a cof_id,the problem will be easy work out
    but now there are those like above)
    I set that as following:
    create table coffees (cof_name VARCHAR(32) PRIMARY KEY,sup_id INTEGER, PRIMARY KEY,PRICE INTEGER )
    THE database print error :cant add more primary keys!
    thanks in advance

    You can only use the PRIMARY KEY declaration on a column if it is the only Primary Key column.
    Use the PRIMARY KEY constraint statement instead.
    create table coffees (
      cof_name VARCHAR(32),
      sup_id INTEGER,  
      PRICE INTEGER,
      PRIMARY KEY ( cof_name ,sup_id )
    )Dave

  • How to set Tool Tip Text to Tree Node?

    Hi,
    How to set Tool Tip Text to Tree Node in JTree?
    Pls somebody help me to solve it.

    bsampeieri,
    Been here a long time myself. I don't agree with the one post is enough per se. That is to say, sometimes, it helps to post in several groups so that more eyes may see it. A number of forum posters linger in specific forum topics and may not see the post in another forum.
    Now, if in the previous post you/others answered the question and then the OP posted here later, I could see the complaint.
    For the OP, the better way to cross-post is to have one "main" post, then have all the other posts refer back to that one (link to it) so that people aren't duplicating the effort to answer your question(s). A simple "I have cross-posted this to get more eyes on it. Please reply to this question at this post <link here>"

  • How to sync two iphone 4s to one itunes account on one PC?

    Hi
    Could you please tell me how to sync two iphone 4s to one itunes account on one PC? I successfully synced my husband's phone to my account ( he got his phone first) but my phone isn't showing up in devices. Very frustrating as he know can listen to all my music and I can't!!
    Thanks in advance

    Try this, How to use multiple iPods, iPads, or iPhones with one computer, http://support.apple.com/kb/HT1495

  • How to set background color in row of JTable ?

    i am new in java please tell me about How to set background color in row of JTable ? please example code. Thnak you.

    Here is an example: http://www.javaworld.com/javaworld/javaqa/2001-09/03-qa-0928-jtable.html
    For more info on how to use tables read the swing tutorial: http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
    ICE

  • How to set background color in af:inputText in an af:table

    Hi,
    how to set background color in af:inputText in an af:table depending on the value of af:inputText.
    For example, how to set background red if the af:inpuText is empty
    Thanks

    Hello Pavo,
    it's also possible to take the code from ebitar and use the expression within styleClass instead of inlineStyle.
    E.g. you can define a custom style "StyleClassEmptyText" in your skin and set this styleclass if af:inputtext is empty.
    By using style classes you can have the same style in the whole application and you are able to change this style on a single point(in the styleclass) for the whole application.
    br
    Peter

  • How to set the default text in an input box or a label to be a predefine, multiline text

    how to set the default text in an input box or a label to be a predefine, multiline text. In other words how to break the line in the code of a text box.
    thank you

    There are a couple of ways of doing this:
    If you're editing on the canvas, press Shift + Enter.
    If you're working in Express View (see lower right hand corner of Project Siena), you'll need to copy a hard return from another app such as Notepad.
    I believe a better implementation of hard returns are in the list of requested functionality that you can find here:
    https://social.technet.microsoft.com/Forums/en-US/2e1f9446-56b2-419a-9c17-7037d2cd6146/from-the-community-overview-of-requested-additional-functionality?forum=projectsiena
    Thor

  • How to copy and paste text from one photo book page to another.

    hello,i downloaded this software 2days ago,and i've been having so much fun with it. pls i need help on how to copy and paste text from one photo book page to another. Secondly how to copy my completed photo book pages project to another laptop for printing. thanks
    This question was solved.
    View Solution.

    Hi DG.
    The easiest way to copy an HP Photo Creations project to another computer is to click the Share button. That will upload the project to the Web and give you a link you can paste into an email. Clicking the link on the other computer allows you to download the project and personalize it. This quick video shows the process. (The screen looks slightly different now, but the concept is the same.)
    Another way to share a project is copy the project folder to a thumb drive. Look in Documents/HP Photo Creations/My Things to find your saved projects.
    Our customer support team would be happy to walk you through the process. Contact them at [email protected]
    Hope this helps,
    RocketLife 
    RocketLife, developer of HP Photo Creations
    » Visit the HP Photo Creations Facebook page — news, tips, and inspiration
    » See the HP Photo Creations video tours — cool tips in under 2 minutes
    » Contact Customer Support — get answers from the experts

Maybe you are looking for

  • How do I create parent/child relationship between objects? so that if I change one, I change all

    I have multiple instances of an object, and I would like to make any changes that I put on one of these objects to perpetuate and change on the other instances of the object

  • Delivery quantity is greater than schedule line confirmation quantity (sales order)

    I am creating a sales order with 30 Mt. I confirmed 10 Mt (partial confirmation and based credit block) in schedule line Now I am going to create the delivery system automatic taking 10 Mt but when I am going to change the delivery means when I incre

  • Moving about newly imported photos

    Hi there, I have a fairly large iPhoto library spanning over 800 events and 49,000 pictures, all arranged chronologically. I am about to start scanning in a lot of old memorabilia that I will eventually want to put new scanned images into the relevan

  • ITunes is evil like the ouijia board...

    I keep throwing it away, but it keeps coming back!! I'm a little scared. All the trouble started when I downloaded iTunes 7. I went to buy a video, and iTunes informed me I couldn't buy it w/o updating. So I figured, cool, they realized they have a c

  • Redirecting Forms 10g URL

    Hi all, I would like to Redirect the my standard Forms URL from: http://myserver:port/forms/frmservlet?config=test to simply: http://myserver. e.g: htp://fidix.app.com Which file should I configure and how? Best regards Fidix