How prevent JTable row selection?

there are three selection mode for JTable, MultiIntervalSelection, SingleIntervalSelection and SingleSelection. Is there a no selection mode?

add selection listener and call table.clearSelection();or
public class NullSelectionModel implements ListSelectionModel {
          public boolean isSelectionEmpty() { return true; }
          public boolean isSelectedIndex(int index) { return false; }
          public int getMinSelectionIndex() { return -1; }
          public int getMaxSelectionIndex() { return -1; }
          public int getLeadSelectionIndex() { return -1; }
          public int getAnchorSelectionIndex() { return -1; }
          public void setSelectionInterval(int index0, int index1) { }
          public void setLeadSelectionIndex(int index) { }
          public void setAnchorSelectionIndex(int index) { }
          public void addSelectionInterval(int index0, int index1) { }
          public void insertIndexInterval(int index, int length, boolean before) { }
          public void clearSelection() { }
          public void removeSelectionInterval(int index0, int index1) { }
          public void removeIndexInterval(int index0, int index1) { }
          public void setSelectionMode(int selectionMode) { }
          public int getSelectionMode() { return SINGLE_SELECTION; }
          public void setValueIsAdjusting(boolean valueIsAdjusting) { }
          public boolean getValueIsAdjusting() { return false; }
          public void addListSelectionListener(ListSelectionListener x) {}
          public void removeListSelectionListener(ListSelectionListener x) {}     
table.setSelectionModel(new NullSelectionModel());no need to edit? simply use setEnabled(false);
cheers !!
//Ref: http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=2&t=017662

Similar Messages

  • How to make row selection by checkbox in ADF table

    hello,
    using jdev11g TP4 , fusion web application
    when i drag my view object as ADF table into jsf page,
    i want to know how to make row selection by checkbox
    thanks
    greenApple
    Edited by: greenApple on Nov 10, 2008 11:33 AM

    Hi,
    the tree component has changed compared to 10.1.3. You no longer have a tableSelectmany component that renders as checkboxes. Instead you use the ctrl key and select the table rows
    Frank

  • JTable row selection with tab key

    Helo.
    I'm having a problem selecting rows in a JTable. The JTable is with single row selection and without column and cell selection. When I press <tab> the selection changes to another cell, and I wanna it to change to the other row of the table, can anyone help me? I think this is a easy one and I haven�t found a way to do it. I�m using JBuilder for the development.

    The default Action for the Tab KeyStroke is to move focus to the next cell.
    The default Action for the Enter KeyStroke is to move focus to the next line.
    So this functionality is already available in JTable by default.
    If you want to Tab Key to work the same way as the Enter Key then you need to map the Tab Key to use the Action assigned to the Enter Key.
    This [url http://forum.java.sun.com/thread.jsp?forum=57&thread=505866]posting shows how you can reassign an Action for a given KeyStroke.
    For more information on this topic read this section from the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html]How to Use Key Bindings.

  • A Listener For JTable Row Selection Changed?

    Never mind... Thought of a couple other things after I posted and found ListSelectionListener. This looks like it fulfills my requirement nicely. - cimmerian76
    >>>
    TableModelListener isn't what I am looking for here. Basically, I'm looking for something that behaves in a way that is analogous to
    TreeSelectionListener's valueChanged(...). Perhaps I'm looking in the wrong places, but the only things I've found were RowSet listener (not even close)
    and TableModelListener (not exactly what I'm looking for - I'm not concerned about data in the table changing).
    The tool I'm writing displays additional information about the object in the row selected in an adjacent panel.
    This display should change every time a user selects a different row.
    I can mimic the behavior I want using a mouse listener on the table, so this isn't an emergency.
    It's more about curiosity. If I can find something that produces this functionality directly, I would prefer to use that.
    <<<
    Message was edited by:
    cimmerian76

    Hi,
    you can use this to handle selection events for the table:
    yourTable.getSelectionModel().addListSelectionListener(... );
    Now e.g. the class containing your main can implement interface ListSelectionListener.

  • REUSE - how to hide row selection indicator

    Hi,
    I am using fm REUSE_ALV_GRID_DISPLAY , within i have an editable checkbox field.
    But in the grid i need to hide the row selection indicator. (ie the square push button appers first column of the gird)
    But if i am using REUSE_ALV_LIST_DISPLAY, the row indicator is not appearing?
    Any suggestions?
    Thanks
    aRs

    hi...
    here sending u the report i m currently working ( used REUSE_ALV_LIST_DISPLAY and output dont hav the selection tab )
    Plz check the FM for merge ALV.
    plz send me urs code, so if possible i ll try to fix it.
    thank-you
    REPORT  zrwty_wty_errors                        .
    TYPE
    TYPE-POOLS: slis, icon.
    Tables
    Tables : pnwtyh,
             balhdr.
    Data Decleration
    DATA: text(1000), lv_clmno(40).
    Internal table for messages ( Datewise )
    DATA: BEGIN OF it_balhdr OCCURS 0,
          lognumber TYPE balhdr-lognumber,
          log_handle TYPE  balhdr-log_handle,
          END OF it_balhdr.
    Internal table for PNWTYH
    DATA: BEGIN OF it_pnwtyh OCCURS 0,
          clmno TYPE pnwtyh-clmno,
          log_message TYPE pnwtyh-log_message,
          END OF it_pnwtyh.
    Internal table to fetch the actual text messages
    DATA: it_message LIKE balm OCCURS 0 WITH HEADER LINE.
    Internal Table to handle the ALV o/p
    DATA: BEGIN OF it_grid OCCURS 0,
          clmno TYPE pnwtyh-clmno,
          chgdat TYPE dats,
          icon TYPE icon-id," BALIMSGTY
          text(1000),
          END OF it_grid.
    Field Catelog and layout Decleration
    *DATA: it_fieldcat  TYPE lvc_t_fcat,
         wa_fieldcat TYPE lvc_s_fcat OCCURS 0 WITH HEADER LINE,
         x_fieldcat TYPE lvc_s_fcat OCCURS 0 WITH HEADER LINE.
    *DATA: x_layout TYPE lvc_s_layo.
    DATA: it_fieldcat  TYPE slis_t_fieldcat_alv," type slis_fieldcat_alv
          wa_fieldcat TYPE slis_fieldcat_alv OCCURS 0 WITH HEADER LINE,
          x_layout TYPE slis_layout_alv.
    DATA: lv_repid LIKE sy-repid.
    have hotspot for a PO.
    DATA: s_fieldcat LIKE LINE OF it_fieldcat.
    s_fieldcat-hotspot = 'X'.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002.
    SELECT-OPTIONS:
      s_aldate FOR balhdr-aldate.
        SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-001.
    PARAMETERS : r1 RADIOBUTTON GROUP rg DEFAULT 'X'.
    PARAMETERS : r2 RADIOBUTTON GROUP rg .
      SELECTION-SCREEN END OF BLOCK b2.
      if s_aldate-high = '00000000'.
      s_aldate-high = s_aldate-low.
      endif.
    FM to fetcht he messg no. based on date
    CALL FUNCTION 'APPL_LOG_READ_DB'
    EXPORTING
       object                   = 'WTY'
       subobject                = 'CLAIMMSG'
        EXTERNAL_NUMBER          = ' '
       date_from                = s_aldate-low
       date_to                  = s_aldate-high
         TIME_FROM                = '000000'
         TIME_TO                  = '240000'
         log_class                = '1'
        PROGRAM_NAME             = '*'
        TRANSACTION_CODE         = '*'
        USER_ID                  = ' '
        MODE                     = '+'
        PUT_INTO_MEMORY          = ' '
      IMPORTING
        NUMBER_OF_LOGS           =
    TABLES
        HEADER_DATA              =
        HEADER_PARAMETERS        =
       messages                 = it_message
        MESSAGE_PARAMETERS       =
        CONTEXTS                 =
    data: zlines type i.
    describe table it_message lines zlines.
    if it_message[] is initial.
    message S398(00) with 'No data found.'.
    exit.
    endif.
    IF radio button ERROR only is selected, Delete others
    IF r2 = 'X'          .
      DELETE it_message WHERE msgty <> 'E'.
    ENDIF.
    fetch log_handle from BALHDR
    SELECT lognumber log_handle FROM balhdr INTO TABLE it_balhdr FOR ALL
    ENTRIES IN
    it_message WHERE lognumber = it_message-lognumber.
    Based on log _handle fetch claim no from PNWTYH
    SELECT DISTINCT clmno log_message FROM pnwtyh INTO TABLE it_pnwtyh FOR
    ALL ENTRIES IN it_balhdr WHERE log_message = it_balhdr-log_handle.
    LOOP AT it_message.
    *select single clmno into lv_clmno from pnwtyh as a  inner join BALHDR
    *as
    b on
    *aLOG_MESSAGE = bLOG_HANDLE where b~LOGNUMBER = it_message-LOGNUMBER.
      READ TABLE it_balhdr WITH KEY lognumber = it_message-lognumber.
      IF sy-subrc = 0.
        READ TABLE it_pnwtyh WITH KEY log_message = it_balhdr-log_handle.
        IF sy-subrc = 0.
          lv_clmno = it_pnwtyh-clmno.
        ENDIF.
    FM to fetch the actual text message
        CALL FUNCTION 'FORMAT_MESSAGE'
          EXPORTING
            id        = it_message-msgid
            lang      = 'EN'
            no        = it_message-msgno
            v1        = it_message-msgv1
            v2        = it_message-msgv2
            v3        = it_message-msgv3
            v4        = it_message-msgv4
          IMPORTING
            msg       = text
          EXCEPTIONS
            not_found = 1
            OTHERS    = 2.
        IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    *data: message like BAPIRET2-MESSAGE.
    *data: it_text like BAPITGB occurs 0.
    *CALL FUNCTION 'BAPI_MESSAGE_GETDETAIL'
    EXPORTING
       id                = it_message-msgid
       number            = it_message-msgno
      LANGUAGE          = SY-LANGU
       textformat        = 'RTF'
      LINKPATTERN       =
      MESSAGE_V1        =
      MESSAGE_V2        =
      MESSAGE_V3        =
      MESSAGE_V4        = -
    IMPORTING
      MESSAGE           = message
      RETURN            =
    TABLES
      TEXT              = it_text
        it_grid-clmno = lv_clmno.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
          EXPORTING
            input  = it_grid-clmno
          IMPORTING
            output = it_grid-clmno.
    Local Variable to handle Date Data
        DATA: l_tmstp(30) TYPE c,
        l_date TYPE sydatum.
        WRITE it_message-time_stmp TO l_tmstp LEFT-JUSTIFIED DECIMALS 0
        NO-GROUPING.
        l_date = l_tmstp(8).
        it_grid-chgdat = l_date.
        it_grid-text = text.
        IF  it_message-msgty = 'E'.
          it_grid-icon = '@0A@'.
        ELSEIF it_message-msgty <> 'E' AND it_message-msgty <> 'S'.
          it_grid-icon = '@09@'.
        ENDIF.
        APPEND it_grid.
        CLEAR it_grid.
        CLEAR: lv_clmno, it_message, text.
      ENDIF.
    ENDLOOP.
    PERFORM display_alv.
    *&      Form  display_alv
          text
    -->  p1        text
    <--  p2        text
    FORM display_alv .
      PERFORM build_field_catalog.
      PERFORM build_layout.
    Assign program name to variable
      lv_repid = sy-repid.
    Call the ALV Grid FM for Display
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
         EXPORTING
           i_callback_program       = lv_repid
           i_grid_title             = 'Wty Errors'
           is_layout_lvc            = x_layout
           it_fieldcat_lvc          = it_fieldcat
           I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
         TABLES
           t_outtab                 = it_grid[]
         EXCEPTIONS
           program_error            = 1
           OTHERS                   = 2             .
    IF sy-subrc <> 0.
       MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
         i_callback_program             = lv_repid
         I_GRID_TITLE                  = 'Display Messages'
      I_CALLBACK_PF_STATUS_SET       = ' '
       i_callback_user_command        = 'USER_COMMAND'
      I_STRUCTURE_NAME               =
         is_layout                      = x_layout
         it_fieldcat                    = it_fieldcat
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
      IT_SORT                        =
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = ' '
      IS_VARIANT                     =
      IT_EVENTS                      =
      IT_EVENT_EXIT                  =
      IS_PRINT                       =
      IS_REPREP_ID                   =
      I_SCREEN_START_COLUMN          = 0
      I_SCREEN_START_LINE            = 0
      I_SCREEN_END_COLUMN            = 0
      I_SCREEN_END_LINE              = 0
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
        TABLES
          t_outtab                       = it_grid[]
    EXCEPTIONS
      PROGRAM_ERROR                  = 1
      OTHERS                         = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " display_alv
    *&      Form  build_field_catalog
          text
    -->  p1        text
    <--  p2        text
    FORM build_field_catalog .
    wa_fieldcat-col_pos = 1.
    wa_fieldcat-fieldname = 'ICON'.
    wa_fieldcat-seltext_l = 'Mssg Type'.
    wa_fieldcat-icon = 'X'.
    wa_fieldcat-outputlen = 8.
    wa_fieldcat-tabname = 'IT_GRID'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-col_pos = 2.
    wa_fieldcat-fieldname = 'CHGDAT'.
    wa_fieldcat-seltext_l = 'Chg Date'.
    wa_fieldcat-outputlen = 10.
    wa_fieldcat-tabname = 'IT_GRID'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-col_pos = 3.
    wa_fieldcat-fieldname = 'CLMNO'.
    wa_fieldcat-seltext_l = 'Claim No'.
    wa_fieldcat-outputlen = 12.
    wa_fieldcat-tabname = 'IT_GRID'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-col_pos = 4.
    wa_fieldcat-fieldname = 'TEXT'.
    wa_fieldcat-seltext_l = 'Message Text'.
    wa_fieldcat-outputlen = 100.
    wa_fieldcat-tabname = 'IT_GRID'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    MODIFY it_fieldcat FROM s_fieldcat TRANSPORTING hotspot
    WHERE fieldname = 'CLMNO'.
    *CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
       EXPORTING
         i_structure_name       = 'ZWTY_ERR'
         i_bypassing_buffer     = 'X'
       CHANGING
         ct_fieldcat            = it_fieldcat[]
       EXCEPTIONS
         inconsistent_interface = 1
         program_error          = 2
         OTHERS                 = 3.
    IF sy-subrc <> 0.
       MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      I_PROGRAM_NAME               =
      I_INTERNAL_TABNAME           =
       I_STRUCTURE_NAME             = 'ZWTY_ERR'
       I_CLIENT_NEVER_DISPLAY       = 'X'
      I_INCLNAME                   =
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
      CHANGING
        ct_fieldcat                  = it_fieldcat[]
    EXCEPTIONS
      INCONSISTENT_INTERFACE       = 1
      PROGRAM_ERROR                = 2
      OTHERS                       = 3
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
      wa_fieldcat-col_pos = 1.
      wa_fieldcat-fieldname = 'ICON'.
      wa_fieldcat-seltext_l = 'Mssg Type'.
    wa_fieldcat-seltext = 'Mssg Type'.
      wa_fieldcat-icon = 'X'.
    wa_fieldcat-SCRTEXT_L = 'Mssg Type'.
    wa_fieldcat-outputlen = 8.
    wa_fieldcat-tabname = 'IT_GRID'.
    APPEND wa_fieldcat TO it_fieldcat.
      MODIFY it_fieldcat FROM wa_fieldcat TRANSPORTING seltext_l WHERE
      fieldname = 'ICON' .
      CLEAR wa_fieldcat.
    MODIFY it_fieldcat FROM wa_fieldcat TRANSPORTING seltext icon
    *SCRTEXT_L
    *WHERE
    fieldname = 'ICON' .
    CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 2.
      wa_fieldcat-fieldname = 'CHGDAT'.
      wa_fieldcat-seltext_l = 'Chg Date'.
    wa_fieldcat-seltext = 'Chg Date'.
       wa_fieldcat-SCRTEXT_L = 'Chg Date'.
    wa_fieldcat-outputlen = 10.
    wa_fieldcat-tabname = 'IT_GRID'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    MODIFY it_fieldcat FROM wa_fieldcat TRANSPORTING seltext_l WHERE
      fieldname = 'CHGDAT' .
      CLEAR wa_fieldcat.
    MODIFY it_fieldcat FROM wa_fieldcat TRANSPORTING seltext SCRTEXT_L
    *WHERE
    fieldname = 'CHGDAT' .
    CLEAR wa_fieldcat.
    wa_fieldcat-col_pos = 3.
    wa_fieldcat-fieldname = 'CLMNO'.
    wa_fieldcat-seltext_l = 'Claim No'.
    wa_fieldcat-outputlen = 12.
    wa_fieldcat-tabname = 'IT_GRID'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 4.
      wa_fieldcat-fieldname = 'TEXT'.
      wa_fieldcat-seltext_l = 'Message Text'.
    wa_fieldcat-seltext = 'Message Text'.
         wa_fieldcat-SCRTEXT_L = 'Chg Date'.
    wa_fieldcat-outputlen = 100.
    wa_fieldcat-tabname = 'IT_GRID'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    MODIFY it_fieldcat FROM wa_fieldcat TRANSPORTING seltext_l WHERE
      fieldname = 'TEXT'.
      CLEAR wa_fieldcat.
    *MODIFY it_fieldcat FROM wa_fieldcat TRANSPORTING seltext SCRTEXT_L
    *WHERE
    fieldname = 'TEXT'.
    CLEAR wa_fieldcat.
    LOOP AT it_fieldcat.
       IF it_fieldcat-fieldname  = 'CLMTY'.
         it_fieldcat-seltext_l = 'ICON'.
         it_fieldcat-icon = 'X'.
         MODIFY it_fieldcat.
       ENDIF.
    ENDLOOP.
    *Adding the Text to be displayed
    x_fieldcat-reptext = 'Claim No.'.
    MODIFY it_fieldcat FROM x_fieldcat TRANSPORTING reptext WHERE
    fieldname = 'CLMNO' .
    CLEAR x_fieldcat.
    x_fieldcat-reptext = 'MSG TYPE'.
    x_fieldcat-icon = 'X'.
    MODIFY it_fieldcat FROM x_fieldcat TRANSPORTING reptext icon WHERE
    fieldname = 'CLMTY' .
    CLEAR x_fieldcat.
    x_fieldcat-reptext = 'Text'.
    MODIFY it_fieldcat FROM x_fieldcat TRANSPORTING reptext WHERE
    fieldname = 'TEXT' .
    CLEAR x_fieldcat.
      MODIFY it_fieldcat FROM s_fieldcat TRANSPORTING hotspot
      WHERE fieldname = 'CLMNO'.
    ENDFORM.                    " build_field_catalog
    *&      Form  Build_layout
          text
    -->  p1        text
    <--  p2        text
    FORM build_layout .
      CLEAR x_layout.
      x_layout-colwidth_optimize = 'X'.
      x_layout-zebra = 'X'.
    ENDFORM.                    " Build_layout
    FORM display_detail *
    --> UCOMM *
    --> SELFIELD *
    FORM user_command USING ucomm LIKE sy-ucomm
    selfield TYPE slis_selfield.
      IF ucomm = '&IC1'.
        READ TABLE it_grid INDEX selfield-tabindex.
    *IF sy-subrc = 0.
    *SET PARAMETER ID 'CLMNO' FIELD it_grid-clmno.
    *CALL TRANSACTION 'ZWTY' AND SKIP FIRST SCREEN.
    *ENDIF.
           IF sy-subrc EQ 0.
             SET PARAMETER ID 'CLMNO' FIELD it_grid-clmno.
             CALL TRANSACTION 'WTY' AND SKIP FIRST SCREEN.
           ENDIF.
        IF sy-subrc EQ 0.
    CALL 'WTY' FOR SELECTED CLAIM
          CALL FUNCTION 'ZWTY_CLAIM_DISPLAY'
            EXPORTING
              i_clmno          = it_grid-clmno
              iv_from_doc      = 'J'
            EXCEPTIONS
              not_found        = 1
              authority_failed = 2
              no_claimtype     = 3
              OTHERS           = 4.
          IF sy-subrc <> 0.
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDFORM.                    "user_command
    regards
    vinsee

  • JTable - row selection not working + change the text format

    Hi All,
    I have written a code to display Jtable with 2 columns, 1 column to display image+text and other is multiline.
    I have used 2 different cell renderer for achiveing the same.
    Please advice on the following:
    @ When I click on row, only one column gets selected. How to fix this?
    @ Data to be displayed in rows is fetched from database. And on some STATUS value row should be in bold text or plain text. I have achieved this but withou logic to iterate over it.
    @ When user right clicks on the row allow them to set text in the row as bold or plain.(Just like we do with mails in outlook box)
    Below is the code:
    Hi All,
    I have written a code to display Jtable with 2 columns, 1 column to display image+text and other is multiline.
    I have used 2 different cell renderer for achiveing the same.
    Please advice on the following:
    @ When I click on row, only one column gets selected. How to fix this?
    @ Data to be displayed in rows is fetched from database. And on some STATUS value row should be in bold text or plain text. I have achieved this but withou logic to iterate over it.
    @ When user right clicks on the row allow them to set text in the row as bold or plain.(Just like we do with mails in outlook box)
    Below is the code:package jtab;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.util.Vector;
    import javax.swing.ImageIcon;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JMenuItem;
    import javax.swing.JOptionPane;
    import javax.swing.JPopupMenu;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableCellRenderer;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellRenderer;
    import jtab.TestIcon.iconRenderer;
    public class SampleJtable {
         JFrame frame;
         JTable table;
         JScrollPane panel;
         JPopupMenu popupMenu ;
         public static void main(String[] args) {
              SampleJtable sample = new SampleJtable();
              sample.loadGUI();
         public void loadGUI(){
              frame = new JFrame("Sample Program for Font and ImageIcons");
              frame.setContentPane(panel);
              frame.setSize(550,250);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setVisible(true);
         public SampleJtable(){
              BufferedImage images[] = new BufferedImage[1];
              try{
                   images[0] = javax.imageio.ImageIO.read(new File("C:/go.gif"));
              }catch(Exception e){
                   e.printStackTrace();
              final Object data [][] = {{"Auftrag \n test \n 777,Abdherhalden Josef, \n 1957,Grenchen Kaufe \n P",new ImageStore(images[0],"Bourquin Rene")},
                        {"Auftrag \n test \n \n 1957,Grenchen Kaufe \n N",new ImageStore(images[0],"Bourquin Rene")}};
              String colIds [] ={"Beschrebung","Von"};
              DefaultTableModel model = new DefaultTableModel(data, colIds) {  
    public Class getColumnClass(int column) {  
    return data[0][column].getClass();
              /*Vector<Object> rowData1 = new Vector(2);
              rowData1.add("Auftrag \n test \n 777,Abdherhalden Josef, \n 1957,Grenchen Kaufe");
              rowData1.add(new ImageStore(images[0],"Bourquin Rene"));
              Vector<Object> rowData2 = new Vector(2);
              rowData2.add("Auftrag \n test \n 777,Abdherhalden Josef, \n 1957,Grenchen Kaufe");
              rowData2.add(new ImageStore(images[0],"Bourquin Rene"));
              Vector<Vector> rowData = new Vector<Vector>();
         rowData.addElement(rowData1);
         rowData.addElement(rowData2);
              Vector<String> columnNames = new Vector<String>();
         columnNames.addElement("Beschrebung");
         columnNames.addElement("Von");     
              DefaultTableModel model = new DefaultTableModel(rowData, columnNames) {  
              table = new JTable(model);
              table.setDefaultRenderer(ImageStore.class, new ImageRenderer());          
              table.getTableHeader().getColumnModel().getColumn(0).setCellRenderer(new LineCellRenderer());
              table.setRowHeight(84);
              panel = new JScrollPane(table);
              panel.setOpaque(true);
         class ImageRenderer extends DefaultTableCellRenderer {  
         public Component getTableCellRendererComponent(JTable table,
         Object value,
         boolean isSelected,
         boolean hasFocus,
         int row, int column) {  
         super.getTableCellRendererComponent(table, value, isSelected,
         hasFocus, row, column);
         ImageStore store = (ImageStore)value;
         setIcon(store.getIcon());
         setText(store.text);
         return this;
         class ImageStore {  
         ImageIcon icons;
         String text;
         int showingIndex;
         public ImageStore(BufferedImage image1,String s) {
         icons = new ImageIcon(image1);
         showingIndex = 0;
         text = s;
         public ImageIcon getIcon() {  
         return icons;
         public void toggleIndex() {  
         showingIndex = (showingIndex == 0) ? 1 : 0;
         class LineCellRenderer extends JEditorPane implements TableCellRenderer {
              public LineCellRenderer() {           
              setOpaque(true);
              setContentType("text/html");          
              public Component getTableCellRendererComponent(JTable table, Object value,
              boolean isSelected, boolean hasFocus, int row, int column) {
              //System.out.println("Whats in value = "+ value.toString());
              String [] strArray = value.toString().split("\n");
              String rtStr = null ;
              System.out.println("TYPE+ "+ strArray[strArray.length-1].toString());
              String val = strArray[strArray.length-1].toString().trim();
              if (val.equalsIgnoreCase("N")){
                   System.out.println("TYPE+ IS NEW");
                   rtStr = "<html><head></head><body><b><div style=\"color:#FF0000;font-weight:bold;\">" + strArray[0] + "</div>" +
                             " <div style=\"color:#0000FF;font-weight:bold;\">" + strArray[1] + "</div>" +
                             "<div style=\"color:#0000FF;font-weight:bold;\">" + strArray[2] + "</div>" +
                             "<div style=\"color:#0000FF;font-weight:bold;\">" + strArray[3] + "</div>" +
                             "</b></body></html>";
              else {
                   System.out.println("TYPE+ IS PENDING");
                   rtStr = "<html><head></head><body><div style=\"color:#FF0000;\">" + strArray[0] + "</div>" +
                   " <div style=\"color:#0000FF;\">" + strArray[1] + "</div>" +
                   "<div style=\"color:#0000FF;\">" + strArray[2] + "</div>" +
                   "<div style=\"color:#0000FF;\">" + strArray[3] + "</div>" +
                   "</body></html>";
              setText(rtStr);
              return this;

    Posting code again........
    package jtab;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.util.Vector;
    import javax.swing.ImageIcon;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JMenuItem;
    import javax.swing.JOptionPane;
    import javax.swing.JPopupMenu;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableCellRenderer;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellRenderer;
    import jtab.TestIcon.iconRenderer;
    public class SampleJtable {
    JFrame frame;
    JTable table;
    JScrollPane panel;
    JPopupMenu popupMenu ;
    public static void main(String[] args) {
    SampleJtable sample = new SampleJtable();
    sample.loadGUI();
    public void loadGUI(){
    frame = new JFrame("Sample Program for Font and ImageIcons");
    frame.setContentPane(panel);
    frame.setSize(550,250);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    public SampleJtable(){
    BufferedImage images[] = new BufferedImage[1];
    try{
    images[0] = javax.imageio.ImageIO.read(new File("C:/go.gif"));
    }catch(Exception e){
    e.printStackTrace();
    final Object data [][] = {{"Auftrag \n test \n 777,Abdherhalden Josef, \n 1957,Grenchen Kaufe \n P",new ImageStore(images[0],"Bourquin Rene")},
    {"Auftrag \n test \n \n 1957,Grenchen Kaufe \n N",new ImageStore(images[0],"Bourquin Rene")}};
    String colIds [] ={"Beschrebung","Von"};
    DefaultTableModel model = new DefaultTableModel(data, colIds) {
    public Class getColumnClass(int column) {
    return data[0][column].getClass();
    /Vector<Object> rowData1 = new Vector(2);
    rowData1.add("Auftrag \n test \n 777,Abdherhalden Josef, \n 1957,Grenchen Kaufe");
    rowData1.add(new ImageStore(images[0],"Bourquin Rene"));
    Vector<Object> rowData2 = new Vector(2);
    rowData2.add("Auftrag \n test \n 777,Abdherhalden Josef, \n 1957,Grenchen Kaufe");
    rowData2.add(new ImageStore(images[0],"Bourquin Rene"));
    Vector<Vector> rowData = new Vector<Vector>();
    rowData.addElement(rowData1);
    rowData.addElement(rowData2);
    Vector<String> columnNames = new Vector<String>();
    columnNames.addElement("Beschrebung");
    columnNames.addElement("Von");
    DefaultTableModel model = new DefaultTableModel(rowData, columnNames) {
    table = new JTable(model);
    table.setDefaultRenderer(ImageStore.class, new ImageRenderer());
    table.getTableHeader().getColumnModel().getColumn(0).setCellRenderer(new LineCellRenderer());
    table.setRowHeight(84);
    panel = new JScrollPane(table);
    panel.setOpaque(true);
    class ImageRenderer extends DefaultTableCellRenderer {
    public Component getTableCellRendererComponent(JTable table,
    Object value,
    boolean isSelected,
    boolean hasFocus,
    int row, int column) {
    super.getTableCellRendererComponent(table, value, isSelected,
    hasFocus, row, column);
    ImageStore store = (ImageStore)value;
    setIcon(store.getIcon());
    setText(store.text);
    return this;
    class ImageStore {
    ImageIcon icons;
    String text;
    int showingIndex;
    public ImageStore(BufferedImage image1,String s) {
    icons = new ImageIcon(image1);
    showingIndex = 0;
    text = s;
    public ImageIcon getIcon() {
    return icons;
    public void toggleIndex() {
    showingIndex = (showingIndex == 0) ? 1 : 0;
    class LineCellRenderer extends JEditorPane implements TableCellRenderer {
    public LineCellRenderer() {
    setOpaque(true);
    setContentType("text/html");
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
    //System.out.println("Whats in value = " value.toString());
    String [] strArray = value.toString().split("\n");
    String rtStr = null ;
    System.out.println("TYPE " strArray[strArray.length-1].toString());
    String val = strArray[strArray.length-1].toString().trim();
    if (val.equalsIgnoreCase("N")){
    System.out.println("TYPE IS NEW");
    rtStr = "<html><head></head><body><b><div style=\"color:#FF0000;font-weight:bold;\">" strArray[0] "</div>"
    " <div style=\"color:#0000FF;font-weight:bold;\">" strArray[1] "</div>"
    "<div style=\"color:#0000FF;font-weight:bold;\">" strArray[2] "</div>"
    "<div style=\"color:#0000FF;font-weight:bold;\">" strArray[3] "</div>"
    "</b></body></html>";
    else {
    System.out.println("TYPE+ IS PENDING");
    rtStr = "<html><head></head><body><div style=\"color:#FF0000;\">" strArray[0] "</div>"
    " <div style=\"color:#0000FF;\">" strArray[1] "</div>"
    "<div style=\"color:#0000FF;\">" strArray[2] "</div>"
    "<div style=\"color:#0000FF;\">" strArray[3] "</div>"
    "</body></html>";
    setText(rtStr);
    return this;
    }

  • JTable row selection on certain cell values

    Hi Everybody,
    Here is the scenario. I have MyTableModel.java, MyTable.java and MyTablePanel.java etc classes. I want that user can only able to select the row in the table when there is certain data in the cell, otherwise user should not able to select the row.
    I know in advance that only one value form a pole of value can be in the cell, and I know all these pole data. Let say we have the three constant values in the pole i.e.. A, B, and C. I want that when there is "B" value in the cell, then user can select the row, in other two cases should not.
    What I did I looked the value form the TableModel for that cell, if the value is "B" then set the "flag" true otherwise false, and used this flag in the table.setRowSelectionEnabled(flag).
    The problem is that this method just read the flag at the start, even when the flags value changed, doesn't make any change.
    Is some body have any idea, how I can solve this problem.
    Thanks in advance

    It sounds like you are trying to catch selections from the user at the point where they click on the row, right? The problem is that the clicking event is what selects the row, so by the time you catch it in an event handler, the selection has been done.
    I guess the best way to do it is to have a MouseListener on the table which intercepts the click and checks the value held in the cell. If the cell displays a value the user shouldnt be able to select, it should set the selection in the table selection model back to empty.
    DS

  • Multi Jtable row selection

    I am trying to allow a multi Jtable selection :
    In a JPanel, boxlayout, I have many Jtables aligned with the Y AXIS (one below the other). They have the same model and what I want is to be able, when I drag an area with the mouse, to select all the rows that are into this area event if the area covers many JTables.
    In other words, the user must be able to select rows from differents Jtables as if there was only one Jtable at all.
    Do seomeone has an Idea ?
    chmurb

    I must be doing something wrong as both not working for me...:
    On the change width - no effect at all:
            Table temp = new Table(cust.getData() , vtrColumn );
            TableColumnModel col = temp.getColumnModel();
            TableColumn tcol = col.getColumn(0) ;
            tcol.setPreferredWidth(10); // tried any other number as well...
            rtrvTable.setModel(temp.getModel());
            rtrvTable.repaint();and on the remove column - it removes it completly - not only hiding it, so I cannot get the value at the column (which I need as it is the PK of the tabe)
            JTable temp = new JTable(cust.getData() , vtrColumn );
            rtrvTable.setModel(temp.getModel());
            TableColumn col0a = rtrvTable.getColumnModel().getColumn(0);
            rtrvTable.removeColumn(0);
            System.out.println(temp.getWidth());
            rtrvTable.repaint();Is there a way only to hide it? if I can set the with to very nerrow - that can be good enough I think....

  • JTable row selection

    What technique would you recommend to programmatically select one or more rows in a basic JTable?

    I used addRowSelectionInterval to get multiple selections. Your note directed my attention to the proper method(s). Naturally I overlooked it on several occasions. Thank you DrClap.

  • How to capture row selection in ALV output List

    Hi experts,
    I am displaying some output using ALV function module. My requirement is i have to capture how much rows user has selected in the output list, based on this information i have to perform some actions.
    Please help me
    Regards,
    Sachin

    Hi Sachin,
    For this first you have to define a variable in your internal table of type c with length 1 and then while building the layout of the ALV, you have to pass this variable name to the layout field BOX_FIELDNAME.
    Now when you select a particular row, then the corresponding field in your internal table willl be marked with X. So, for further processing, you can just loop through the table where 'BOX = 'X' and proceed.
    For Example:
    *      Structure for output details
    TYPES: BEGIN OF gs_output.
            INCLUDE STRUCTURE zas_water_qlty_rep.
    TYPES: selected(1) TYPE c,
           END OF gs_output.
    DATA: object_tab            TYPE STANDARD TABLE OF gs_output.
    CONSTANTS: lc_selected(8)             TYPE c VALUE 'SELECTED'.
    lw_layout-box_fieldname     =   lc_selected.    "Field for checkbox
    * Local workarea
      DATA: lw_layout  TYPE slis_layout_alv.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_buffer_active          = gc_x
                i_bypassing_buffer       = gc_x
                i_callback_program       = lv_repid
                i_callback_pf_status_set = g_form_set_pf_stat
                i_callback_user_command  = lc_uform
                i_structure_name         = lv_zas_water_qlty_rep
                is_layout                = lw_layout
                it_fieldcat              = g_fieldcat_tab[]
                it_events                = g_events_tab[]
                it_event_exit            = g_event_exit_tab[]
           TABLES
                t_outtab                 = p_object_tab
           EXCEPTIONS
                program_error            = 1
                OTHERS                   = 2.
    Hope this helps.
    Regards,
    Phani.

  • How to enable row selection conditionally  in ADF 11g Table

    Hi,
    i am using ADF 11g.
    My use cae is:
    we need to display a table component in which only those rows that have a particular value in one of its columns should be selectable, other rows should be viewable but not selectable.
    That is, to say only those rows should be displayed as selectable in which the user name column is having the value same as the logged in user, suppose. And all the other rows having user name other than logged in user should be viewable , but not selectable for the user.
    I know in ADF 10.1.3 it is possible to conditionally enabling selection of rows in af.table by using "selection"-facet. But with 11g there is no such table facet.
    Does anyone have some idea how to do it in 11g?
    Thanks

    Frank,
    thank for your suggestion.
    so i tried to use clientLister like this:
    selectMatCat = function(event) {
    var matCatTable = event.getSource();
    rwKeySet = event.getAddedSet();
    for (rowKey in rwKeySet) {
    firstRowKey = rowKey;
    break;
    var cellhandler = matCatTable.findComponent("matCatCode", firstRowKey);
    if (cellhandler != null) {
    alert (cellhandler.getValue());
    event.cancel();
    but the row in which cellhandler != null is still selected so that i can get its value on the sever side by using code like : "matCatTable.getSelectedRowData()".
    I also noticed that the selection event will not automatically notify the server so the event.cancel() seems like not make so much sense.
    Any suggestion?
    Thanks.
    Peng

  • Disable DataGrid row selection for a column?

    Hi,
    I have a DataGrid with a CheckBox in one column. When the CheckBox itself is clicked, or any point in the CheckBox column
    is clicked, I *don't* want the grid row selected. IOW, row selection should be disabled for the column. How to get this behavior?
    Thanks, Garry

    Hi All,
    I do have almost similar requirement where I have image overlay-ed on row, on whose click a context menu should appear but row should not get selected.
    Row selection should happen if user clicks elsewhere on that row (apart from overlayed image).
    I tried below lines in MouseClick event listeners.
    event.stopImmediatePropagation();
      event.stopPropagation();
    Above lines stopped itemClick event but didnt prevent the row selection.
    Regards,
    Pavan

  • Using row selection in ALV using class cl_salv

    Hi,
    how to use row selection by using cl_salv classes...
    I need to display scarr table in the basic list in ALV wthout using screens and function modules...
    On multiple selection of carrid from ALV, need to display flight details from sflight.
    Also how to get the selection buttons for corresponding rows.
    NOTE : Using class cl_salv*
    Thanks,
    Siddarth

    You may need to look into Rich's example code by the following thread
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/cda3992d-0e01-0010-90b2-c4e1f899ac01

  • How to delete the selected rows in a JTable on pressing a button?

    How to delete the selected rows in a JTable on pressing a button?

    You are right. I did the same.
    Following is the code where some of them might find it useful in future.
    jTable1.selectAll();
    int[] array = jTable1.getSelectedRows();
    for(int i=array.length-1;i>=0;i--)
    DefaultTableModel model = (DefaultTableModel)jTable1.getModel();
    model.removeRow(i);
    }

  • How to set special rows in jtable not selectable

    Hello programmers,
    anybody knows how to set special rows(p.E. row 0) in jtable not selectable.
    in advance thanks for your answers

    table = new JTable(...)
         public void changeSelection(int row, int column, boolean toggle, boolean extend)
              if (row == 0)
                   return;
              else
                   super.changeSelection(row, column, toggle, extend);
    };

Maybe you are looking for

  • Problem with check_changed_data

    hello I have added a checkbox and a button to a ALV Grid report. When the checkbox is ckecked and the button is pushed, the record with the checkbox used for further processing. I have been searching thru the SDN and it looks like I need to use the "

  • E mail address of customer

    Hi All, Can any one please guide me in which table the e-mail address of the cusotmers are stored .. I need to display on the report output with the details of the customer and the email address.. Please help me Thanking you in advance, Sandhya

  • .avi in a mac platform

    Hi, Can anyone tell me why .avi files work so well on a PC and not so well with FCP and Apple? To play .avi, you need to play them through VLC on a mac. When video editing on Adobe Premiere Pro on a PC, the files created are .avi which doesn't seem t

  • Blinking images and messageBox colors

    I am looking for the most efficient way to create an image (such as a .gif or .jpg) that blinks for a specified amount of time. I tried to do something with the setTimeOut method, but Adobe doesn't seem to like it. I would also like to change the col

  • In old version, my tabs were saved when I closed; now I am warned that I am closing tabs, but no saving....WHAT HAPPENED TO THAT LOVELY FEATURE?

    I think I have said. When I close with Firefox 4, I no longer get to keep my tabs for the next time I start up. I think your new version lost it, because it worked until the moment I upgraded.