Jtable - disable mouse selection

hello,
i did like to disable row selection in a jtable by mouse.
in fact, the user should not be able to select rows in the table, but programmatily it should work.
any ideas?
thank you
greets
lukas

You could try removing all the MouseListeners from the table. I don't know what other functionality you would lose.
MouseListener[] listeners = (MouseListener[])table.getListeners(MouseListener.class);
for (int i = 0; i < listeners.length; i++)
     table.removeMouseListener( listeners[i] );

Similar Messages

  • JTable disable column selection

    Do we have a convenient way to disable the selection/focusing of a single column in a JTable while tabbing thorugh the tablecells?

    You can customize the tabbing by using the approach discussed in [Table Tabbing|http://www.camick.com/java/blog.html?name=table-tabbing].

  • JTable - Column swap disabling for selected columns

    Hi,
    In my JTable i want to disable the swapping of selected columns, table.getTableHeader().setReorderingAllowed(false); this disables the whole table swapping.
    Is there anyway to disable only selected column swapping?
    Thanks in advance.
    Yours,
    Arun

    I was able to disable the column swapping in all the ways, i.e. i've solved the problem that i've said in my previous post.
    The following are the scenario'scovered, if the user wants to disable swapping of 1st and 2nd column of a JTable
    1. Donot allow dragging of the 1st and 2nd column and
    2. If the user drag-drop 3 or 4 th column in place of 1st or 2nd column, then undo the swap operation by re-swapping the columns.
    Try the following example
    import java.awt.Point;
    import java.awt.event.MouseEvent;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.event.MouseInputListener;
    import javax.swing.plaf.basic.BasicTableHeaderUI;
    import javax.swing.table.JTableHeader;
    import javax.swing.table.TableColumnModel;
    public class FixedTableColumnsExample
        FixedTableColumnsExample()
            String[] columnNames = {"First","Last Name","Sport","# of Years","Vegetarian"};
              Object[][] data = {
              {"Mary", "Campione","Snowboarding", new Integer(5), new Boolean(false)},
              {"Alison", "Huml","Rowing", new Integer(3), new Boolean(true)},
              {"Kathy", "Walrath","Knitting", new Integer(2), new Boolean(false)},
              {"Sharon", "Zakhour","Speed reading", new Integer(20), new Boolean(true)},
              {"Philip", "Milne","Pool", new Integer(10), new Boolean(false)}
              JTable table = new JTable(data, columnNames);
            TableColumnModel columnModel = table.getColumnModel();
            EditableHeader test = new EditableHeader(columnModel);
            table.setTableHeader(test);  
            JFrame frame = new JFrame("Table Fixed Column Demo");
            frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            JScrollPane scrollPane = new JScrollPane(table);
            frame.getContentPane().add( scrollPane );
            frame.setSize(400, 300);
            frame.setVisible(true);
        public static void main(String[] args)
            new FixedTableColumnsExample();
    class EditableHeader extends JTableHeader
        public EditableHeader(TableColumnModel columnModel)
            super(columnModel);
        public void updateUI()
            setUI(new EditableHeaderUI());
    class EditableHeaderUI extends BasicTableHeaderUI
        boolean is1and2Swapped  = true;
        protected MouseInputListener createMouseInputListener()
            return new MouseInputHandler((EditableHeader) header);
        class MouseInputHandler extends BasicTableHeaderUI.MouseInputHandler
            protected EditableHeader header;
             public MouseInputHandler(EditableHeader header)
                 this.header = header;
             public void mouseDragged(MouseEvent e)
                 int draggedColumnIndex = ((EditableHeader)e.getSource()).getDraggedColumn().getModelIndex();
                 if(draggedColumnIndex != 0 && draggedColumnIndex != 1 )
                     super.mouseDragged(e);
                     is1and2Swapped = true;
                 else
                     is1and2Swapped = false;
             public void mouseReleased(MouseEvent e)
                 int draggedColumnIndex = ((EditableHeader)e.getSource()).getDraggedColumn().getModelIndex();
                 Point p = e.getPoint();
                 TableColumnModel columnModel = header.getColumnModel();
                 if(p.x < 0)
                     p.x = 0;
                 int index = columnModel.getColumnIndexAtX(p.x);
                 super.mouseReleased(e);
                 if((index == 0 || index == 1) && is1and2Swapped)
                   header.getColumnModel().moveColumn(index,draggedColumnIndex);
    }Is there anyother better way to do the swap disabling? If so please suggest me.
    This solution is having one disadvantage.
    Consider the following scenario,
    a) 1 and 2 are fixed columns.
    b) Move column 4 to 3rd position
    c) Move new 3rd column to 1st or 2nd column's position
    d) the new 3rd column is moving to position 4(its original position when the model was created) instead of position 3.
    This is because the TableColumModel is not updated properly. I'm working on that. Any Suggestions?
    Thanks
    Arun.

  • Is there a way to disable mouse acceleration in OSX Yosemite?

    i have used my dads iMac and MBP in the past and always noticed how bad the mouse response was in my opinion. Mind you, some people like the way the mouse responds in OSX and will probably have no idea what my issue is. That is mouse acceleration and the lack of option to disable it in the mouse settings panel. Here is a good explanation about what it is, also in the video is a visual example.
    "Mouse or cursor acceleration, to put it simply, makes the travel distance of your cursor on the screen reliant of the velocity of your physical mouse movement rather than just the distance that you move your mouse. So making one movement of the same distance at two different speeds will cause two different relative cursor movements, with quick movement causing the cursor to travel a greater distance."
    source:
    https://www.youtube.com/watch?v=16diwK6HWbI
    So the thing i want to accomplish, is making the physical mouse movement one-to-one with the cursor speed on the screen. As an example: moving my mouse 10 cm would always make my mouse on the screen go 1000 pixels, no matter how fast i move my mouse.
    I've had my mouse set up like that in windows and linux for quite some time now and i hope there is an easy way to set the mouse response like that in OSX as well.
    I want to make clear that this isn't just an issue in games where you want to have great mouse precision. I have become really accustomed to this way of mouse response in any type of application. So the problem lies not in any mouse settings of any game/program. The problem lies in how OSX translates physical mouse movement to cursor movement.
    Anyway, i ran into this issue about a year ago when i was using my dad's computer. i've had my own windows computer for some time now. An option to disable mouse acceleration in OSX Yosemite might have been implemented properly in the mean time. I have searched this community and found some old posts of people who had this same problem as me, but never read about any fix for it. The main reason i am asking this is because i am considering buying a Macbook.
    I'd rather not use any third party software, but if there is any out that that just works and is easy to use, let me know.

    Please don't be obnoxious to people like tbirdvet trying to help; nobody here owes you an answer, or anything else for that matter.
    Anyway, Yosemite seems to enable mouse acceleration by default. You can disable it to get a constant pixels pointer moves / meters mouse moved ratio by typing this in terminal:
         defaults write .GlobalPreferences com.apple.mouse.scaling -1
    you'll need to logout and log back in for changes to take effect. To restore the standard behaviour:
         defaults write .GlobalPreferences com.apple.mouse.scaling 2
    should do the trick.
    C.

  • How to disable the selection of "Title and logo URL of a SharePoint 2013 site" from browser

    how to disable the selection of "Title and logo URL of a SharePoint 2013 site" from browser or How can we able to set our custom default log to the sp2013 site using code.So that users are not allowed to change from browser again.
    Thanks &amp; Regards, Krishna

    Hi  Krishna,
    For your issue, you need to deploy a farm solution using HideCustomAction to hide site settings link. For example to hide “Title, description, and logo” link you can use below code:
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <HideCustomAction
    GroupId="Customization"
    HideActionId = "ProjectSettings"
    Location = "Microsoft.SharePoint.SiteSettings">
    </HideCustomAction>
    </Elements>
    Reference:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/92f002b7-0e9c-424e-836a-de40c4e5d81f/hide-option-from-site-settings-page-in-sharepoint-2010?forum=sharepointdevelopmentprevious
    http://blog.milanchauhan.com/2013/06/add-custom-section-in-site-settings.html
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • Webdynpro ABAP ALV in SAP ECC6 - EHP4: To disable Column Selection

    Hi All,
    We are using SAP ECC6 EHP4 and  for Webdynpro ABAP application, after each column a vertical white line is appearing, and I need to hide this..
    SAP suggested us to disable COLUMN SELECTION I have tried the below code but still I am not able to get this done..
    Can you please suggest the appropriate method to achieve the same.
    Code:
    * show tab COLUMN SELECTION in Settings page
    CALL METHOD wd_this->alv_conf_table->if_salv_wd_std_functions~set_column_selection_allowed
      EXPORTING value = ABAP_false..
    here alv_conf_table refers to CL_SALV_WD_CONFIG_TABLE.
    Thanks in advance.
    Thanks
    Srinivas
    Edited by: Srinivas Manchi on Apr 22, 2010 11:35 AM
    Edited by: Srinivas Manchi on Apr 22, 2010 1:06 PM

    You have to disable the DDic binding on the column before your override text will show up:
    data: l_ref_cmp_usage type ref to if_wd_component_usage.
      l_ref_cmp_usage =   wd_this->wd_cpuse_alv( ).
      if l_ref_cmp_usage->has_active_component( ) is initial.
        l_ref_cmp_usage->create_component( ).
      endif.
      data l_salv_wd_table type ref to iwci_salv_wd_table.
      l_salv_wd_table = wd_this->wd_cpifc_alv( ).
      data l_table type ref to cl_salv_wd_config_table.
      l_table = l_salv_wd_table->get_model( ).
      data l_column type ref to cl_salv_wd_column.
      l_column = l_table->if_salv_wd_column_settings~get_column( 'POSTING_DATE' ).
      data l_header type ref to cl_salv_wd_column_header.
      l_header = l_column->get_header( ).
      l_header->set_prop_ddic_binding_field(
        property =  if_salv_wd_c_ddic_binding=>bind_prop_text
        value = if_salv_wd_c_ddic_binding=>ddic_bind_none ).
      l_header->set_text( `Posting Date` ).

  • How to disable the Selection screens of LDB's ?

    Hi,
             How to disable the Selection screens of LDB's when we r using the predefined LDB for our executable pgm ? and how to include the predefined LDB  can u write the Code for including LDb or if possible give an example of a Pgm using a Predefined LDB?
    Thanks & Regards,
    Gopi.

    Hi Gopi,
    Go through the link,
    http://www.sapdevelopment.co.uk/hr/hrhome.htm
    Regards,
    Azaz Ali.

  • How to disable Multi-selection thing in slicer.

    Hello,
    I am using Slicer in Excel Sheet and i want to disable Multi-selection thing in slicer.
    Is it possible to throw an exception or doesn't allow to do a multiple selection in excel slicer using VBA or without?
    Quick help ll be appreciated  :)
    Thanks & regards,
    Gaurav Badhani.

    Thanks for your reply,
    I used below given code and it's working and i put this code on ThisWorkbook and calling on
     Workbook_SheetCalculate
    Workbook_SheetSelectionChange
    it's working fine but whenever i am selecting slicer value using CTRL key this code is not excuting coz system is not able to call events
    Kindly help me with the events or code coz i am using CTRL key for multi selection and whenever i am using CLRL key it's not working
    Please find below given code
     Dim scl As SlicerCacheLevel
        Dim oSlicer As Slicer
        Dim i As SlicerCaches
        Set i = ActiveWorkbook.SlicerCaches
        Dim oSi As SlicerItem
        Dim ItemsAllowed As Integer
        Dim cntItems As Integer
        ItemsAllowed = 1
        cntItems = 0
        Application.EnableEvents = False
        For Each oSi In ActiveWorkbook.SlicerCaches("Slicer_RC_Description").SlicerItems
             If oSi.Selected Then cntItems = cntItems + 1
            If cntItems > ItemsAllowed And oSi.Selected Then
                oSi.Selected = False
                MsgBox "Please select only one item"
                Application.EnableEvents = True
                Exit Sub
            End If
        Next oSi
    Also tell me what event i should use for ur code or how can i use code using CTRL key
    Thanks & Regards,
    Gaurav Badhani
    A

  • Tree control: How to disable the selection of a child item

    Hello everyone,
    Im having trouble with disabling the selection of a child item in a tree control. I dont know if its possible but havent found any answers on this forum regarding this issue.
    Example:
    Parent tag 1
        child item 1
        child item 2
    Parent tag 2
        child item a
        child item b
    What i would like to do is being able to select the parent tags but not the child items, because i use the name of the selected item in my program to determine which actions are allowed and those that are not. To avoid this problem i look at the first 4 letters of the name and this way i can determine if it is a parent tag or child item and take appropriate action. Im able to do this because the parent tags have fixed names. But even though nothing happens in software if i select a child item it still lights up, so for the user of the program it looks as if the child items is selected but the program doesnt do anything(because i made it that way). Thats why i want to be able to disable the selection of the child item or at least make the selection colour of the child item transparant so it doesnt look like it is selected.
    Can anyone help me with this problem, if there are parts of my question you dont understand, just ask.
    greetz
    Ynse.

    Muks,
    your last image disables the whole tree.
    To programmatically disables an item use ActiveItem.Disabled? property.
    Unfortunately this only has two states, Enabled and disabled (thus grayed).
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • How to disable the select options button, while audio is playing in the question template in captivate 8?

    How to disable the select options button, while audio is playing in the question template in captivate 8?

    Apologies for late reply.
    I mean "On Question screens audio keeps on playing even after we have selected an option or options depending on the question type and clicked Submit. How do we stop the audio on selecting an option?"

  • How do I disable auto select for the path selection tool?

    For the move tool you can choose to disable auto selection, auto select a group, or auto select a layer. By default though the path selection tool autoselects a layer. How can I disable autoselection?

    I can’t seem to reproduce what you describe.
    Please elaborate, possibly with the help of some screenshots.

  • Disable Mouse Right click inside Adobe Acrobat PDF plugin

    Hi All,
    We are rendering Adobe live cycle pdf file inside html object tag.
    I have disabled toolbar , navigation bar using navpanes=0&toolbar=0.
    But when mouse right click reenable the context menu again.
    So Is there any way to disable mouse righ click inside Adobe Acrobat PDF browser plugin?

    I had the same problem after updating Firefox to version 4.0 and Acrobat Reader to Version X. For me (Win XP) what solve the problem was deleting the Acrobat Reader Plugin (nppdf32.dll) in the Firefox plugin folder (C:\Program Files\Mozilla Firefox\plugins). So now there is only one Acrobat Reader Plugin left namely the one in the Acrobat Reader plugin folder (C:\Program Files\Adobe\Reader 10.0\Reader\Browser).

  • Mx|Tree disable hover, selection and background color

    Hello.
    I would like to know how can i disable the dhover, selection and background color.
    i don't need selection at all so if i can just disable the selection in a tree component (plus make the background color transparent) it would be great.
    thanks

    RTFM
    Use Tree's "selectable" property and "backgroundAlpha" style.

  • DISABLE MOUSE EVENT on jlabel

    Dear all,
    I have a jlabel on which i perform a click and the embbeded image switch between start and stop image.
    My problem consists in preventing from performing multiples click/or disabling mouse event while the application starts loading some parameters.
    switchViewLabel.addMouseListener(new MouseAdapter() {
                   public void mouseClicked(MouseEvent e) {
                        //it takes a long time
                                   onSwitchViewButtonClick();
    protected void onSwitchViewButtonClick() {
              System.out.println("onSwitchViewButtonClick");
              if (canGo) {
                   System.out.println("canGo");
                   canGo = false;
                   MainWindowPeer.getInstance().setCursorToWait();
                         //this action load parameter
                            CommandWindow.getInstance().switchView();
                         refreshSwitchViewButton();
                   MainWindowPeer.getInstance().setCursorToDefault();
                   canGo = true;
         } But on my console i have noticed :
    canGo
    onSwitchViewButtonClick
    canGo
    onSwitchViewButtonClick
    canGo.....
    It looks like we store mouse event anywhere and for each event we execute onSwitchViewButtonClick code and consume event.(it seems to not be asynchronous)....
    How to do ???
    Thanks for any helps..

    Dear all,
    yes i want to ignore mouse events until the processing is done.But how to perform process in separate thread and what is a semaphore.Is it possible to have much more explanation...
    Shall i do following code..
    mouseAdapter = new MouseAdapter() {
                   public void mouseClicked(MouseEvent e) {
                        SwingUtilities.invokeLater(new Runnable(){
                             public void run() {
                                  //switchViewLabel.removeMouseListener(mouseAdapter);
                                  onSwitchViewButtonClick();
                                  //switchViewLabel.addMouseListener(mouseAdapter);
              };Thanks you in advance...

  • Disabling complex selection button

    Hi Experts,
       In my select-options, based on the user ( sy-uname ), I am disabling the select-option-High value.
       i.e.      if screen-name = 'S_DATE-HIGH'.
                    screen-input = 0.
                 endif.
      But at the same time I need to disable the complex selection button also. It means that the user has to give only one input like parameter.
    How can I disable complex selection button.
    Thanks and regards,
    Venkat

    hi,
    please check this below code
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME  TITLE TEXT-027 .
    PARAMETERS: P_RADIO1 RADIOBUTTON GROUP RAD DEFAULT 'X' USER-COMMAND UCOM .
    PARAMETERS : P_KEY TYPE SYDATUM DEFAULT sy-datum MODIF ID MO1.
    PARAMETERS: P_RADIO2 RADIOBUTTON GROUP RAD.
    SELECT-OPTIONS: SO_BUDAT FOR BSIS-BUDAT MODIF ID MO2 .
    SELECTION-SCREEN END OF BLOCK B2.
    *--AT SELECTION-SCREEN OUTPUT STATMENTS--
    AT SELECTION-SCREEN OUTPUT.
      LOOP AT SCREEN.
         IF P_RADIO1 = 'X'.
           CHECK SCREEN-group1 = 'MO1'.
           SCREEN-INPUT = 1.
         ELSE.
           CHECK SCREEN-group1 = 'MO1'.
           SCREEN-INPUT = 0.
        ENDIF.
        MODIFY SCREEN.
      ENDLOOP.
      LOOP AT SCREEN.
        if P_RADIO2 = 'X'.
          CHECK SCREEN-GROUP1 = 'MO2'.
          SCREEN-INPUT = 1.
        ELSE.
          CHECK SCREEN-GROUP1 = 'MO2'.
          SCREEN-INPUT = 0.
       endif.
           MODIFY SCREEN.
      ENDLOOP.

Maybe you are looking for

  • ZenXtra: copying from Zen: "file unaccesib

    Hi, When copying from my Zen Xtra, after transfer of a couple of files in queue I receive an error: "file unaccessible..." and I cannot copy anything more unless I reconnect. Moreover Zen and the connection seems to be out of order (ie. not all field

  • In-database mining vs database efficiency - Trade-off?

    Can anyone please throw some light on how Predictive Analytics (Automated Analytics/KXEN) deals with database load/resource sharing when both analytical and operational workloads are executed? In other words - does in-database scoring impacts databas

  • Ping DB has failed and DB Permissions has failed, cannot connect to DB??

    Hello all, I am trying to install fatwire on my Windows 7 platform and after successfully installing my Oracle Server, my Weblogic server, and successfully deploying my CS application, I keep getting the following error during Test CS Configuration:

  • DNG converter don't work for some RW2-files

    Hi, i found out, that there ist now direct support from CS4 to my new Lumix LX5. :-( In  some forums i got the hint to use the free DNG converter. that works  for most of the files, but some rw2's it can't convert. yesterday i made  10 pictures and t

  • How can i istall the photocd plugin of photoshop CS3 to photoshop cs4 under windows7?

    How can i istall the photocd plugin of photoshop CS3 to photoshop cs4 under windows7? i had no problem to install under windows XP, but i do not know how and where to install the windows profiles and i am not sure, if i habe just ro move the .8bi fil