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);
frame.getContentPane().add(jsp);
frame.setVisible(true);
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));
aColumn.setWidth(40);
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!

Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
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
jt.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
aColumn = jt.getColumn(vtm.getColumnName(0));
aColumn.setWidth(40);
. // same kind of thing for each column
aColumn = jt.getColumn(vtm.getColumnName(4));
aColumn.setWidth(400);
JScrollPane jsp = new JScrollPane(jt);
frame.getContentPane().add(jsp);
frame.setVisible(true);
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?

Similar Messages

  • 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 .....
    Girish

  • How to set dynamic column width for analysis item

    Dear Experts,
    I have a query view which is added in the web template as an analysis item. The web item properties on width is not working - I tried entering a value in the width but when I execute the template, the query view's width still stays the same.
    Module com.sap.ip.bi.rig.ColumnWidth don't seem correct because I don't want the column width to be static. As my number of columns may change, I wanted the overall width of my query view to stay the same.
    Appreciate any ideas which can solve this issue
    Thanks and Regards,
    huimin
    BW newbie

    Hi Huimin,
    I don't think it is possible to fix the width of the Analysis webitem since it dynamically adjusts its width based on the text maxlength within its cells. Unless you use com.sap.ip.bi.rig.ColumnWidth where the cols are static, you cannot achieve this.
    Even if you do override the css settings using a cell padding or something, the portal settings would override the same. How about using a Report webitem to insert tables/charts & check if the width can be adjusted here - just a thought.
    --Priya

  • How to set a fixed width for a box

    Hi there,
    Struggling here.... must admit. 
    I need a solution whereby I can set a fixed width for a box that is grouping two buttons.  I suppose generally, I want to know how to set a fixed width for anything element.
    See the picture below.  I want the two buttons to stay the same distance apart, and I want the grouped buttons to stay the same distance from the right edge of the window, even as a user resizes the window.
    This is what happens when you reduce the size of the window .....
    I would like to stop this from happening.
    I can't figure out how accomplish keeping the parent div a fixed width, and a fixed position from the right side of the window, so the buttons won't overlap.
    Perhaps I'm doing the whole thing wrong. 
    I mean, is there a way to accomplish this without grouping the buttons?  That is, make the buttons fixed width, fixed distance apart from each other, and fixed distance from the right side of the window, even as the user resizes the page?
    I am trying to accomplish this using the Min/Max width settings, but given that there are so many different units to choose from, and the fact that when I place a button or box on the screen, it seems to be creating that button or box with a percentage-based width, I don't know how many pixels to set it to.... sigh....
    Many thanks in advance for your help.
    Sam

    Okay after much futzing I figured out at least part of the solution I need, but if someone knows of a more efficent way to do this please let me know. 
    I set a fixed minimum width in pixels for both of the buttons at 156px.
    I then made the left button float left and the right button float right.
    I then made the parent div for the buttons float right.
    That made the buttons stay the same size.
    The only thing I need to figure out how to do now is make the parent div stay a consistent distance in pixels from the right.  I tried setting a right margin but that didn't work.  As you size the window down, the div gets closer to the edge, until it passes it.  

  • 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?
    Thanks

    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.
    Regards,

  • OLE2 how to set a column width of an excel file i'm creating?

    how can i set the column width in an excel file i'm creating with ole?
    or even, haw can i set the auto-fix properties?

    Hallo !
    SORRY MY ENGLISH is very BAD.
    I tried to set page header and  footer in Excel sheet with abap ole
    DATA : BEGIN OF enter,
             x(1) TYPE x VALUE '0D',
            END OF enter.
    DATA : format(255) TYPE c.
    FORM set_page_sheet.
      CALL METHOD OF excel 'ActiveSheet' = sheet.
      CALL METHOD OF sheet 'PageSetup' = pagesetup.
      SET PROPERTY OF pagesetup 'Orientation' = xllandscape.
      SET PROPERTY OF pagesetup 'PrintTitleRows' = '$9:$12'.
      CLEAR format.
    ERROR
      CONCATENATE 'PAGESHEET' enter-x 'PAGE &P/&N' INTO format.
    ERROR
      SET PROPERTY OF pagesetup 'RightHeader' = format.
      CLEAR format.
      CONCATENATE ' Text 1 ' enter-x 'Text 2'
    enter-x 'Text 3 ' INTO format.
      SET PROPERTY OF pagesetup 'RightFooter' = format.
      FREE OBJECT pagesetup.
    ENDFORM.                    " set_page_sheet
    Activate report -
    ERROR - The enter-x must by data type c or another then data type x
    Thanks for answer.

  • How to set jtable column width

    Hello..
    I 'm using a simple jtable with the default model. I just want to set each column size to make table smaller Is this possible?
    Thanks
    Feras

    newdeveloper wrote:
    Hello..
    I 'm using a simple jtable with the default model. I just want to set each column size to make table smaller Is this possible?
    Thanks
    FerasI think that your problem probably has more to do with the Layout you're using (or not using) than it does with individual column sizes. What layout are you using?
    What happens when you set the size (or preferredSize, minimumSize, and maximumSize) on the whole JTable?
    You might also be looking for JTable.[getColumnModel()|http://download-llnw.oracle.com/javase/6/docs/api/javax/swing/JTable.html#getColumnModel%28%29].[getColumn()|http://download-llnw.oracle.com/javase/6/docs/api/javax/swing/table/TableColumnModel.html#getColumn%28int%29].[setPreferredWidth()|http://download-llnw.oracle.com/javase/6/docs/api/javax/swing/table/TableColumn.html#setPreferredWidth%28int%29].
    If none of those approaches work, post an SSCCE that demonstrates the problem.
    PS- Swing questions belong in the Swing forum.

  • How to set the column width in the PDF exports of interactive reports ?

    Hello,
    I have a huge problem with the PDF export for the Interactive reports. I'm using APEX 3.2.
    I have to produce a PDF report in landscape format that show 21 columns. My problem is that the columns have a ridiculous short width and that the text inside the columns do not wrap in the columns. So I get things like that :
    Date Name
    2011 Leina
    I should see 2011-08-01 and the name Leinad Jan
    I tried several things to format the columns, but none of the them has any effect on the PDF itself.
    1) I used HTML code in the report query. It works well with the interactive report, but display the HTML tags in the PDF.
    2) I used css to set the width of my columns. It works in the interactive report, but not in the PDF, the column width do not change.
    It's like the report do not notice that my page format is Legal 14 x 8.5 (Landscape) and still believe it's 8.5 x 11 (which is "portrait")
    Do you have any idea so set the columkn widths in the reports ?
    Thank you !
    Edited by: leinadjan on Aug 1, 2011 11:15 AM

    To "remember" the column widths, add a mouse listener to the table header. Upon mouseReleased(), get the column widths and save them to your file. When the application starts next time, get the stored widths and set them using:
    table.getColumn("XXX").setPreferredWidth(...);
    By default, your columns are adjustable, but you can use:
    table.getTableHeader().setResizingAllowed(true);

  • How to set the column width of JTable

    I want do remember the column width and write it to a file, when the window is started , the column width is read from the file and the table is set as that. I also want the column width is not fixed and can be changed by mouse.But I am always failded.
    How to do? would you please help me!
    Thanks a lots.

    To "remember" the column widths, add a mouse listener to the table header. Upon mouseReleased(), get the column widths and save them to your file. When the application starts next time, get the stored widths and set them using:
    table.getColumn("XXX").setPreferredWidth(...);
    By default, your columns are adjustable, but you can use:
    table.getTableHeader().setResizingAllowed(true);

  • How to set equal column width?

    In one report I have 5 tables with different number of rows etc. Is there any possibility or way to make columns inside of it equal? Problem is when report is being exported to .XLS file there are columns which are not visible or sometimes they are merged.
    Is there any quick way to avoid it or they only way is to sit in front of SSRS report few hours and somehow manage to set it manually praying that it will be good?

    Hi glaeran,
    The Excel renderer is primarily a layout renderer. Its goal is to replicate the layout of the rendered report as closely as possibly in an Excel worksheet and consequently cells might be merged in the worksheet to preserve the report layout. As per my understanding,
    this behavior is currently by design. For more information about it, please refer to the link below to see merge cells section:
    http://msdn.microsoft.com/en-us/library/dd255234.aspx
    To avoid the merged cells, if we want to display multiple tables horizontally, the rows of the two tables must be aligned horizontally strictly. If we want to display multiple tables vertically, then the columns of the tables must be aligned vertically strictly.
    The following thread about the similar issue is for your reference:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/7fbb3d31-fc1b-4c9b-8a7d-afc76cbb0291/ssrs-2012-report-export-to-excel-and-sort-thje-data-on-excel-spreadsheet?forum=sqlreportingservices
    Hope it helps.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support
    Well I do realise the point of "avoiding merged cells" however the points was to find a simply way to avoid it not just a summary "why SSRS report is behaving this way not another". Hoped that there's somekind of solution for my problem since in one report
    as it was said I had to put 5 different tables and every time the report itself is exported to XLS file.. So I thought that maybe it's possible to set same align of cells using table/column/cell properties or whatever so I won't have to spend whole day trying
    to match align of 5 tables column by column.. :)

  • 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:
    http://digital.ni.com/public.nsf/websearch/7AEC2CC2618D47DF86256D280058BDA5
    Hope this helps,
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • How to fix the column width in a table in htmlb tableview control

    HI Experts,
    I have an issue with my htmlb table view controller. I have created a custom iView with a htmlb table view control and placed it in quick navigation window.
    When data in columns exceeds, I am getting horizontal scroll bar and column,table are getting extened. I don't want  column size increases when text length increses. Instead when lenght of the text incrases in a column, I want the text displyed in multiple columns.
    I have tried for this as below.
    <hbj:tableView
        id="statTable"
        model="bean.stattableModel"
        design="ALTERNATING"
        headerVisible="false"
        footerVisible="false"
        fillUpEmptyRows="false"
        navigationMode="BYPAGE"
        selectionMode="NONE"
        headerText="Report List"
        visibleFirstRow="1"
        visibleRowCount="10"
    width="100%">
    <%
         stattableModel.getColumn("D").setWidth("5px");
         stattableModel.getColumn("D").setWrapping(false);//tried true aswell
         stattableModel.getColumn("H").setWidth("px");
         stattableModel.getColumn("H").setWrapping(false);
    %>
    No change happen ever after I used the above code.
    Any one has the idea, how make it work.
    Thanks in Advance,
    Chinna.

    Hi Babu,
    Please go through this links.
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/80a7eef2-9a2c-2a10-12bb-abad552f3302
    http://www.sapfans.com/forums/viewtopic.php?f=20&t=300326
    Kind regards
    Prabhakaran.P

  • How to reduce the coulmns width for Timesheet in ESS ?

    Hi,
    In ESS Timesheet, how to reduce the columns width for professional self service?
    It is looking fine for weekdays, but when the user is assigned as professional self service at back end, few more sales order columns are added dynamically to timesheet for professional self service user. Now these extra coulmns are jumbled and also wide.
    I tried the OSS notes 989453 in 'listviewerslim.java' , but it doesn't work. Is there any other alternative work around for this. Do I need to work at backend to solve this, If so, please let me know the work around.
    Points will be awarded.
    Regards,
    Raj.

    Dear Friend
    Really need ur help as we are upgrading from 4.7 to ECC6.
    Our client want to implement tiem sheet. Request you to provide gudiance wheher CATS i.e CATSRegular orESS timesheet would be useful.
    if would be great if u could provide a kind of advantages adn disadvantages of both.
    Suitable points would be rewarded
    Sam

  • New to portal: Setting the column width in portal QBE report

    I'm trying to set different widths to different columns in the QBE report. One of the columns in the report contains long descriptive text. With the default column width the reports runs into many pages and user has to scroll a lot. I would like to set the column width for this column so that it does not wrap for every 2/3 words. In the customization tab, I'm setting the width type to "Char" and selecting the number of characters to be displayed in that coulmn. Percent/pixel width type also didn't help. Should I set the Header width also?. I'm not sure where to set this header column width.QBE report just ignores these customization parameters and displays the report in default format. Please let me know if you have any idea/solution to this problem.
    Thanks
    Surya

    Hi,
    This is a bug and has been fixed 30984.
    Thanks,
    Sharmila

  • How to set the column order of a sealed column in a custom Content Type for the new item form NewDocSet.aspx?

    Dear SharePoint Developers,
    Please help.
    I need to know How to set the column order of a sealed column in a custom Content Type for the new item form NewDocSet.aspx?
    I think this is a "sealed column", whatever that is, which is  shown in SPD 2013 as a column of content type "document, folder, MyCustomContentType".
    I know when I set the column order in my custom Content Type settings page, it is correct.
    But, when I load the NewDocSet.aspx page, the column order that I set in the settings page is NOT used for this "sealed column" which is bad.
    Can you help?
    Please advise.
    Thanks.
    Mark Kamoski
    -- Mark Kamoski

    Hi,
    According to your post, my understanding is that you want to set the column order of a sealed column in a custom Content Type for the new item form NewDocSet.aspx.
    Per my knowledge, if you have Content Type management enabled for the list or library (if you see a list of content type with the option to add more), the display order of columns is set for each content type.
    Drill down into one of them and you'll see the option under the list of columns for that content type.
    To apply the column order in the NewDocSet.aspx page, you need to:
    Select Site Settings, under Site Collection Administration, click Content type publishing. In the Refresh All Published
    Content Types section, choose Refresh all published content types on next
    update.
    Run two timer jobs(Content Type Hub, Content Type Subscriber) in central admin(Central Administration--> Monitoring--> Review timer jobs).
    More information:
    http://sharepoint.stackexchange.com/questions/95028/content-types-not-refreshing-on-sp-online
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

Maybe you are looking for

  • Problem with my MSI 290x gaming 4g performance in unigine valley benchmark.

    First im dutch(netherlands) so sorry for my maybe bad english. My system is: Asus p8z77 v deluxe mb intel 3770k cpu 16gb ram 1866 Corsair 2x ssd 256 gb OCZ MSI 290x gaming win7 64bit ultimate. When i came home with my card i removed my old 7970 and r

  • Since updating to itunes 11, Home Sharing is not working

    Since updating to itunes 11, Home Sharing is not working. I am running Windows 7, 64-bit. All mobile devices are up to date with ios, including 2 apple tvs (2 & 3), iphone 4s and 3gs, ipad1 & ipad2. I've rebooted twice, turned home sharing off, then

  • Macpro and using a TV as another viewing option at the same time as display

    Hi, I have a MacPro and I'm trying to edit some footage but want to use my Radeon X1900 with one output going to my 23inch Apple display the other output going to my TV. I have the setting in FCP veiw menu to "All Frames" & "Digital Cinema Desktop Pr

  • NWDS 7.11 ceclt nwcetool is missing

    Hi! After installing NWDS 7.1 EhP1 I now urgently miss the ceclt tool which was formerly (in NWDS 7.10) located under ...SAP\IDE\CE\eclipse\tools\nwcetool\ I need this tool urgently to convert my EAR project to an SDA file using the ceclt function cr

  • Imac Monitor - Shading

    I have 4 distinct shaded bars going across the monitor (Imas 21.5 2.5 GHz) starting from light to heavy grey shading. It is there all the time and I am not sure if the monitor is damaged or if the kids have pushed some setting somewhere.  Any help I