How to disable JTable Column Dragging (only single column)

How could i disable a single column from being dragged in JTable?
I need to fix the first column from being dragged in JTable and all other columns except the first can be dragged. how would i accomplish this task ?
well, i know how to fix all column in jtable from being dragged using
table.getTableHeader().setReorderingAllowed(false);But dont know how to fix only a single column. is there any method for doing this. or i have to implement any other logic?
Please help me !
Thanks

The question is why do you have this requirement. I figure if the user wants to reorder the colum, let them, the table won't break.
Maybe something like this would be acceptable:
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
public class FixedColumnScrollPane extends JScrollPane
    public FixedColumnScrollPane(JTable main, int fixedColumns)
        super( main );
        //  Use the table to create a new table sharing
        //  the DataModel and ListSelectionModel
        JTable fixed = new JTable( main.getModel() );
        fixed.setFocusable( false );
        fixed.setSelectionModel( main.getSelectionModel() );
        fixed.getTableHeader().setReorderingAllowed( false );
//        fixed.getTableHeader().setResizingAllowed( false );
        fixed.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
        main.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
        //  Remove the fixed columns from the main table
        for (int i = 0; i < fixedColumns; i++)
            TableColumnModel columnModel = main.getColumnModel();
            columnModel.removeColumn( columnModel.getColumn( 0 ) );
        //  Remove the non-fixed columns from the fixed table
        while (fixed.getColumnCount() > fixedColumns)
            TableColumnModel columnModel = fixed.getColumnModel();
            columnModel.removeColumn( columnModel.getColumn( fixedColumns ) );
        //  Add the fixed table to the scroll pane
        fixed.setPreferredScrollableViewportSize(fixed.getPreferredSize());
        setRowHeaderView( fixed );
        setCorner(JScrollPane.UPPER_LEFT_CORNER, fixed.getTableHeader());
    public static void main(String[] args)
        //  Build your table normally
        JTable table = new JTable(10, 8);
        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        JScrollPane scrollPane= new FixedColumnScrollPane(table, 1 );
        JFrame frame = new JFrame("Table Fixed Column Demo");
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        frame.getContentPane().add( scrollPane );
        frame.setSize(400, 300);
        frame.setVisible(true);
}Or maybe you should be using a Row Header. A row header is like the column header of JTable. It remains fixed on the left side of the scroll pane. Search the forum for examples using "setrowheaderview".

Similar Messages

  • How to disable/enable the cells for editing column wise in JTable in java?

    Hi All,
    Can any one tell me how to disable the cells for editing by column wise in JTable?
    Here depending upon the radio button selected, I need 2 disable some columns for editing
    and enable some columns for editing?
    how can I do tat using JAVA?
    Any sample code is of great help to me.
    Thanks in Advance

    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
    ~

  • How to identify missing records in a single-column table?

    How to identify missing records in a single-column table ?
    Column consists of numbers in a ordered manner but the some numbers are deleted from the table in random manner and need to identify those rows.

    Something like:
    WITH t AS (
               SELECT 1 ID FROM DUAL UNION ALL
               SELECT 2 ID FROM DUAL UNION ALL
               SELECT 3 ID FROM DUAL UNION ALL
               SELECT 5 ID FROM DUAL UNION ALL
               SELECT 8 ID FROM DUAL UNION ALL
               SELECT 10 ID FROM DUAL UNION ALL
               SELECT 11 ID FROM DUAL
    -- end of on-the-fly data sample
    SELECT  '[' || (id + 1) || ' - ' || (next_id - 1) || ']' gap
      FROM  (
             SELECT  id,
                     lead(id,1,id + 1) over(order by id) next_id
               FROM  t
      where id != next_id - 1
    GAP
    [4 - 4]
    [6 - 7]
    [9 - 9]
    SQL> SY.
    P.S. I assume sequence lower and upper limits are always present, otherwise query needs a little adjustment.

  • How to concatenate two colums into one single column

    I need some ideas to concatenate two different columns into one single column using a set of distinct values.
    For Example,
    Customer Product Number
    xyz A 1
    xyz B 2
    xyz B 1
    AAA C 7
    AAA A 1
    The result should look like this,
    Customer Value
    xyz A1 B2 B1
    AAA C7 A1
    How would I group this into once value ?
    Thanks in advance ...

    Tom's discussion of writing your own aggregate routines
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:2196162600402
    starts off with a link to the 8i alternatives
    "see
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:229614022562
    for 8i methods (not aggregates)"
    Unforutnately, it's a lot more work in 8i.
    Justin

  • Displaying 2 columns in a single column using HTML section of reports.

    Hi Team,
    I have a requirement in which we need to display 2 columns in the same column of OBIEE report. At present we have 2 columns as 2 different columns.
    For example if i have a column A which is used as @A in html section i need the new column to have @A + @B where B is another column in database.
    Can i concatenate 2 columns in a single column ?
    Thanks,
    Ritesh

    first select column 1 and column 2 in criteria.
    go to reaults are add narrater view.
    in narrater view type.
    @1@2[br/]
    set number of rows
    this should work in narrator.
    Edited by: user10615659 on May 20, 2013 4:30 PM

  • Combining two columns into a single column

    Hi,
    I have a VC Iview which displays the data of a query in a table .
    Output in a Table    
    ......................<<Quantity>>               <<Unit>>                     <<Amount>>               <<Currency>>
    &&Sales&&                                 
    Is it possible in VC to combine "Quantity" column and "unit" column to a single column say "Quantity"
    similarly "Amount" column and "currency" column to a single column"Amount"
    I.e i wanted to show the values in a single column some thing like this:
    &&Sales:&&                     <<120 Kg>>                                            <<500 Dollars>> ( 2 columns )
    Instead of( 4 columns) :
    &&Sales :&&           << 120>>              <<Kg>>                <<500>>                           <<Dollars>>
    Thanks
    P.Navakanth

    Hi,
    You could hide your actual columns for Quanity and unit and create one more column of type expression box in your table that will concatenate the value of quantity and unit.
    Regards,
    Murtuza Kharodawala

  • How to disable JTable column?

    Hi! this is archana. Pls suggest me how to disable columns of a table except one, so that no other one can modify its cell values.
    Help me.

    Hi
    i dont know whether u r using TableModel or not.
    if ur using a customTableModel for ur entries ..
    u can implement the following method of
    Table Model Interface.
    public boolean isCellEditable(int rowIndex,                              int columnIndex)then implement in such a way that ..
    compare always with ur column number and return false.
    as follows.
    public boolean isCellEditable(int rowIndex,                              int columnIndex){if (columnIndex ==4 )return false;elsereturn true;}above code makes all cells in the col=4 uneditable.
    even u rearrange the cols in table it works as per documentation.
    test this .. and let me know whether u succeeded r not.
    note: i think The implementation of this method in AbstractTableModel or defaultTableModel
    returns true always.
    thanks

  • Removing header, border for only single column in mx:DataGrid

    Hi,
        I am using Flex4 SDK and FlashBuilder4.
    I have a requirement where i need to remove column header, borders and grid lines for only last column in datagrid.
    It should look like there is no column present. This column will be used to show some icon for only selected row.
        Can any one suggest how to implement this. Please provide any sample if you can.
    Thanks

    hi Johnny, it was helpfull for me.
    With the given example i am still getting the grid line gaps with the selected row or hover color between verticle cells of the column.
    As gridlines can only be removed for complete datagrid not for a single column. is it possible ?
    Thanks

  • Disabling auto-complete in a single column or cell

    Dear All, I find the auto-complete feature in Numbers to be both time-saving but also dangerously stupid. Why should the default option be that when only one auto-complete entry is available, continuing to type your entry and pressing the return key automatically selects that entry? I would like to be able to turn off the auto-complete for a single column, but not for the rest, in which it works very well. So far I have not found any way to do this. It seems logical enough; we ought to be able to control which columns offer the auto-complete function and which don't.
    --Kevin

    R C-R wrote:
    It would be fine if a modifier key was able to disable the feature 'locally'.
    Perhaps Control-Return would work
    Control-Return is not a modifier key, it is an entry.
    I was thinking to the ability to press a modifier key when entering the first character in the cell. Pressing this key would tell to the entry parser: don't use the auto-completion.
    For my own use, I apply a drastic formula: the auto-completion feature is disabled.
    You are satisfied with the delete feature.
    I may understand that but the OP is not.
    So I try to imagine a possible enhancement.
    What I describe may help.
    For me it changes nothing.
    For you, it let you use the delete key.
    For the OP it would give him a neat answer.
    Yvan KOENIG (from FRANCE vendredi 8 août 2008 18:49:32)

  • How to have cascading lov for a single column in tabular form

    Hi,
    How to have a cascading lov for a single column in tabular form
    ie i have one employee name column
    in tabular form if v pressed add row then one row ll be added
    In my scenario based on first row value
    the second row value to be displayed
    To achieve this what i have to do ..
    Regards,
    Pavan

    READ Cascading select list on tabular form  and
    Oracle APEX 4.0: Cascading LOVs/Select Lists | Inside Oracle APEX by Patrick Wolf BLOG
    helps you,
    Pars.

  • How to remove dotted lines in a single column using javascript?

    Hi,
    In InDesign document,i want to remove the dotted lines in a single column using javascript.here i want to remove only the dotted lines has presented at the end of text in a cell.kindly help me if anyone has idea regarding this.
    Thanks in advance!
    Vimala L

    Hi,
    Those dotted lines have added in the document by manually. The dotted lines have presented in all the columns but in a single column i need to remove it.
    Thanks,
    Vimala L

  • How to disable listenPort? (SSL only)

    Hi,
              how can I disable listenPort and enable only SSLListenPort?
              Thanks.
              

    There is no way to do this in WLS 5.1. You can use firewalls to prevent access to
              this port...
              Darrel Cox wrote:
              > Did you ever get an answer to this question? If so, what was it? And can it be
              > done without bringing down the instance?
              >
              > Darrel
              >
              > Papaya Head <[email protected]> wrote:
              > >in wls5.1... thanks.
              > >
              > >Papaya Head wrote:
              > >
              > >> Hi,
              > >>
              > >> how can I disable listenPort and enable only SSLListenPort?
              > >>
              > >> Thanks.
              > >
              

  • Merge Two Columns in a Single Column

    Dear,
    Inputs
    Table1 |
    Col1 (Number) |
    1 |
    2 |
    3 |
    4 |
    5 |
    6 |
    and table 2
    Table2 |
    Col1 (Number) |
    7 |
    8 |
    9 |
    10 |
    11 |
    12 |
    No relation between the two tables
    I want to write a select statement that will result
    Column
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    No sorting is required, I just need to have all the values listed in a single column... How can I do?
    Thanks in Advance.

    If there is dup values between the two tables and you want get only unique, use UNION. If not UNION ALL as already stated.
    Nicolas.

  • Merge two column value in single column

    Team,
    I have a requirement where in I need to merge 2 column values in a single column.
    ex. I have Percent_complete column in my table. and my table has only one record.
    I need to query such that I need to store the values of percent_complete and (100- percent_complete) values in a single column.
    ex
    Percent complete has 30 value.
    I need to select 30 and 70(100-30) both in a single column.
    Thanks,

    SQL> select  *
      2    from  tbl
      3  /
    PERCENT_COMPLETE
                  30
    SQL> select  abs(grouping(1) * 100 - max(percent_complete)) percent_complete
      2    from  tbl
      3    group by rollup(1)
      4  /
    PERCENT_COMPLETE
                  30
                  70
    SQL> select  nvl(percent_complete,100 - max(percent_complete)) percent_complete
      2    from  tbl
      3    group by rollup(percent_complete)
      4  /
    PERCENT_COMPLETE
                  30
                  70
    SQL>
    SY.

  • How to disable JTable Column Dragging?

    cant figure out how to do this..thanks

    hi, i had the same problem, too. the only solution i could find was to override the
    moveColumn(int columnIndex, int newIndex) {}
    method in the TableColumnModel. if there is a nicer way to do this (like the hidden flag i did not find), i'd be interested in that solution as well ...

Maybe you are looking for

  • Error while running batch update statement

    Hi We are experiencing the below error while running the batch update statement where in the IN clause have more than 80,000 entries. The IN clause is already handled for max 1000 values so it has multiple or clause like update...where id in (1,2...9

  • Power Mac G4 FW800 system hangs every 30 to 45 mins.

    Hi everyone, I have a power mac G4 dual 1.25 FW800 machine running OSX 10.4.11. I have installed both Digital Performer 5.13 and Logic Pro 8.02 on this machine. I have also installed a PCI USB card by Allergo. This card is used mainly for all the ilo

  • Release strategy for PO on Payment terms..

    Dear friends, Is it possible to have Release strategy for PO on Payment terms..... I checked in CEKKO, no field availble for payment terms. Is there any other way.......... Plz help Rgds, Navin

  • Postings in Bal.Sheet. adj.1 F-44

    Hi All, I am trying to understand the reason behind the following posting in Bal.Sheet. adj.1 account which is 530103. When we try to clear the transaction with F-44 entries which are for previous years 2006,2007 etc. system is taking Bal.Sheet. adj.

  • Trying to learn as3

    i am getting the folloing errors 1067: Implicit coercion of a value of type Number to an unrelated type flash.display:DisplayObject. 1137: Incorrect number of arguments.  Expected no more than 1. my code cl_mc.addEventListener(MouseEvent.MOUSE_DOWN,