Check Box in JTable Header Changes

Hi All,
In JTable, we have JCheckBox as header. And respetive data also check box's (new Boolean() objects) i have given. When i select header check , all the data check boxes are getting selected. Later if unselect any data check box, Header check box should be deselected. I am not able to deselect Header check box, if the user unselect any data check box.
So Please send sample program on this. And please try to solve my question.
Thanks to All
Mohan

Cross-post: http://forum.java.sun.com/thread.jspa?threadID=5202809

Similar Messages

  • Check box - "Bid May be Changed"

    Good evening,
    What does it mean:
    Check box - "Bid May be Changed"?     (it is in the bid invitation)
    Alexey

    Hi,
    If you select that check box in the Bid invitation header,the bidders can make changes to the Bids after you change the Bid invitation(before accepting/rejecting the Bids) i.e. allow bidders to submit new bids after your  changes  in the Bid invitation.
    BR,
    Disha.
    Do reward points for  useful answers and close the thread if your query is answered.

  • Check box  in ALV Header for selection

    Hi,
    I'm working on ALV in ABAP web dynpro. We have a requirement to check some rows and based on the selection a FM should be executed.
    I've used checkbox in the column for selection. Is there anyway to use a check box (or any element)  in the column header and use that to select all.
    I checked the ALV column header class documentation but didnt find anything that allows UI elements in header.
    Any workaround to tackle this?
    Thank you,
    Vasu

    Hi Thomas,
    I've already done that (in toolbar).  Checking if there is some hidden option that I missed to do this. Looks like there isn't

  • Selecting, Deselecting check boxes in JTable

    Hi,
    I have a JTable with 5 columns (First 4 are String and the last one in Boolean (ie., JCheckBox). I have tow buttons "Select All" and "Deselect All" below the JTable. I need to make all check boxes enabled if I click the button "Select All" and vice versa if I click "Deselect All". How do I do this. Please help me.
    Thanks
    Subbu

    hi,
    can you please help me? I have to make a table rather Ive made a table and my program search a list of files from a folder and populate different colums and rows. now I want the user to select the names and then selected files will be deleted.
    I am unable to achieve the proper GUI. ive made a JTable but the cells are editable. i dont know about TableModel and tried my level best to understand but failed to implement. when I try to add JCheckBox object in rows and columns the text representation of the GUI appears in the row rather then the actual Object. please guide me how to add JCheckBoxes into the rows and columns? how make cells uneditable? and how to give columns headings? I will be highly grateful.
    cheers
    seenan

  • Drop-down list of check-box options with header.

    Okay, I'm not sure if this is actually possible but I shall ask anyway. Partially because I have limited FP real estate and also because I think this is relatively easy method for the user to use, I have come up with the following idea:
    I want something that looks similar to a menu ring when not selected, displaying the text 'Plots'. Then, when it is clicked a list/menu opens downwards (as opposed to the default operation of menu rings). In this list/menu will be an element for each plot that is displayed on an XY Graph. Each element will contain a check-box (control) and a string (indicator). The strings will each display their respective plot name. The user can then click on the list/menu/thing to show the elements for the plots, and can check or uncheck however many they wish. The idea is that whichever plots are checked will be the ones displayed on the XY Graph.
    Firstly, have I explained this well enough, and secondly, is it possible?
    Thank you.
    James
    Never say "Oops." Always say "Ah, interesting!"
    Solved!
    Go to Solution.

    Just to make sure I wasn't leading you down the garden path, I messed around a little and came up with the following two vi's (LV 8.5)
    Load  Custom Ring Main.vi, run it, and try selecting the ring list.
    Hope this helps! 
    Thoric (CLA, CLED, CTD and LabVIEW Champion)
    Attachments:
    Custom Ring Main.vi ‏24 KB
    custom_ring_subvi.vi ‏37 KB

  • JTable - Check box in column header with sorting

    Hello
    I have 3 problems/questions.
    1. When adding sorting to a table with
    setAutoCreateRowSorter(true);and you click on a column header, normally a sorting arrow will appear, and indicate in what direction its sorting,
    but in the column head with the checkbox, even though the sorting works, the arrow will never appear. Is there anyway to fix this?
    2. Is there anyway to get the checkboxes in the table cells to be aligned left (I dont mean the columnheader checkbox, but the ones below)?
    3. When you click on the columnheader to either sort or check the checkbox, you will have to wait about a second between each click, or else it won't react and won't sort. sometimes you will have to click twice for it to react. If you click a lot of times fast, then it won't react until you stop for a second, and click again, though it will react only on the first click, but not the secont, third, fourh, and so on, until you stop for a second. Is there anyway to fix this, or atleast make it have a better reaction time?
    This is the code for creating the table:
    public class Example extends JFrame{
        private Container container;
        private JTable exampleTable;
        public Example(){
            container = getContentPane();
            ExamleTableModel examleTableModel = new ExamleTableModel();
            exampleTable = new JTable(examleTableModel);
            TableColumn tc = exampleTable.getColumnModel().getColumn(0);
            tc.setCellEditor(exampleTable.getDefaultEditor(Boolean.class)); 
            tc.setCellRenderer(exampleTable.getDefaultRenderer(Boolean.class)); 
            tc.setHeaderRenderer(new CheckBoxHeader(new MyItemListener()));
            container.add(new JScrollPane(exampleTable), BorderLayout.SOUTH);
            exampleTable.setAutoCreateRowSorter(true);
            setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );       
            this.pack();
            setSize(500,500);
            setVisible(true);
        }This is the code for the checkboxheader:
        class MyItemListener implements ItemListener 
                public void itemStateChanged(ItemEvent e) { 
                    Object source = e.getSource(); 
                    if (source instanceof AbstractButton == false) return; 
                    boolean checked = e.getStateChange() == ItemEvent.SELECTED; 
                    for(int a = 0, b = exampleTable.getRowCount(); a < b; a++) { 
                        for(int c = 0, d = exampleTable.getRowCount(); c < d; c++) { 
                            if(exampleTable.getColumnName(c).equals("")){
                                exampleTable.setValueAt(new Boolean(checked),a,c);
        class CheckBoxHeader extends JCheckBox 
            implements TableCellRenderer, MouseListener {
            protected CheckBoxHeader rendererComponent; 
            protected int column; 
            protected boolean mousePressed = false; 
            public CheckBoxHeader(ItemListener itemListener) { 
                rendererComponent = this; 
                this.setHorizontalAlignment(JLabel.LEFT);
                rendererComponent.addItemListener(itemListener); 
            public Component getTableCellRendererComponent( 
                    JTable table, Object value, 
                    boolean isSelected, boolean hasFocus, int row, int column) { 
                if (table != null) { 
                    JTableHeader header = table.getTableHeader(); 
                    if (header != null) { 
                        rendererComponent.setForeground(header.getForeground()); 
                        rendererComponent.setBackground(header.getBackground()); 
                        rendererComponent.setFont(header.getFont()); 
                        header.addMouseListener(rendererComponent); 
                setColumn(column); 
                rendererComponent.setText("");
                setBorder(UIManager.getBorder("TableHeader.cellBorder")); 
                return rendererComponent; 
            protected void setColumn(int column){this.column = column;} 
            public int getColumn(){return column;} 
            protected void handleClickEvent(MouseEvent e) { 
                if (mousePressed) { 
                    mousePressed=false; 
                    JTableHeader header = (JTableHeader)(e.getSource()); 
                    JTable tableView = header.getTable(); 
                    TableColumnModel columnModel = tableView.getColumnModel(); 
                    int viewColumn = columnModel.getColumnIndexAtX(e.getX()); 
                    int column = tableView.convertColumnIndexToModel(viewColumn); 
                    if (viewColumn == this.column && e.getClickCount() == 1 && column != -1) { 
                        doClick(); 
            public void mouseClicked(MouseEvent e) { 
                boolean active=true;
                JTableHeader header = (JTableHeader)(e.getSource()); 
                switch (e.getID()) {
                case MouseEvent.MOUSE_CLICKED:
                case MouseEvent.MOUSE_PRESSED:
                case MouseEvent.MOUSE_RELEASED:
                    JTable tableView = header.getTable();
                    TableColumnModel columnModel = tableView.getColumnModel();
                    int viewColumn = columnModel.getColumnIndexAtX(e.getX());
                    int column = tableView.convertColumnIndexToModel(viewColumn);
                    Rectangle bounds = tableView.getCellRect(-1, column, false);
                    if (e.getX() > bounds.x + 16) { // only if one the checkbox
                        if (e.getID() == MouseEvent.MOUSE_CLICKED) {active = false;}
                    }else{active=true;}
                if(active){
                    handleClickEvent(e); 
                    ((JTableHeader)e.getSource()).repaint();   
            public void mousePressed(MouseEvent e){mousePressed = true;} 
            public void mouseReleased(MouseEvent e){} 
            public void mouseEntered(MouseEvent e){} 
            public void mouseExited(MouseEvent e){} 
    }If you want the code for the ExamleTableModel, I will post it if you ask (having trouble with the character limit).

    What are you supposed to cast it to? I might have tried to cast it to something wrong.
    I tried
    TableCellRenderer tcr = table.getDefaultRenderer(Boolean.class);
    ((DefaultTableCellRenderer)tcr).setHorizontalAlignment(SwingConstants.LEFT);and that gave me a ClassCastException. But I might have been trying to cast it to the wrong thing.

  • Check Box in Header of ALV GRID only............

    Hi Experts,
                   Can anyone help me out... in keeping the Check box at the Header Level.....
    This requirement is in the copy of the standard transaction "ME2N". 
    1. In ME2N when you click on the Chage Layout button of ALV grid
    and choose "Sorting" tabe.
    2. Add any 3 fields say 1. Vendor/Supply plant 2. Purchasing group and 3. Purchasing document in the Sort criteria and choose accending order radio button and check box in the sum .
    3. Now click on the Displayed Column tab and remove the above 3 fields from the Displayed colums and add it column set
    4. Now report shows the heirarchial one in the sorting manner.
    5. I want the Check Boxes at all levels both in the header and the item level.
    When I click on the Header level check box all the item level check box should get checked. When I add the check box in the field catalog I am able to see the check box in the item level only because only item level data appears in the internal table and Header level is displayed based on the ALV grid sorting option and that row records are unknown in the internal table.
    Is there some thing which I can do to get the check box at the header level retaining all the functionality of ME2N and ALV GRID.....
    It would be great help if some one solves me this issue... Points will be awarded.
    Br,
    Laxmi.

    Hi Bharath,
               Thanks for your response. Select ALL already existing... My requirement is not to get the whole report records selected at  particular level all items and header should get selected. Say for example  I have Vendor2 i.e,  vendor 1 and vendor2. So in the Vendor 1 i will have Purchasing group1 , Purchasing document 1 and say 10 items under Purchasing document. say same as like in Vendor2. So if Click on the Vendor1 all the sub items of it have to selected so that I can perform further action only for these items not for the enter items of the report.
    Br,
    Laxmi.

  • Acrobat 9.1  Mac How do you change from Radio buttons to Check boxes?

    I have a DMV Form I Downloaded and had to convert to PS then back to PDF (written originally on PC Acrobat was in XML format).
    So on new form, I am able to add fields. I used the the Forms manager to automatically create the fields. Fields that were made Radio Buttons should have been Check boxes. How do change the Radio buttons to check boxes. There are a lot of them and I don't wish to have to re-key them in.
    Suggestions?

    Well when I click on the box it shows a Check mark in the box. That exactly what I need because in the instructions it requires a Check mark in each of the check boxes. Normally the Med form is sent as a paper copy from DMV every two years.
    Also another Tip. A PDF that has XML Content. (PC Acrobat Version).
    If you want a usable PDF on Mac and get rid of the XML do the following:
    Open the XML Based PDF on Mac Acrobat 9.X .
    Now choose export and save as Postscript File (.ps).
    Now locate and drop on Distiller 9.X.
    When PDF created will be a Pristine exact replica of the XML file except Mac Acrobat can edit and create forms with it.

  • Device preferences dialog box is too narrow and cuts off check boxes - can't change synch prefs?

    In itunes - preferences - devices dialogue box is too narrow - can't see check boxes - hence can't change synch settings. Have checked resolution and text size - both set at smallest.

    Are you on Windows or Mac?
    Look here to see where your Lightroom preferences are located on your system, and make absolutely certain that the user running LR has permission to read and write to that folder.
    Hal

  • Adding check box in the transaction xd02

    hi friends,
      My requirement is to add a check box in the customer change : contact person details standard screen in the transaction xd02.
    can any one please give me the suggestions for that?

    when u find the BADI name go there and add a sub screen with the element you want to put in there. activate the BADI. your task is done.

  • How to add  ComboBox in Jtable Header

    Hello everyone,
    I want to add a Combox box in JTable Header .Basically it works as central access to whole table e.g. by selecting delete row in combo box then it should delete the current selected row.If somebody has any idea please share it.
    Thanks in advance.

    The individual headers are not Swing components and therefore do not respond to mouse events in the same way as Swing components. Why don't you just have a popup menu that is positioned over the currently selected row? If you want to apply an action to all selected rows then have a set of buttons placed above the table header.

  • Disable the check box

    Hi All,
    I have a requirement in which based on the profile option user should be able to change the value of check box.
    Name of profile option is acces_level. In this user level profile option two values are possible 'User' or 'Administrator' and there are two check boxes cb1 and cb2. I want that cb2 should be available only to the user, those have value of profile option as 'Administrator'. cb1 will be available for all.
    Thanks in advance.
    Looking forward onn this.

    I used now
    declare
    nProp varchar2(20);
    BEGIN
    nProp := fnd_profile.value('ACCESS_FOR_WISPER_PART_RESEND');
    if nProp = 'ADMINISTRATOR' then
    set_item_property('XXINFC_WISPER_PARTS_MASTER.INSPECTION_FLAG', enabled, 'property_true');
    else
    set_item_property('XXINFC_WISPER_PARTS_MASTER.INSPECTION_FLAG', enabled, 'property_false');
    end if;
    END;
    I am writing this in WHEN-NEW-FORM-INSTANCE trigger at data block level.
    Now there is only one problem. In the form I am displaying 15 values. All 15 values have there respective check boxes. Now except first check box all other check boxes are disabled. Do you have any clue why the first cbox is not disabled. There is one more thing when profile option is set with value USER (Now it should allow to update the check box) then If I change any cbox then it does not allow me to change any other check box.
    Looking forward for you reply.

  • Captute the check box and display

    hi,
    In a report program se38, with the output I've displayed the check boxes before every line item, I need to keep a check box in the header row and if I check this one all the check boxes of the line items must be checked and I need to capture the particular line items if checked manually and randomly.
    i did not use grid display its a simple display with write statements.
    (in short if the first(header) check box is checked need to check remaining and need to process the check box itmes if checked as above and manually)
    thanks and regards with rewards later on

    Hi,
    Check this sample code...
    DATA: t_lineitem TYPE TABLE OF char1.
    DATA: s_lineitem LIKE LINE OF t_lineitem.
    DATA: v_header,
          v_index TYPE syindex.
    START-OF-SELECTION.
      WRITE: / 'Header check box',  v_header AS CHECKBOX.
      SKIP 2.
      DO 10 TIMES.
        s_lineitem = sy-index.
        WRITE: / 'Line item-', sy-index , s_lineitem AS CHECKBOX.
        APPEND sy-index TO t_lineitem.
      ENDDO.
    AT LINE-SELECTION.
      READ LINE 1 FIELD VALUE v_header.
      DO .
        v_index = sy-index + 2.
        READ LINE v_index FIELD VALUE s_lineitem.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
        s_lineitem = v_header.
        MODIFY CURRENT LINE FIELD VALUE s_lineitem.
      ENDDO.
    Thanks
    Naren

  • About gr message check box in me21n

    Please any one can explain the purpose of the field gr message check box in the header part in the delivery invoice tab page while creating purchase order t-code me21n
    regards and thanks
    satya

    HI.
    Sathya
    We are required this same scenario
    Can u please know how to do GR message setup..
    How u did it.
    Regards
    Sk

  • IF one checked box in the same PERNR is marked, mark the rest of them?

    Hi to everybody!
    I've an ALV with checked boxes, now, when the user check  one check box of one PERNR I need to mark all the check boxes of that PERNR...for example
    CHECKBOX                 PERNR                    DATA
          ◘                             12345                    555.74
          ◘                                                             5552
          ◘                                                           142,55
          ◘                              5214                       23
          ◘                                                             2522
    For example, when the user check the first box, (12345) the next check boxes until the PERNR change must be selected, How can I make this?
    Thanks a lot
    Regards,

    I did the same for VBELN, and it working for me, Only thing is you need to generate some action when you check the checkbox. press some button  and see how it works.
    REPORT ztest_alv_check MESSAGE-ID zz .
    TYPE-POOLS: slis.
    DATA: x_fieldcat TYPE slis_fieldcat_alv,
    it_fieldcat TYPE slis_t_fieldcat_alv,
    l_layout TYPE slis_layout_alv,
    x_events TYPE slis_alv_event,
    it_events TYPE slis_t_event.
    DATA: BEGIN OF itab OCCURS 0,
    vbeln LIKE vbak-vbeln,
    posnr LIKE vbap-posnr,
    chk(1),
    END OF itab.
    SELECT vbeln
    posnr
    FROM vbap
    UP TO 20 ROWS
    INTO TABLE itab.
    x_fieldcat-fieldname = 'CHK'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 1.
    x_fieldcat-input = 'X'.
    x_fieldcat-edit = 'X'.
    x_fieldcat-checkbox = 'X'.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'VBELN'.
    x_fieldcat-seltext_l = 'VBELN'.
    x_fieldcat-hotspot = 'X'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 2.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'POSNR'.
    x_fieldcat-seltext_l = 'POSNR'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 3.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program      = sy-repid
        is_layout               = l_layout
        i_callback_user_command = 'USER_COMMAND'
        it_fieldcat             = it_fieldcat
      TABLES
        t_outtab                = itab
      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.
    *&      Form  USER_COMMAND
    *       text
    *      -->R_UCOMM      text
    *      -->RS_SELFIELD  text
    FORM user_command USING r_ucomm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield.
      DATA: gd_repid LIKE sy-repid, "Exists
      ref_grid TYPE REF TO cl_gui_alv_grid.
      IF ref_grid IS INITIAL.
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
          IMPORTING
            e_grid = ref_grid.
      ENDIF.
      IF NOT ref_grid IS INITIAL.
        CALL METHOD ref_grid->check_changed_data .
      ENDIF.
      LOOP AT itab WHERE chk = 'X'.
        itab-chk = 'X'.
        MODIFY itab  TRANSPORTING chk WHERE vbeln = itab-vbeln .
      ENDLOOP.
      rs_selfield-refresh = 'X'.
      BREAK-POINT.
    ENDFORM. "USER_COMMAND

Maybe you are looking for