Setting color of a specific line?

okay so in swing is it possible to set a portion of the text in a text field to a different color? Like in my chat program(below) can I make it so all incoming chat(instring) is blue and all outgoing text(string) is red?
Am I using the wrong text component for changing the color of a line? Should I even be using J text components for this?
The tutorial often puts tons of different text components in to its examples, and uses odd methods to change the color.
It seems that I have to use something like setCaretColor, but i am not clear on how to use this in the way I want to use it.
here is the code:
import java.io.*;
import java.net.*;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.JOptionPane;
import javax.swing.JDialog;
import javax.swing.JTextField;
import java.beans.*; //property change stuff
import java.awt.*;
import java.awt.event.*;
public class server extends JFrame implements ActionListener
     JButton recieve;
     String string;
        String instring;
     String aft = " ";
     String bef = " ";
     String allchat=" ";
     JTextField towrite;
     boolean stop = false;
     String name;
     JTextArea chatbox;
     public server(){
                         setSize(490,550);
                         getContentPane().setLayout(null);
                         recieve = new JButton("send message");
                         recieve.setBounds(30,150,150,35);
                         getContentPane().add(recieve);
                                   recieve.addActionListener(this);
                         chatbox = new JTextArea("chat goes here");
                         chatbox.setEditable(false);
                         chatbox.setBounds(10,200,460,270);
                         getContentPane().add(chatbox);
                                        towrite = new JTextField("Write message here");
                         towrite.setBounds(10,475,460,35);
                         getContentPane().add(towrite);
                                        towrite.addActionListener(this);
                         setVisible(true);
               name = (String)JOptionPane.showInputDialog(null,"Enter your name");
          while(stop==false){
               try
               ServerSocket socket = new ServerSocket(4019);
               Socket insocket =socket.accept();
               BufferedReader in = new BufferedReader (new InputStreamReader(insocket.getInputStream()));
               instring = in.readLine();
               socket.close();
               bef = instring;
               if(bef.equals(aft)){}else{
                    allchat=instring+"\n"+allchat;
                    chatbox.setText(allchat);
catch(Exception e){}
         public void actionPerformed(ActionEvent evt)
        if(evt.getActionCommand().equals("send message"))
try
Socket socket = new Socket("67.166.126.246",4020);
OutputStream out = socket.getOutputStream();
string=name+": "+towrite.getText();
byte buffer[] = string.getBytes();
out.write(buffer);
socket.close();
catch(Exception e){}
               bef = string;
               if(bef.equals(aft)){}else{
                    allchat=string+"\n"+allchat;
                    chatbox.setText(allchat);
               aft=bef;
public static void main(String[] args)
server s = new server();}}

Hmmmm im sorry but Im not quite sure I understand how to do this.
Do you have to know the exact digits at which the text starts and ends?
or can you, as mentioned just use html tags to set the text color?
If i were to highlight a line of the text, would that text be highlighted even if its location in the string changed?
It would seem that tags would be easier but from what I have tried they don't seem to work in editor panes, but the ydo work in buttons
Im sorry, Im being a bit of a pest, but I have not been doing java for that long, and I do not have a teacher, so all of my questions have to go here.

Similar Messages

  • Set color to a specific word in text

    I hava text in JEditorPane I want to set Color to spacific word in text
    thank you

    Engy i've been searching.U'll find EXACTLY what u want in the java tutorial ,the folder (uiswing),open the folder (Components) inside it u'll find the file(generaltext.html).there, u'll find a perfect demo with it's 2 classes TextComponentDemo.java & LimitedStyledDocument.java
    u can use them.u'll find all u want there..good luck

  • Setting color in a specific JTable

    I was wondering if anyone could help me with this problem. I wish to set some cells in the first column only to Yellow. I have done the following;public class customTableCellRenderer extends
    DefaultTableCellRenderer
        JTable table;
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
    Component cell = super.getTableCellRendererComponent(table,value,isSelected,hasFocus,row,column);//getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if(value instanceof String)
                 String s= (String) value;
                 if(value.equals("Monday"))
                    cell.setBackground(Color.YELLOW);
                else
                    cell.setBackground(Color.BLUE);
                 return cell;
    }and my class with the JTable calls the above class:
        public JPanel centre()
            JPanel tablePanel=new JPanel(new BorderLayout());
            Object[] titles = new String[]{"","9.00","10.00","11.00","12.00","13.00","14.00","15.00","16.00","17.00","18.00","19.00"};
            String[] rows = new String[]{"Monday","Tuesday","Wednesday","Thursday","Friday"};
            Object[][] data ={
                        {"Monday","","","","","","","","","","",""},
                         {"Tuesday","","","","","","","","","","",""}};
              DefaultTableModel model=new DefaultTableModel(data,titles); 
              table=new JTable(model);
             String[][] data = new String[rows.length][titles.length];
            JTable timeTable = new JTable(data, titles);         customTableCellRenderer cr=new customTableCellRenderer();
               try
                table.setDefaultRenderer( Class.forName
                   ( "java.lang.Integer" ), cr );
            catch( ClassNotFoundException ex )
                System.exit( 0 );
            table.setDefaultRenderer(Color.class, cr);
            JScrollPane pane = new JScrollPane(table);  
            pane.setSize(new Dimension(500,300));
            pane.setViewportView(table);
            tablePanel.add("Center", pane);
            return tablePanel;
    }it still doesnt set the color in the cells for; Monday, Tuesday, Wednesday, Thursday, Friday.

    Your renderer isn't being used.
    JTable chooses the appropriate renderer based on the value of the getColumnClass(...) method. Since you haven't overridden that method it thinks all data is an Object and uses the Object renderer.
    The following lines accomplish nothing, since you don't store any Integers or Color objects in your table. Every Object is a String.
    table.setDefaultRenderer( Class.forName( "java.lang.Integer" ), cr );
    table.setDefaultRenderer(Color.class, cr);
    If you want you can specifiy a renderer for a specific column. You get the TableColumn from the TableColumnModel and add the renderer directly to the column.
    If all you want to do is color a cell, then another option is to override the prepareRenderer() method. Something like this:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=610474

  • How to set color of a specific pixel on an artLayer in JS

    I am brand new to PS scripting. I know I can select a 1x1 pixel rectangle and fill it with a specific color, but that seem inefficient.
    Is there a way to quickly and directly set the color of a specified pixel?
    Thanks.

    JTextArea doesn't support this, but if you read the JTextArea API you will find a link to the Swing tutorial on "Using Text Components" that will show you a text component that you can use.

  • How do you set the font color for a specific entire row inside a JTable?

    How do you set the font color for a specific entire row inside a JTable?
    I want to change the font color for only a couple of rows inside a JTable.
    I've seen some ways to possibly do this with an individual cell.
    Clarification on changing the font color in an individual cell would be helpful too if
    there is no easy way to do this for a row.

    hai,
    Try out with this piece of code.Create your table and assign the renderer to each column in the table.
    CellColorRenderer m_CellColorRenderer = new CellColorRenderer();
    for(int i=0;i<your_JTable.getColumnCount();i++)
    your_JTable.getColumnModel().getColumn(i).setCellRenderer(m_CellColorRenderer);
    class CellColorRenderer extends JLabel implements TableCellRenderer
    CellColorRenderer()     
    setOpaque(true);     
    setHorizontalAlignment(LEFT);
    setVerticalAlignment(CENTER);
    setBackground(Color.white);
    setForeground(Color.black);
    protected void setValue(Object value)
         setText((value == null) ? "" : value.toString());
    public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected, boolean hasFocus, int row,int column)
         if(isSelected == true)
              setForeground(Color.red);
         else
              setForeground(Color.black);
         setValue(value);
         return this;
    regards,
    bala

  • I want to display specific line to be color in alvlist how

    i want to display specific line to be color in alvlist
    i write the code as follows here document type is initial. then that line is to be
    appeared as color line but problem is initially it is appeared correct later i moved to next previous screens  error lines are to be colored where i have to clear 
      loop at it_doclist where blart eq space.
          gt_layout-info_fieldname  = 'COLOR_LINE'.
          it_doclist-color_line = 'C600'.
          modify it_doclist .
          clear:it_doclist.
      endloop.
    please help me exactly
    Thanks
    Ramana reddy

    u r requiremnt is not clear...but any how check this code....
    it has a form for assigning colors....
    rewardif useful
    REPORT zppb001_prd_posting_upload
           NO STANDARD PAGE HEADING LINE-SIZE 255
           MESSAGE-ID zpp.
    INCLUDE bdcrecx1.
    TYPE-POOLS  :slis.
    DATA:   wk_success(5) TYPE c,     "To store the successfull Hits
            wk_failure(5) TYPE c,     "To store the failed Hits
            l_mstring(600),           "To store Message texts
            t_date TYPE zservice_date,"To store Uploaded Date
            wk_lines(5) TYPE c,       "To store No of Records
            lines(5) TYPE c,          "To store No of Records
            wk_len(150) TYPE c,       "To store File path
            wk_alp TYPE i,            "To store path length
            lent TYPE i,              "To store path length
            b(4).                     "To store File extension
    DATA:   alvfld TYPE slis_t_fieldcat_alv WITH HEADER LINE,
            v_events TYPE slis_t_event WITH HEADER LINE,
            wk_events LIKE LINE OF v_events,
            it_list_comments TYPE slis_t_listheader,
            wk_list_comments LIKE LINE OF it_list_comments,
            wk_layout TYPE slis_layout_alv.
    CONSTANTS: c_formname_top_of_page TYPE slis_formname
                                   VALUE 'F_TOP_OF_PAGE'.
    --TO STORE FINAL DATA TO BE POSTED--
    Generated data section with specific formatting - DO NOT CHANGE  ***
    DATA: BEGIN OF record OCCURS 0,
            budat_002(010),
            bktxt_004(025),
            matnr_005(018),
            werks_006(004),
            alort_007(004),
            erfmg_008(017),
          END OF record.
    End generated data section ***
    DATA: BEGIN OF messages OCCURS 0,       "TO STORE FINAL STATUS DISPLAY
           budat_002(010),
           bktxt_004(025),
           matnr_005(018),
           maktx TYPE makt-maktx,
           werks_006(004),
           alort_007(004),
           erfmg_008(017),
           msg_e(400),
           msg_s(600),
           msgtyp TYPE c,
           line_color(4),
          END OF messages.
    DATA: BEGIN OF st_record1 ,
           matnr_005(018),
           werks_006(004),
           budat_002(010),
           bktxt_004(025),
           erfmg_007(017),
           erfmg_008(017),
           alort_007(004),
          END OF st_record1.
    DEFINE alv_macro.
      move : &1 to alvfld-col_pos,
             &2 to alvfld-fieldname,
             &3 to alvfld-seltext_m.
      if &2 = 'MATNR_005' or &2 = 'MAKTX'.
        alvfld-fix_column = 'X'.
      endif.
      append alvfld.clear alvfld.
    END-OF-DEFINITION.
    DATA : record1 LIKE TABLE OF st_record1 WITH HEADER LINE,
           it_excel LIKE TABLE OF alsmex_tabline WITH HEADER LINE,
           messtab1 LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE,
           it_acc LIKE TABLE OF record WITH HEADER LINE,
           it_rej LIKE TABLE OF record WITH HEADER LINE.
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002.
    PARAMETERS: p_file TYPE localfile OBLIGATORY .
    SELECTION-SCREEN END OF BLOCK b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          static    = 'X'
        CHANGING
          file_name = p_file.
    AT SELECTION-SCREEN ON p_file.
      wk_len = p_file.
      CONDENSE wk_len NO-GAPS.
      lent = STRLEN( wk_len ).
      wk_alp = lent - 4.
      b = wk_len+wk_alp(lent).
      IF ( b NE '.txt' ) AND ( b NE '.xls' ).
        MESSAGE e939.
        CLEAR p_file.
        STOP.
      ENDIF.
    START-OF-SELECTION.
      PERFORM upload_fun.
      PERFORM open_group.
      PERFORM fill_bdc_table.
      PERFORM close_group.
      PERFORM assign_colors.
      PERFORM f_event_build.
      SORT messages BY matnr_005 ASCENDING.
      PERFORM assign_columns.
      PERFORM count.
      IF ctu = 'X'.
        PERFORM alv.
      ENDIF.
      FREE:messages,messtab1,record1.
    END-OF-SELECTION.
    --FORM UPLOAD_FUN--
    FORM upload_fun.
    REFRESH: record1, it_acc, it_rej, record, messages, messtab1, it_excel.
      PERFORM fetch_from_flat_file.
      CLEAR it_excel.
      DESCRIBE TABLE it_excel.
      IF sy-tfill = 0.
        MESSAGE i937. STOP.
      ENDIF.
      LOOP AT it_excel.
        CASE it_excel-col.
          WHEN '0001'. MOVE: it_excel-value TO record1-matnr_005.
          WHEN '0002'. MOVE: it_excel-value TO record1-werks_006.
          WHEN '0003'. MOVE: it_excel-value TO record1-budat_002.
          WHEN '0004'. MOVE: it_excel-value TO record1-bktxt_004.
          WHEN '0005'. MOVE: it_excel-value TO record1-erfmg_007.
          WHEN '0006'. MOVE: it_excel-value TO record1-erfmg_008.
          WHEN '0007'. MOVE: it_excel-value TO record1-alort_007.
        ENDCASE.
        AT END OF row.
          APPEND record1. CLEAR record1.
        ENDAT.
      ENDLOOP.
      DELETE record1 WHERE matnr_005 EQ ' '.
    --DO NOT UPLOAD WHERE PRD QTY = 0--
      DELETE record1 WHERE ( erfmg_007 = 0 OR erfmg_007 = ' ' )
                      AND  ( erfmg_008 = 0 OR erfmg_008 = ' ' ).
      DESCRIBE TABLE record1[].
      IF sy-tfill > 0.
    --MOVE ACCEPTED QTY AND FETCH THE RESPECTIVE STGLOC-**
        LOOP AT record1 WHERE erfmg_007 NE 0 AND erfmg_007 NE ' '.
          MOVE:    record1-budat_002 TO it_acc-budat_002,
                   record1-bktxt_004 TO it_acc-bktxt_004,
                   record1-matnr_005 TO it_acc-matnr_005,
                   record1-werks_006 TO it_acc-werks_006,
                   record1-erfmg_007 TO it_acc-erfmg_008.
          APPEND it_acc. CLEAR: it_acc,record1.
        ENDLOOP.
    --MOVE ELPRO FOR THE ACCEPTED ENTRIES--
        LOOP AT it_acc.
          SELECT SINGLE elpro INTO it_acc-alort_007
                                            FROM mkal CLIENT SPECIFIED
                                            WHERE mandt = sy-mandt
                                            AND matnr = it_acc-matnr_005
                                            AND werks = it_acc-werks_006.
          MODIFY it_acc TRANSPORTING alort_007. CLEAR: it_acc.
        ENDLOOP.
    --MOVE PRD QTY FOR REJECTED QTY--
        LOOP AT record1 WHERE erfmg_008 NE 0 AND erfmg_008 NE ' '.
          MOVE: record1-budat_002 TO it_rej-budat_002,
                record1-bktxt_004 TO it_rej-bktxt_004,
                record1-matnr_005 TO it_rej-matnr_005,
                record1-werks_006 TO it_rej-werks_006,
                record1-erfmg_008 TO it_rej-erfmg_008,
                record1-alort_007 TO it_rej-alort_007.
          APPEND it_rej. CLEAR: it_rej, record1.
        ENDLOOP.
    --MOVE ACCEPTED AND REJECTED READINGS TO FINAL TABLE
        APPEND LINES OF it_acc TO record. APPEND LINES OF it_rej TO record.
        FREE : it_rej, it_acc, record1.
      ELSE.
        MESSAGE i937.
        STOP.
      ENDIF.
    ENDFORM.                    " UPLOAD_FUN
    --FORM fill_bdc_table--
    FORM fill_bdc_table.
      IF NOT record[] IS INITIAL.
        LOOP AT record.
          PERFORM bdc_dynpro USING 'SAPLBARM' '0800'.
          PERFORM bdc_field  USING 'BDC_CURSOR' 'RM61B-BKTXT'.
          PERFORM bdc_field  USING 'BDC_OKCODE' '=ISTDA'.
          PERFORM bdc_field  USING 'RM61B-BUDAT' record-budat_002.
          PERFORM bdc_field  USING 'RM61B-BKTXT' record-bktxt_004.
          PERFORM bdc_field  USING 'RM61B-MATNR' record-matnr_005.
          PERFORM bdc_field  USING 'RM61B-WERKS' record-werks_006.
          PERFORM bdc_field  USING 'RM61B-ALORT' record-alort_007.
          PERFORM bdc_field  USING 'RM61B-ERFMG' record-erfmg_008.
          PERFORM bdc_dynpro USING 'SAPLCOWB' '0130'.
          PERFORM bdc_field  USING 'BDC_OKCODE' '=WEIT'.
          PERFORM bdc_field  USING 'BDC_CURSOR' 'G_COWB_HEADER-MNGTXT'.
          PERFORM bdc_transaction USING 'MFBF'.
          CLEAR messtab.
          messtab1[] = messtab[].
          LOOP AT messtab1 WHERE msgtyp = 'S' OR msgtyp = 'E'.
            SELECT SINGLE * FROM t100 WHERE sprsl = messtab1-msgspra
                                      AND   arbgb = messtab1-msgid
                                      AND   msgnr = messtab1-msgnr.
            IF sy-subrc = 0.
              l_mstring = t100-text.
              PERFORM store_messages.
              CLEAR l_mstring.
            ENDIF.
          ENDLOOP.
          MOVE-CORRESPONDING record TO messages.
         SELECT SINGLE maktx INTO messages-maktx FROM makt CLIENT SPECIFIED
                                                 WHERE mandt = sy-mandt
                                              AND matnr = messages-matnr_005
                                              AND spras = 'EN'.
          APPEND messages.
          CLEAR: messages, messtab1. REFRESH messtab1.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    "fill_bdc_table
    --FORM assign_columns--
    FORM assign_columns .
      REFRESH alvfld.
      alv_macro '1' 'MATNR_005' 'PART NO'.
      alv_macro '2' 'MAKTX' 'DESCRIPTION'.
      alv_macro '3' 'WERKS_006' 'PLANT'.
      alv_macro '4' 'BUDAT_002' 'POSTING DATE'.
      alv_macro '5' 'BKTXT_004' 'SHIFT'.
      alv_macro '6' 'ERFMG_008' 'QUANTITY'.
      alv_macro '7' 'ALORT_007' 'STGLOC'.
      alv_macro '8' 'MSG_E' 'ERRORS DUE TO'.
      alv_macro '9' 'MSG_S' 'STATUS'.
    ENDFORM.                    " assign_columns
    --FORM f_event_build--
    FORM f_event_build .
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = v_events[].
      READ TABLE v_events WITH KEY name = slis_ev_top_of_page
                                               INTO wk_events.
      wk_layout-info_fieldname = 'LINE_COLOR'.
      wk_layout-colwidth_optimize    = 'X'.
      IF sy-subrc = 0.
        MOVE c_formname_top_of_page TO wk_events-form.
        MODIFY v_events FROM wk_events INDEX sy-tabix.
      ENDIF.
    ENDFORM.                    " f_event_build
    --FORM f_top_of_page--
    FORM f_top_of_page.
      WRITE sy-datum TO t_date.
      CLEAR: it_list_comments[].
      wk_list_comments-typ  = 'H'. "H=Header, S=Selection, A=Action
      wk_list_comments-key  = ''.
    CONCATENATE 'UPLOADED STATUS FOR PRODUCTION POSTING ON - ' t_date INTO
                                 wk_list_comments-info SEPARATED BY space.
      APPEND wk_list_comments TO it_list_comments.
      CLEAR wk_list_comments.
      DESCRIBE TABLE messages LINES wk_lines.
      lines = wk_lines.
      wk_list_comments-typ  = 'S'. "H=Header, S=Selection, A=Action
      wk_list_comments-key  = ''.
      CONCATENATE 'Total No of Hits:' lines INTO wk_list_comments-info
                                                      SEPARATED BY space.
      APPEND wk_list_comments TO it_list_comments.
      CLEAR wk_list_comments.
      wk_list_comments-typ  = 'S'. "H=Header, S=Selection, A=Action
      wk_list_comments-key  = ''.
      CONCATENATE 'Successfull Hits:' wk_success INTO
                wk_list_comments-info SEPARATED BY space.
      APPEND wk_list_comments TO it_list_comments.
      CLEAR wk_list_comments.
      wk_list_comments-typ  = 'S'. "H=Header, S=Selection, A=Action
      wk_list_comments-key  = ''.
      CONCATENATE '    Failed Hits:' '   ' wk_failure INTO
                              wk_list_comments-info
                              SEPARATED BY space.
      APPEND wk_list_comments TO it_list_comments.
      CLEAR wk_list_comments.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          i_logo             = 'ENJOYSAP_LOGO'
          it_list_commentary = it_list_comments.
    ENDFORM.                    "F_TOP_OF_PAGE
    --FORM assign_colors--
    FORM assign_colors .
      LOOP AT messages.
        CASE messages-msgtyp.
          WHEN 'E'.
            messages-line_color = 'C601'.
          WHEN 'S'.
            messages-line_color = 'C501'.
        ENDCASE.
        MODIFY messages TRANSPORTING line_color.
      ENDLOOP.
    ENDFORM.                    " assign_colors
    --FORM COUNT--
    FORM count .
      CLEAR: wk_failure, wk_success.
      LOOP AT messages.
        CASE messages-msgtyp.
          WHEN 'E'.
            ADD 1 TO wk_failure.
          WHEN 'S'.
            ADD 1 TO wk_success.
        ENDCASE.
      ENDLOOP.
    ENDFORM.                    " COUNT
    --FORM ALV--
    FORM alv .
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program = sy-repid
          is_layout          = wk_layout
          it_fieldcat        = alvfld[]
          it_events          = v_events[]
        TABLES
          t_outtab           = messages
        EXCEPTIONS
          program_error      = 1
          OTHERS             = 2.
    ENDFORM.                    " ALV
    --FETCH_FROM_FLAT_FILE--
    FORM fetch_from_flat_file .
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = p_file
          i_begin_col             = 1 "From 1st Column
          i_begin_row             = 2 "From 2nd row
          i_end_col               = 7 "Till 7th Column
          i_end_row               = 65000 "Till Row
        TABLES
          intern                  = it_excel
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
    ENDFORM.                    " FETCH_FROM_FLAT_FILE
    --FORM STORE_MESSAGES--
    FORM store_messages.
      IF l_mstring CS '&1'.
        REPLACE '&1' WITH messtab1-msgv1 INTO l_mstring.
        REPLACE '&2' WITH messtab1-msgv2 INTO l_mstring.
        REPLACE '&3' WITH messtab1-msgv3 INTO l_mstring.
        REPLACE '&4' WITH messtab1-msgv4 INTO l_mstring.
      ELSE.
        REPLACE '&' WITH messtab1-msgv1 INTO l_mstring.
        REPLACE '&' WITH messtab1-msgv2 INTO l_mstring.
        REPLACE '&' WITH messtab1-msgv3 INTO l_mstring.
        REPLACE '&' WITH messtab1-msgv4 INTO l_mstring.
      ENDIF.
      CONDENSE l_mstring.
      IF messtab1-msgtyp = 'E'.
    CONCATENATE messages-msg_s l_mstring INTO l_mstring SEPARATED BY space.
        MOVE l_mstring TO messages-msg_e.
        MOVE 'E' TO messages-msgtyp.
        MOVE 'Document Not Posted' TO messages-msg_s.
      ELSEIF messtab1-msgtyp = 'S'.
    CONCATENATE messages-msg_s l_mstring INTO l_mstring SEPARATED BY space.
        MOVE l_mstring TO messages-msg_s.
        MOVE 'S' TO messages-msgtyp.
      ENDIF.
    ENDFORM.                    " store_messages

  • Go to a specific line in a report.

    Hi<
    How can i, using the at-line-selection or the at-user-command, scroll to a specific line in a report?
    I've using the scroll statement but nothing have done it.
    imagine a 12 pages report, y want to go to the line 756 no matter in what page is it.

    Hi,
    These is and example that i made.
    If you can make it work, ill be more than thank full.
    Hi,
    These is and example that i made.
    If you can make it work, ill be more than thank full.
    REPORT z_example .                                                     
    DATA: i TYPE i,                                                        
          c TYPE i,                                                        
          s TYPE i.    
    SELECTION-SCREEN BEGIN OF BLOCK one WITH FRAME TITLE text-001.         
    PARAMETERS:     max_num TYPE i OBLIGATORY.                             
    SELECTION-SCREEN END OF BLOCK one.                                     
    START-OF-SELECTION.                                                    
      SET PF-STATUS 'MENU'.                                                
      i = 0.                                                               
      c = 0.                                                               
      DO max_num TIMES.                                                    
        WRITE: /10 i COLOR 5 HOTSPOT.                                      
        i = i + 1.                                                         
        c = c + 1.                                                         
        IF c = 31.                                                         
          NEW-PAGE.                                                        
          c = 0.                                                           
        ENDIF.                                                             
      ENDDO.        
    *&      Top-of-page                                                    
    TOP-OF-PAGE.                                                           
      PERFORM top_of_page.                                                 
    *&      Top-of-page                                                    
    TOP-OF-PAGE DURING LINE-SELECTION.                                     
      PERFORM top_of_page.                                                 
      PERFORM top_of_page.                                                 
    *&     from Top-of-page                                                
    FORM top_of_page.                                                      
      WRITE: 10 'my example' COLOR 1, 70 'Page:' COLOR 1, sy-pagno COLOR 2.
    ENDFORM.                                                               
    *&   Event AT USER-COMMAND.                                            
    AT USER-COMMAND.                                                       
      CASE sy-ucomm.                                                       
        WHEN 'SELEC'.                                                      
          s = sy-lisel+9(12).                                              
          i = 0.                                                           
          c = 0.                                                           
          DO max_num TIMES.                                                
            IF i = s.                                                      
              WRITE: /10 i COLOR 6.                                        
              s = 0.                                                       
            ELSE.                                                          
              WRITE: /10 i COLOR 5 HOTSPOT.                                
            ENDIF.                                                         
            i = i + 1.                                                     
            c = c + 1.                                                     
            IF c = 31.                                                     
              NEW-PAGE.                                                    
              c = 0.                                                       
            ENDIF.                                                         
          ENDDO.                                                           
      ENDCASE.

  • Coloring of a (specific) row in ALV report-How?

    Hi Experts,
    Am looking to assign a color for a (specific)row in ALV report.......so, pls. let me know How to get it done?
    thanq

    TABLES:LFA1.
    SELECT-OPTIONS:LIFNR FOR LFA1-LIFNR.
    DATA:BEGIN OF ITAB OCCURS 0,
    LIFNR LIKE LFA1-LIFNR,
    NAME1 LIKE LFA1-NAME1,
    LAND1 LIKE LFA1-LAND1,
    ORT01 LIKE LFA1-ORT01,
    REGIO LIKE LFA1-REGIO,
    SORTL LIKE LFA1-SORTL,
    CFIELD(4) TYPE C,
    END OF ITAB.
    data:col(4).
    data:num value '1'.
    SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE LIFNR
    IN LIFNR.
    LOOP AT ITAB.
    concatenate 'C' num '10' into col .
    ITAB-CFIELD = col.
    num = num + 1.
    if num = '8'.
    num = '1'.
    endif.
    MODIFY ITAB.
    ENDLOOP.
    TYPE-POOLS:SLIS.
    DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA:LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA:SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE.
    DATA:EVE TYPE SLIS_T_EVENT WITH HEADER LINE.
    LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    LAYOUT-WINDOW_TITLEBAR = 'VENDORS DETAILS SCREEN'.
    LAYOUT-EDIT = 'X'.
    LAYOUT-info_fieldname = 'CFIELD'.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    I_PROGRAM_NAME = SY-REPID
    I_INTERNAL_TABNAME = 'ITAB'
    I_INCLNAME = SY-REPID
    CHANGING
    CT_FIELDCAT = FCAT.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = FCAT
    TABLES
    T_OUTTAB = ITAB.
    this is for coloring cols
    REPORT ZBHCOLOR_COLS.
    TABLES:LFA1.
    SELECT-OPTIONS:C_LIFNR FOR LFA1-LIFNR. " FOR GRID ONLY
    PARAMETERS:LIST RADIOBUTTON GROUP ALV DEFAULT 'X',
    GRID RADIOBUTTON GROUP ALV.
    DATA:BEGIN OF ITAB OCCURS 0,
    LIFNR LIKE LFA1-LIFNR,
    NAME1 LIKE LFA1-NAME1,
    LAND1 LIKE LFA1-LAND1,
    ORT01 LIKE LFA1-ORT01,
    SORTL LIKE LFA1-SORTL,
    REGIO LIKE LFA1-REGIO,
    COL TYPE LVC_T_SCOL,
    END OF ITAB.
    DATA:COLR TYPE LVC_S_SCOL.
    SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE ITAB.
    LOOP AT ITAB.
    IF ITAB-LIFNR IN C_LIFNR.
    COLR-FNAME = 'NAME1'.
    COLR-COLOR-COL = '5'.
    COLR-COLOR-INT = '1'.
    COLR-COLOR-INV = '0'.
    COLR-NOKEYCOL = 'X'.
    APPEND COLR TO ITAB-COL.
    COLR-FNAME = 'LIFNR'.
    APPEND COLR TO ITAB-COL.
    MODIFY ITAB.
    ENDIF.
    ENDLOOP.
    TYPE-POOLS:SLIS.
    DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA:LAYOUT TYPE SLIS_LAYOUT_ALV.
    LAYOUT-ZEBRA = 'X'.
    layout-coltab_fieldname = 'COL'.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    I_PROGRAM_NAME = SY-REPID
    I_INTERNAL_TABNAME = 'ITAB'
    I_INCLNAME = SY-REPID
    CHANGING
    CT_FIELDCAT = FCAT.
    IF LIST = 'X'.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = FCAT
    TABLES
    T_OUTTAB = ITAB.
    ELSEIF GRID = 'X'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = FCAT
    TABLES
    T_OUTTAB = ITAB.
    ENDIF.
    Reward points if useful.

  • How can i dynamically vary the color of one graph line

    I was looking on the developer zone and noticed several people are looking for a way to change the color of one graph line. Simplest case I would like to know: a graph is running, then you press a button and from that point on the color of the graph changes, but doesnt change the old data line color. THis way the line will consist of different colors.
    The property node changes the whole line, and the line is always just one color. It should be possible to make the line consist of different color sections, anyone know how?

    The application is actually not as slow as it seemed, i had some settings set wrong (anti aliasing in plot, and some functions in advanced, when you right click on the graph)
    Especially unchecking the anti-aliasing makes it much faster
    Also, just plotting point and not a line, or alternatively, changing the interpolation makes it faster.
    Anyway, the attached files do not rely on processor so much anymore, see for yourself
    Attachments:
    multicolor_looking_plot.vi ‏99 KB
    multicolor_looking_plot_2.vi ‏105 KB
    multicolor_looking_plot_3_truncated_array.vi ‏99 KB

  • ALV - Desactivate Check box on a specific line

    Hello all,
    I need your help for desactivate my checkbox on ALV GRID on specific line.
    See on the screen shot on the link :
    http://www.casimages.com/img.php?i=101006040322252671.jpg
    See the implementation of my ALV and my Catalog :
    g_container type scrfname value 'BCALV_GRID_DEMO_0100_CONT1',
          g_grid  type ref to cl_gui_alv_grid,
          g_custom_container type ref to cl_gui_custom_container,
          g_event_receiver type ref to lcl_event_receiver,
          gt_fieldcat type lvc_t_fcat,
          gs_layout type lvc_s_layo.
    types: begin of gs_outtab.
    types: checkbox type c.                "field for checkbox
    * §B1.Extend your output table by a field to dis- or enable
    *     cells for input.
    types: celltab type lvc_t_styl.        "field to switch editability
            include structure zpvprevmaj.
    types: end of gs_outtab.
    form build_fieldcat changing pt_fieldcat type lvc_t_fcat.
      call function 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'ZPVPREVMAJ'
        CHANGING
          ct_fieldcat      = pt_fieldcat.
    *§A2.Add an entry for the checkbox in the fieldcatalog
      clear ls_fcat.
      ls_fcat-fieldname = 'CHECKBOX'.
    * Essential: declare field as checkbox and
    *            mark it as editable field:
      ls_fcat-checkbox = 'X'.
      ls_fcat-edit = 'X'.
    * do not forget to provide texts for this extra field
      ls_fcat-coltext = text-f01.
      ls_fcat-tooltip = text-f02.
      ls_fcat-seltext = text-f03.
    * optional: set column width
      ls_fcat-outputlen = 2.
      append ls_fcat to pt_fieldcat.
    endform.                    "build_field
    gs_layout-stylefname = 'CELLTAB'.
      gs_layout-info_fname = 'LINE_COLOR'.
      perform color_line.
      call method g_grid->set_table_for_first_display
        EXPORTING
          is_layout            = gs_layout
          it_toolbar_excluding = lt_exclude
        CHANGING
          it_fieldcatalog      = gt_fieldcat
          it_outtab            = gt_outtab[].
          "it_sort              = it_sortcat.
    Thank you very much for your answers
    Edited by: Emilien P. on Oct 6, 2010 4:10 PM
    Edited by: Emilien P. on Oct 6, 2010 4:13 PM

    I think is no possible with the style i try a little tutorial. I have test the style for normal cell  and in comment i test with the check box and the checkbox always display !! :
    You can easly test this program in SAP and if anyone arrive to no display the checkbox in line 6, he will be my god Thank you :
    report ZCO_AFFACT_TEST.
    TYPE-POOLS: SLIS.
    *- Fieldcatalog
    DATA: IT_FIELDCAT TYPE LVC_T_FCAT.
    DATA: X_FIELDCAT TYPE LVC_S_FCAT.
    DATA: X_LAYOUT TYPE LVC_S_LAYO.
    " FOR DISABLE
    DATA: LS_EDIT TYPE LVC_S_STYL,
    LT_EDIT TYPE LVC_T_STYL.
    " FOR DISABLE
    DATA: BEGIN OF IT_VBAP OCCURS 0,
    VBELN LIKE VBAP-VBELN,
    POSNR LIKE VBAP-POSNR,
    STYLE TYPE LVC_T_STYL, "FOR DISABLE
    END OF IT_VBAP.
    DATA: LS_OUTTAB LIKE LINE OF IT_VBAP.
    SELECT VBELN
    POSNR
    UP TO 10 ROWS
    INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
    FROM VBAP.
    DATA:L_POS TYPE I VALUE 1.
    CLEAR: L_POS.
    L_POS = L_POS + 1.
    X_FIELDCAT-SELTEXT = 'VBELN'.
    X_FIELDCAT-FIELDNAME = 'VBELN'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS = L_POS.
    X_FIELDCAT-EDIT = 'X'.
    "Delete commentary for test with check box.
    "X_FIELDCAT-CHECKBOX = 'X'.
    X_FIELDCAT-OUTPUTLEN = '10'.
    x_fieldcat-ref_field = 'VBELN'.
    x_fieldcat-ref_table = 'VBAK'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    L_POS = L_POS + 1.
    X_FIELDCAT-SELTEXT = 'POSNR'.
    X_FIELDCAT-FIELDNAME = 'POSNR'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS = L_POS.
    X_FIELDCAT-EDIT = 'X'.
    X_FIELDCAT-OUTPUTLEN = '5'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    L_POS = L_POS + 1.
    "FOR DISABLE HERE 6ROW IS DISABLED
    SY-TABIX = 6.
    LS_EDIT-FIELDNAME = 'VBELN'.
    LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
    LS_EDIT-STYLE2 = SPACE.
    LS_EDIT-STYLE3 = SPACE.
    LS_EDIT-STYLE4 = SPACE.
    LS_EDIT-MAXLEN = 10.
    INSERT LS_EDIT INTO TABLE LT_EDIT.
    LS_EDIT-FIELDNAME = 'POSNR'.
    LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
    LS_EDIT-STYLE2 = SPACE.
    LS_EDIT-STYLE3 = SPACE.
    LS_EDIT-STYLE4 = SPACE.
    LS_EDIT-MAXLEN = 6.
    INSERT LS_EDIT INTO TABLE LT_EDIT.
    INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-STYLE.
    MODIFY IT_VBAP INDEX SY-TABIX FROM LS_OUTTAB TRANSPORTING
    STYLE .
    X_LAYOUT-STYLEFNAME = 'STYLE'.
    " UP TO HERE
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
      EXPORTING
        I_CALLBACK_PROGRAM = SY-REPID
        IS_LAYOUT_LVC      = X_LAYOUT
        IT_FIELDCAT_LVC    = IT_FIELDCAT
      TABLES
        T_OUTTAB           = IT_VBAP[]
      EXCEPTIONS
        PROGRAM_ERROR      = 1
        OTHERS             = 2.
    IF SY-SUBRC NE 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
      WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Edited by: Emilien P. on Oct 7, 2010 3:09 PM

  • Alternate color in two successive line

    i would like to have a line in a color and the next in an other color.
    for example, the first line in blue, the second in yellow, the third in blue etc...
    in order to alternate the colors between each record (line) on my report.
    thanks

    Hi!
    /* Purpose: Set a color to every 3 rows in the report */
    if ( MOD(:cs_rowct,6) <= 3 ) and (MOD(:cs_rowct,6)<> 0 ) then
    color change.
    end if
    Above :cs_rowct is summary col in data model
    based on one of your col(field) and reset at
    report level and count at report level
    Also you can change MOD condition depending on you req.
    Nirali
    null

  • How to set colors to table control?

    Hi all,
    can we set colors to tables columns and rows?? How can we acieve this? Any help please
    Thanks,
    Madhan.

    Hi All
    thanks for your replies..
    data tab type IF_main_view=>Elements_segment.
      data line type IF_main_view=>Element_segment.
      data node_info type ref to if_wd_context_node_info.
      data attribute_info type wdr_context_attribute_info.
      data attr_value type WDR_CONTEXT_ATTR_VALUE.
      data wd_standard_cell type ref to cl_wd_table_standard_cell.
      data component like line of cl_abap_structdescr=>components.
      data wd_table_column type ref to cl_wd_table_column.
      node_info = lo_nd_segment->get_node_info( ).
      attribute_info = node_info->get_attribute( 'CELL_DESIGN' ).
    if component-name = 'SEGMENT'.
      wd_standard_cell->set_cell_design( CL_WD_ABSTR_MASTER_TABLE_COL=>E_CELL_DESIGN-BADVALUE_MEDIUM ).
    endif.
    i am trying to set color for  some colomns, but i am not getting any colors??? anything wrong in this.. please help
    thanks,
    Madhan.

  • How can i set color some rows in jtable

    hi all,
    i have table with two cols one is id and other name
    i have array of id, i want set color for only those rows in an array
    i tried with the following code but only one row is seting why it is not setting
    the other rows? or this is the worg way what i did?
         model       = new DefaultTableModel(data, header);
            table          = new JTable(model){
                 int mostUsedCols[] = 151,80,185,90,88,95,137,152,153,181,178,179,180,107};
                 public Class getColumnClass(int column)
                        return getValueAt(0, column).getClass();
                   public Component prepareRenderer(TableCellRenderer renderer, int row, int column)
                        Component c = super.prepareRenderer(renderer, row, column);
                               int id = Integer.parseInt(tblLedgerAccounts.getModel().getValueAt(row, 0).toString());
                               for(int j=0; j<mostUsedCols.length;j++){
                                    c.setBackground( id == mostUsedCols[j] ? Color.LIGHT_GRAY : Color.WHITE );
                        return c;
                   }help me to solve this problem
    thanks
    daya

    hello,
    thanks,
    i have table 2 cols(say for ex) 1st column is name and other one is
    id, and i have some array of id's, i need to set the color for these rows
    and remainings rows are defalut color (white).
    I doubt that you need the
    else
    c.setBackground( Color.WHITE );if i did't set like this the entire table get gray.
    >
    since the color should be set to the default by the
    super.prepareRenderer(...) method. In fact this code
    would override the default row selection coloring.
    But maybe I don't understand your requirement. You
    notice my original example always to check to make
    sure the row is not selected before changing the
    background color.here is the demo, i comment this line what will happen c.setBackground( Color.WHITE );
    if not doing right than suggest me.
    import java.awt.Color;
    import java.awt.Component;
    import java.util.Vector;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.ListSelectionModel;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellRenderer;
    public class TableColor extends JFrame {
         public TableColor()
              Vector header = new Vector();
              Vector data   = new Vector();
              header.addElement("ID");//0
              header.addElement("Name"); //1
              header.addElement("village"); //2
              Vector v = new Vector();
              v.addElement(new Integer(1));
              v.addElement("daya");
              v.addElement("DVB");
              data.addElement(v);
              Vector v1 = new Vector();
              v1.addElement(new Integer(2));
              v1.addElement("raju");
              v1.addElement("DVBs");
              data.addElement(v1);
              Vector v2 = new Vector();
              v2.addElement(new Integer(3));
              v2.addElement("James");
              v2.addElement("sdf");
              data.addElement(v2);
              Vector v3 = new Vector();
              v3.addElement(new Integer(4));
              v3.addElement("Naga");
              v3.addElement("DVBsadf");
              data.addElement(v3);
              Vector v4 = new Vector();
              v4.addElement(new Integer(5));
              v4.addElement("xyz");
              v4.addElement("asdf");
              data.addElement(v4);
            DefaultTableModel tblModLedgerAccounts      = new DefaultTableModel(data, header);
            JTable tblLedgerAccounts          = new JTable(tblModLedgerAccounts){
                 int mostUsedCols[] = {2,4,5};
                 public Class getColumnClass(int column)
                        return getValueAt(0, column).getClass();
                   public Component prepareRenderer(TableCellRenderer renderer, int row, int column)
                        Component c = super.prepareRenderer(renderer, row, column);
                               int id = Integer.parseInt(getModel().getValueAt(row, 0).toString());
                               for(int j=0; j<mostUsedCols.length;j++){
                                    if(id == mostUsedCols[j]){
                                         c.setBackground(Color.lightGray);
                                         break;
    //                                else
    //                                     c.setBackground(Color.WHITE);
                   return c;
              JScrollPane scrollPaneLedgerAccounts =     new JScrollPane(tblLedgerAccounts);
              tblLedgerAccounts.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
              this.getContentPane().add(scrollPaneLedgerAccounts);
              setVisible(true);
              pack();
              setTitle("Table Color");
              setDefaultCloseOperation(EXIT_ON_CLOSE);
         public static void main(String args[]){
              new TableColor();
    }thanks
    daya

  • Excel Set Color and Border VI: no fill?

    If i use Excel Set Color and Border VI to modify the format of a cell, i will get white as my default color for my cell.  However, I am looking for no fill.  I don't want any color, since the color will hide the gird line.  What do I get the no fill option for cell color in LabVIEW?
    Kudos and Accepted as Solution are welcome!
    Solved!
    Go to Solution.

    I have to say I was waiting for this question (I have tried it and observed the same thing). The only solution I see is to use a combination of the RGT vis and ActiveX.
    Ben64
    note, I have connected Cell1 and Cell2 of the _Worksheet Range method but it is probably sufficient to connect only Cell1 here.
    edit: Good, your solution seems a lot more simple!

  • When I try change the color of the edge ui only change the color of the top line

    Hi,
    When I have tried to change the color of the edge field with this command:
    $.ui.#textEdit.border.edge.color.value="255,255.255" only change the color of the top line.
    Somebody know why?
    Thanks
    Ruben

    I'd like to add i've encountered the same issue. I've found out that you can use the object appearance options to reset the borders to the same properties for all edges and corners. We have custom properties for the border of a field and i needed to set the border to 0mm and back to the default 0.018 mm and our color using the option "edit together". After that, the script to change the border color works for all edges, i suppose it'll work the same for the presence.
    Regards,
    Marijn Sponselee.

Maybe you are looking for

  • How do I set up an account to receive email from my SMTP relay Server. Have I made a SMTP Server config error?

    Hi, How do I set up an account to receive email from my SMTP Relay Server? I've setup the SMTP feature and set my Server to use anonymous authentication. Things appear to look ok. But I can't connect make a test connection to it when I am trying to a

  • Repeating Frames

    In my report, my query is a 184 column table. Select query is also a 184 column table. There are Repeating frames in my layout editor, each contains 10 columns. From the 2nd repeating frame onwards, the page break before property is "Yes". Now if, fo

  • Purchase order - tracking nos.

    Hi All, In Purch.Order, there is a column for Tracking nos. I want this field to be automatically updated per item in the following scenarios 1.When i convert a p-req to a PO, i want the p-req nos to be automatically entered by the system in this fie

  • Changeing Transaction timeouts

    Hi.. While trying to tune the WLI ejbs, I came across the following documentation on edocs.bea.com. It mentions to change the trans-timeout-seconds attribute for the wlpi-ejb.jar file. But when I accessed the ejb descriptor using weblogic console, I

  • About having multiple blank  rows on master detail form

    Can I have multiple blank rows on detail form when I create master detail form? please help me shuyue