Resize column width for JTable without column headers?

I find that for me to resize columns of a JTable by using
mouse dragging, I MUST have column headers and then drag
column headers to resize them. Is my understanding correct?
Actually, I need to have a table without header columns.
How can I use mouse to resize column width by dragging?
The background for this request is that I am putting a
complex table as another table's column header and I hope to
be able to resizing the complex table by mouse dragging.
Thanks very much,

I think you have mistake there. Try
<style type="text/css">
table.apexir_WORKSHEET_DATA td {
white-space:nowrap !important;
td[headers="DESCR"] {
width:300px !important;
max-width:300px !important;
#apexir_DESCR {
max-width:300px !important;
</style>And you can try add
table.apexir_WORKSHEET_DATA {
width: 100% !important;
table-layout: fixed !important;
My Blog:

Similar Messages

  • Jtable without column header

    Hi all,
    I have searched for jtable without column header... and if it´s possible how can I make?

    Override JTable#configureEnclosingScrollPane() to do nothing or remove the table header manually ( jScrollPane.setColumnHeader(null) ) after you added the table to the scroll pane.

  • How to set initial column widths for a table

    What I'd like to do is to control the initial column widths for a table.
    I'm building the table by using a class which extends AbstractTableModel. This class takes care of setting the headers and reading the data for the table.
    If I do the following:
    VarTableModel vtm = new VarTableModel(vi);
    JTable jt = new JTable(vtm);
    JScrollPane jsp = new JScrollPane(jt);
    I will see a table in my window. The widths of the columns are equal and are a function of the horizontal dimension of the window.
    I have tried to set the width of a column by doing the following:
    TableColumn aColumn;
    aColumn = jt.getColumn(vtm.getColumnName(0));
    But this has no effect on what gets displayed. I can force the widths that I want by using 'setMaxWidth' but this has the unfortunate side effect of not allowing the user to make the column wider if they want.
    What I'd like is a way to specify the widths of the columns when initially displayed and then let the user adjust to their liking.
    I'm sure that there is a way to do this, but I don't seem to understand where to intervene in the process to produce the effect that I want.
    Any help or suggestions will be greatly appreciated!

    add this line and try ur codeThanks for the suggestion! Unfortunately, it doesn't seem to do the trick. Here is an abbreviated segment of my code:
    vtm = new VarTableModel(vi);
    JTable jt = new JTable(vtm);
    // we want a horizontal scrollbar, so turn resizing off
    // and we want to control column widths
    aColumn = jt.getColumn(vtm.getColumnName(0));
    . // same kind of thing for each column
    aColumn = jt.getColumn(vtm.getColumnName(4));
    JScrollPane jsp = new JScrollPane(jt);
    If I do the above, the table gets displayed with each of the five columns the exact same width. So, the sizing of the columns is happening somewhere else despite turning auto resizing off.
    Where is that occurring and how can I intervene so that I can control the widths of the columns on initial display and still allow the user to adjust the widths if they so choose?

  • How do I set column width for a table?

    I want to set the same width for all the columns in a particular table. Is there anyway of doing this without having to actually manually adjust each individual column?

    Select the column headers and drag across (A,B,C for example) then select between one of the columns (your pointer will change shape). Select and drag to the new width. All selected columns will change.

  • Set column width in JTable

    I have two columns in a JTable and I am trying to set the column width for the first.
    I am trying to this by
    getDataTbl().getColumnModel().getColumn(1).setHeaderValue(" Data ");
    int width = ((String)getDataTbl().getColumnModel().getColumn(0).getHeaderValue()).length();
    but it doesn't reset the width. I want the first column width to be smaller than the second which should be much larger width.
    Any suggessions to this?

    Hi there
    Use this JTable method
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);This should solve your resize problem

  • Dynamic Column width for a report

    Will the width property of a column be able to be set at run-time (i.e. ability to set the width of a column to an expression) in SQL Reporting Services 2008? One problem I have seen is the inability to set the width of columns in a report when you you have several columns whose order is determined based on parameters.
    Lets say I have 2 columns in a report and two fields from the database which will populate those columns: 1 field that is varchar(5) and one which is varchar(50). If I do not know which column each field will go to until runtime how am I supposed to adjust the column width? Letting the column width be set by an expression would solve everything as I could pass the width in to the report. As it stands now, I would have to set each column's width to accomodate a field of type varchar(50) in order to avoid wrapping of data.
    You could say just create 2 reports, one for each case, but what if I had 15 fields? 20?
    Has anyone figured out how to dynamically set the width of a column? Will the width of a column be able to be set at run-time in SQL Server Reporting Services 2008 via expression or some other means?
    Questions, questions, questions.

    Ok slight update
    RDL xml files are used during deisgn of reports but when you deply they go into the Content column of a table called Catalog:
    SELECT [Name],
    FROM [Catalog]
    WHERE type = 2
    So I think this can be edited programmatically.  Widths can be found like this:

  • How to set displayed column width for a search help

    I have created an elementary search help for a custom field with a value table behind it.
    The search help functions correctly, but when displayed the column widths are all 10 characters. The user has to adjust the column to view the descriptive text.
    Can anyone tell me how to set default column widths for the help?

    Please  open you Elementary search  help  and see the Column  width   behind the Fields of your ...there  increase the width of the fields
    "Activate it  and refresh
    reward  points if it is usefull .....

  • How can I set column width in JTable?

    How can I set column width in JTable?

    Also, read the JTable API before posting questions. You will find a link to the Swing tutorial on "How to Use Tables", which contains an example of doing exactly this.

  • JTable without column headers?

    I want a JTable without the column headers.
    How can i do this?

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Test extends JFrame {
        public Test() {
         String[] head = {"","",""};
         String[][] data = {{"0-0","0-1","0-2"},
         JTable myTable = new JTable(data,head);
         Container content = getContentPane();
         content.add(new JScrollPane(myTable), BorderLayout.CENTER);
        public static void main(String[] args) { new Test(); }

  • Column width in JTables.Help needed!!!!

    I am trying to print out a JTable and have had a few problems along the way but have managed to solve them all so far apart from this one. When the JTable is shown on screen it doesn't make the columns wide enough . I ahev managed to find some code from these forums but it doesnt resize correctly if the Column headings contain more text than any of the data (If you know what i mean). Below is the code i am using
    public void sizeAllColumnsToFitData (JTable table)  {
        for (int col = 0; col < table.getColumnCount (); col++)  {
          TableColumn curColumn = table.getColumn (table.getColumnName (col));
          if (curColumn == null)
            continue; // not a valid column skip
    //  Translate to the model
          int modelColumn = curColumn.getModelIndex ();
    //  Loop for all rows in this column looking for the widest piece of data
          int maxColumnWidth = 0;
          for (int row = 0; row < table.getRowCount(); row++)  {
            TableCellRenderer curCellRenderer = table.getCellRenderer (row, modelColumn);
            Object value = table.getValueAt (row, modelColumn);
            Component curRenderComponent = curCellRenderer.getTableCellRendererComponent(table, value, true, true, row, modelColumn);
            Dimension cellDimension = curRenderComponent.getPreferredSize ();
            if (cellDimension.width > maxColumnWidth)
              maxColumnWidth = cellDimension.width;
    //  Set the column width to fit the maximum
          Dimension cellSpacing = table.getIntercellSpacing ();
          curColumn.setPreferredWidth (maxColumnWidth + (cellSpacing != null ? cellSpacing.width : 1));
      }I pass my table into here and it works fine apart from in doesnt take into consideration the size of the headings. Please Help ME!!!!

         at database_testing.SLAMS.sizeAllColumnsToFitData(
         at database_testing.SLAMS.getInfo(
         at database_testing.SLAMS.getInfo_actionPerformed(
         at database_testing.SLAMS_getInfo_actionAdapter.actionPerformed(
         at javax.swing.AbstractButton.fireActionPerformed(
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(
         at javax.swing.DefaultButtonModel.fireActionPerformed(
         at javax.swing.DefaultButtonModel.setPressed(
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(
         at java.awt.Component.processMouseEvent(
         at java.awt.Component.processEvent(
         at java.awt.Container.processEvent(
         at java.awt.Component.dispatchEventImpl(
         at java.awt.Container.dispatchEventImpl(
         at java.awt.Component.dispatchEvent(
         at java.awt.LightweightDispatcher.retargetMouseEvent(
         at java.awt.LightweightDispatcher.processMouseEvent(
         at java.awt.LightweightDispatcher.dispatchEvent(
         at java.awt.Container.dispatchEventImpl(
         at java.awt.Window.dispatchEventImpl(
         at java.awt.Component.dispatchEvent(
         at java.awt.EventQueue.dispatchEvent(
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(
         at java.awt.EventDispatchThread.pumpEvents(
         at java.awt.EventDispatchThread.pumpEvents(
         at i think it may have something to do with my headerRenderer being null cus if i replace the line TableCellRenderer headerRenderer = curColumn.getHeaderRenderer(); with TableCellRenderer headerRenderer = table.getTableHeader().getDefaultRenderer(); then it doesnt come up with an error but only increase the size of the coluns (where neccessary by 2 characters)

  • Can't set custom column widths in JTable

    I'm trying to set custom columns widths. They are set as I wish but then they are reset to default values (all columns have the same size). This is caused by method JFrame.setVisible(true) which invokes JTree.setWidthsFromPreferredWidths(). It can be investigated from following stack trace printed when a column being resized (see below).
    How to prevent this auto width sizing?
    P.S. can't override JTable.setWidthsFromPreferredWidths(); seems it's private
    table = new JTable(model) {
         public void columnMarginChanged(ChangeEvent event) {
              new Exception("stack trace").printStackTrace();
    // setting here custom columns widths via table column model stack trace
         at mtu.gui.TrackList$1.columnMarginChanged(
         at javax.swing.table.DefaultTableColumnModel.fireColumnMarginChanged(
         at javax.swing.table.DefaultTableColumnModel.propertyChange(
         at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(
         at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(
         at javax.swing.table.TableColumn.firePropertyChange(
         at javax.swing.table.TableColumn.firePropertyChange(
         at javax.swing.table.TableColumn.setWidth(
         at javax.swing.JTable$2.setSizeAt(
         at javax.swing.JTable$5.setSizeAt(
         at javax.swing.JTable.adjustSizes(
         at javax.swing.JTable.adjustSizes(
         at javax.swing.JTable.setWidthsFromPreferredWidths( <======
         at javax.swing.JTable.doLayout(
         at java.awt.Container.validateTree(
         at java.awt.Container.validateTree(
         at java.awt.Container.validateTree(
         at java.awt.Container.validateTree(
         at java.awt.Container.validateTree(
         at java.awt.Container.validateTree(
         at java.awt.Container.validateTree(
         at java.awt.Container.validateTree(
         at java.awt.Container.validateTree(
         at java.awt.Container.validateTree(
         at java.awt.Container.validateTree(
         at java.awt.Container.validateTree(
         at java.awt.Container.validate(
         at java.awt.Component.setVisible( <=====
         at mtu.gui.Test.test_03(
         at mtu.gui.Test.main(
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(
         at java.lang.reflect.Method.invoke(
         at com.intellij.rt.execution.application.AppMain.main(Unknown Source)

    When I create the table I have code like this:TableColumn col = getColumnModel().getColumn(2);
    col.setMinWidth(width + 4);
    col.setMaxWidth((int)(width * 1.2));Works just fine for me. The setWidthsFromPreferredWidths() method will use these limits as far as I can see.

  • How to fix the table column header and resize the width of a table column?

    Hi all,
    I have the following two requirements,
    1) I need to wrap the table column header into two rows. I mean the header must be displayed in two rows.
    2) I need to to able to resize the width of the column. i.e The user should be able to drag the column width according to his requirement.
    Is this possible. Any help would be appreciated!

    Hi Kishan,
    Refer to these links.They may ne useful for you.

  • Column width for cl_gui_splitter_container not working

    Hello friends,
    I'm trying to set the column width in a splitter, but the width is not being changed. Can anyone help me ? Here is a draft of my code
    At the PBO of the screen form I have the following:
               gobj_split                       TYPE REF TO cl_gui_splitter_container,
              gobj_container_1        TYPE REF TO cl_gui_container,
               gobj_container_2       TYPE REF TO cl_gui_container,
               gobj_drawer_container  TYPE REF TO cl_gui_docking_container,
    gobj_right_container   TYPE REF TO cl_gui_docking_container,
    *-- Create Container for Drawer (Left)
       IF gobj_drawer_container IS INITIAL.
         CREATE OBJECT gobj_drawer_container
             repid     = gv_repid
             dynnr     = gv_dynnr
             extension = 400
             others    = 1.
    *-- Create Container for the right
       IF gobj_right_container IS INITIAL.
         CREATE OBJECT gobj_right_container
             repid                       = gv_repid
             dynnr                       = gv_dynnr
             side                        = gobj_right_container->dock_at_right
             extension                   = 1500
             cntl_error                  = 1
             cntl_system_error           = 2
             create_error                = 3
             lifetime_error              = 4
             lifetime_dynpro_dynpro_link = 5
             OTHERS                      = 6.
    *-- Create Split Object
    CREATE OBJECT gobj_split
           parent            = gobj_drawer_container
           rows              = 2
           columns           = 1
           cntl_error        = 1
           cntl_system_error = 2
           OTHERS            = 3.
    *-- Split into two rows and one column
    CALL METHOD gobj_split->get_container "Container for Date & Information
           row       = 1
           column    = 1
           container = gobj_container_1.
       CALL METHOD gobj_split->get_container "Container for Main Options
         row       = 2
         column    = 1
         container = gobj_container_2.
    *-- Set Row and Column Modes to absolute
    CALL METHOD gobj_split->set_row_mode
           mode = gobj_split->mode_absolute.
       CALL METHOD gobj_split->set_column_mode
           mode = gobj_split->mode_absolute.
    *-- Set Row Height (THIS IS WORKING)
      gobj_split->set_row_height( EXPORTING id     = 1
                                                                               height = 50 ).
    *-- Set Column Width ( THIS IS NOT WORKING )
       gobj_split->set_column_width( EXPORTING id    = 1
                                                                                   width   = 50 ).    
    And this is what I get... no matter value I put in line 80, the width doesn't change.
    Does anyone have any idea why this is happening ?
    Thank you

    You splitted the parent container in two part upper and lower row (2 rows), so you are able to adjust the vertical size, but not the horizontal size (only 1 column)  this size must be adjusted on parent container.

  • Change column width for print table to report

    Hi, want to make the first column in my table to be printed to report wider than the rest, for it contains the part numbers of about 16 chars and the other columns are the data of 4 each. Don't want to make all equally wide for I want to fit as many column as possible over the page. How can I do this?? Thanks for any help. Is there maybe another way to print in a table format?? Madri

    Hi Madri,
    Assuming you are using the Standard Report type with the Report Generation VIs, you can check out this KnowledgeBase entry that discusses how to customize the VI to generate a report with different column widths:
    Hope this helps,
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • Column validation for JTable?

    Hi all,
    i have a table on my app, there is a column that show boolean value on the table. it's represented by check box, cause i'm using a custom table model. the datas is took from database.
    i want to create a column validation to validate at least only 1 cell must checked, if there's only a checkbox that checked and when we try to uncheck the last one it will show us a warning. how to make it possible?
    anyone can help me?
    i'm using jdk1.6.0_04

    You will probably need to create a custom editor.
    This code shows how to create one using a text field. The code will be similiar for a check box:
    You will need access to the JTable or TableModel and would need to look at the values in every row for the specific column before determining whether to stop editing or not.

Maybe you are looking for

  • ARIS process import in BPM

    Hi All, I am trying to import ARIS process into BPM.I am using ARIS 7.2 wherein I converted EPC into BPMN.After that I tried to export the BPMN .But there could only export the file only in the XML format and not in BPMN format. But in BPM we are una

  • Apple Script Help

    Hi,   I wrote the below script to delete files of a particular folder, but now I want to do that to the Documents folder. I tried using this script but it didn't work. Any ideas? Or any entirely different script that might work. Thanks. tell applicat

  • Digit in part number disapears on wrap - help...

    Here is what happens: I type this part number into a new text box, FRDM6881-C100. Then I make the text block smaller, positioning the right side of the text block so that it falls over the "C100" in the part number. The text wraps at FRDM- but on the

  • HT4623 IOS 7 issues with FaceTime access

    Just updated my IPad with IOS 7 and can't access FaceTime can anyone help me please ?

  • ICloud usage by family

    My whole family is on one acct. everyone has two-three devices. How can I separate them all and they still keep their games and stuff?