Resizing & dont drag column

How to do to a column in a Jtable cant drag and drop in a other column position.
And i need that these columns arent resizable.
Thanks

The methods you seek are found in the JTableHeader class.

Similar Messages

  • Dragging columns in a JTable

    how to drag columns in a JTable ?

    JTable myTable = new JTable(mymodel,myheaders);
    JTableHeader head =myTable.getTableHeader();
    //// this function will solve your problem
    head.setReorderingAllowed(true);

  • Dragging columns in JTable

    I am dragging a JTable column with my mouse. If I release the column, will an event be fired indicating that the column was dragged AND is now being released??
    The mouseReleased(MouseEvent e) in MouseListener() will just inform me of the release of the mouse button, it will not inform me whether this release of the mouse button has induced the release of a dragged column.
    The columnMoved(TableColumnModelEvent e) in TableColumnModelListener() will give me the coordinates of a column WHILE it is being dragged. It will not inform me if a column gets released.
    If no specific event exist to indicate the release of a dragged column, I guess I'll try to obtain the same result by combining both the mouseReleased method and the columnMoved method.
    Thanks in advance.
    Olivier

    try attaching MouseMotionListener as well as MouseListener to the table header. when mouse drag starts, make a boolean variable, say dragged true, and then in mouseReleased() method, check if dragged is true or not. if true, it'll meet your both the requirements.
    add this code to your code.
    private boolean dragged = false;
    private void addDragListener(JTable tableObj) {
         final JTable table = tableObj;
         MouseMotionAdapter motionListener = new MouseMotionAdapter() {
              public void mouseDragged(MouseEvent me) {
                   dragged = true;
                   TableColumnModel columnModel = table.getColumnModel();
    int viewColumn = columnModel.getColumnIndexAtX(me.getX());
    int column = table.convertColumnIndexToModel(viewColumn);
                   System.out.println("column " + column +" dragged");
         MouseAdapter mouseListener = new MouseAdapter() {
              public void mouseReleased(MouseEvent me) {
                        if(dragged) {
                             System.out.println("column released after dragging");
                             dragged = false;
         JTableHeader th = table.getTableHeader();
         th.addMouseMotionListener(motionListener);
         th.addMouseListener(mouseListener);
    hope this helps,

  • JTable resize of last column

    I've got a table with 2 columns, the tabel is inside a scroll pane. I want the first table column to be of fixed size and the second column to take up all of the viewports remaining width.
    I've setAutoResizeMode(JTable.AUTO_RESIZE_OFF) and getColumnModel().getColumn(0).setWidth(0), however, what method should I employ to determine resize, determine column 1's desired width based on the viewports width and set column 1's width?
    Thanks in advance,
    Jas

    The only thing I can think is that because there is no "NEXT COLUMN" to the one you are trying to resize it throws the ArrayIndexOutOfBoundsException. If you have 4 columns and you tell it to resize next column, and then you try to resize the right side of the 4 column it is trying to resize the next column, column 5, which does not exist and therefore throws the exception.

  • Resizing a particular column in a table

    Well, I know that my topic may seem stupid, but I can't find a way to resize the first column of my TreeTable. Here is what I've tried :
    treetable.getColumnModel().getColumn(0).setWidth(100);
    and it doesn't work at all !!
    please, ...
    delph :)

    Not a stupid topic. You have to have a phd in swing to understand column widths in JTable. there;s no guarantee that what I sugest will solve you problem though....
    Use TableColumn.setPreferredWidth(). You may have to create your own column model and implement the getPreferrredWith() method. Also make sure the Jtable.setAutoResizeMode(int mode) is set to what you need (I'm not sure if it makes any difference... but just in case)
    Good luck,
    Gilles

  • Data Grid - issues resizing width of columns and with data refresh and sort

    SQLDeveloper 1215 on Windows XP professional
    Database : various 9.2
    In the table data tab there are a few minor issues our developers have highlighted.
    1) There seems to be a minimum column width in the data display. This restricts flexibility in reviewing the data, esp. where the data length is less than the minimum column width.
    2) If a column is resized or the column order is changed and a refresh or a new filter is applied then the columns are restored to their original position and size making it frustrating to run more than one query via the GUI.
    3) There is no quick sort option by clicking on the column heading which would be useful.

    I am still seeing this minimum column width in SQL Developer production (v1467) and I haven't seen any other posts relating to this. I have seen this all of the grids that I have looked at, including all of the grid based sub-tabs for the Object tabs (ie Columns, Data, Indexes, Constraints, etc) and the SQL Worksheet results tab.
    It is very obvious with the Column Name and Data Type columns of the Table Columns tab - the Column Name column can be shrunk to truncate values but the Data Type column can only be shrunk to about the twice the width of the widest value.
    Can anyone in development provide any comments about why we have this minimum width and how the minimum width is actually calculated?

  • Resizable and drag & drop window

    Hi!
    I need to build a window with title bar and close button to
    display an internal movieclip (mc is in the same movie). Window
    must be custom resizable and drag & drop. I don' t want to use
    window component. Please, help me. Thanks in advance...

    Here.
    You can work out the rest of the kinks. Good Luck.

  • How to listen for resizing of JTable column

    Is there anyway to tell when the columns in a JTable are being resized by the user? I couldn't find any listeners or anything that will tell you when the user is dragging the column width with the mouse.
    Thanks.

    Use ColumnModelListener as shown below:-
              table.getColumnModel().addColumnModelListener(new TableColumnModelListener() {
                   public void columnAdded(TableColumnModelEvent e) {
                   public void columnMoved(TableColumnModelEvent e) {
                   public void columnRemoved(TableColumnModelEvent e) {
                   public void columnMarginChanged(ChangeEvent e) {
                   public void columnSelectionChanged(ListSelectionEvent e) {
              });

  • Adding resize handles to a rectangle to resize and drag in a canvas

    Hi
    I am having difficulty for the last couple days in getting a rectangle in java 2d to addshape handles to the corners which will allow me to resized the rectangle and then and dragged within the canvas using these handles. Also to get the shape on the canvas I will be clicking a button for the shape Rectangle to appear on the canvas in the first instance. I do not understand where I am going wrong.
    I am using the format of g2D.drawRect(10,10,50,50 ) for example to demonstrate my shape.
    Thanks in advance

    Search for
    draggable tjacobs01
    and
    resizeable tjacobs01
    these are my classes for doing what you're talking about. They work on components so you'll either have to switch your rectangles to components or adapt this code to non-component objects. It becomes more tricky because of the mouselistening.
    usage:
    Component c = ...
    new Draggable(c);
    new Resizeable(c);
    parent.add(c);

  • Removing the ability to drag columns

    In 11g the end-user has the ability to change the position of columns on a request... change the order, make them section headers etc.
    I want to remove that ability - any one been able to do this and can let me know how its done, please?
    Thanks - and 10 points to the first correct answer!!

    Hi User,
    Not possible for now.Open bug with Oracle,
    BUG:10222173 - ABILITY TO DISABLE DRAG AND SORT FUNCTIONALITY OF COLUMNS
    Rgds,
    Dpka

  • Drag column in JTable

    Hi,
    How can I protect the JTable for the user don�t press the mouse for drag the column position???
    thanks!!!!

    Try this:
    JTable objTable = new jTable();
    objTable.getTableHeader().setReorderingAllowed(false);

  • Is it possible to resize the row / column of a table at run time ?

    Hello All ,
    I want to make a table where the user have to put datas . But if some data exceeds the length of the column / row the user should have the ability to resize the column / row of the table just like we are able to do at the time of designing . Is it possible ??
    Thanks .
    Bibhu .

    Hi,
    If you select a cell in the table that cannot receive data, then the expand to fit will not be available.
    However if you select an object that is in the table (like a textfield) then the option of expand to fit should be available.
    Try experimenting with the options.
    Niall

  • Resize after dragging into another image

    This is my first post here. I have been a Photoshop user for years, but just upgraded to a new computer and CS5 Windows. While using CS2 I often would drag an image into another image and then resize it so that it looked the way I wanted in the new image. Now, when I drag an image into another, I can't resize it. What do I need to turn on or off. Files are the same format and bit depth.
    Thanks
    Paul

    Are you saying the way you were set up before, you immediately saw the resizing handles, and you could drag them to resize?
    I know there's an option for that, but finding it...  Always a challenge...
    Ah, found it.  Do this:
    1.  Activate the Move tool (4 way arrow cursor) in the Tools panel.
    2.  Check the [ ] Show Transform Controls box at the top of the main Photoshop window.
    -Noel

  • Resize a blob column in an Oracle table

    I have a table that store pictures from inspections. Occasionally, I will get a 3 or 4 mg file that Oracle Reports will not produce a report because of the size of the photo.
    Is there code to resize a blob?

    Hi,
    Not sure what you mean by "resizing" a blob. You can extract and return a substring of the blob using the dbms_lob supplied package:
    SQL> -- get the first 2000 bytes
    SQL> select dbms_lob.substr(<blob_column>,2000,1) from <blob_table>;but given the nature of your data, I highly suspect that would be of any use to Oracle Reports or any frontend for that matter.
    If by "resizing" a blob, you mean "change the resolution of the pic (blob), on the fly, so that it occupies less space", then I doubt it would be easy to implement using SQL or even PL/SQL.
    Just a thought - you may want to program the image resizing logic in a language like Java or C and implement it as a Java Stored Procedure or call it as an external procedure respectively.
    pratz

  • Image resizes when dragged to new window

    All my images change size when I move them to a new window. I am making numerous graphics that need to be exact for collage like purposes; I will work them in their own window and will drag the finished images to a separate window to print(graphics are small, and I want to fill a print page with as many as possible) My issue is that whenever I drag the images to the new window they re size, usually larger. The new window is the same size as old. This is also happening when I print but image will be smaller than what is seen in image size dialog box. Please advise. Thank you

    I assume that you are working with Elements v.3 or v.4.
    In order to avoid a major size disparity as you describe in making a collage, have the resolution of the canvas and the picture files the same. For example, go to File>New>Blank file and establish width, height, and resolution. Click ok. For printing, it is desirable to have resolution 240-300px/in.
    Next set the resolution of the picture files to a similar value. You may have to resample in order to achieve this. Minor degrees of size adjustment in the collage can be achieved via the handles in the move tool. Note that each picture file will be on its own layer, allowing for this type of adjustment readily.
    Feel free to repost if you have additional problems as you go on with your project.
    Ken

Maybe you are looking for

  • How can I get my subfolders back in chronolical order?

    I've run Lightroom from the beginning and love it.  For some reason, I developed multiple catalogs.  I remedied that today with a master catalog which seems to have worked fine with one exception: On my hard disk my photos are arranged in Date Folder

  • User Management (for dummies?)

    reposting from a different forum... I'm trying to use User Management and my head hurts... ...I'm on 11.5.10.2 ATG RUP5 and I've tried to connect all the dots referencing the User Management Admin Guide. I'm trying to create a role that I could grant

  • Invalid SRS when create a map tile layer

    Hi, When i created a map tile layer and submit , it shows "Error creating a new map tile layer: Invalid SRS(spatial referencing system). This might be caused by invalid SRID or no database connection being available to retrieve SRS information." And

  • BlackBerry-8800 Cannot Install Third-party softwares

    Hi ... can anyone help me how to be able to change all settings (including password prompts), and install Third Party Applications I am unable to make changes to the settings or install Third Party Applications. I have a Blackberry that was previousl

  • Newly created users are not able to log in through WEBGUI in SRM system

    Hi All, I have created new roles in the SRM system with  the BP tanscation codes Like( BBPSC01 BBPSC02 BBPSC03 BBPSC04) after that I have created new users and I have assigned these roles to users. Users are able to login throgh SAP GUI but Users are