HELP Friends!!! How to set the width of columns of JTABLE?

Hi!
How to set the width of a particular column in JTable?
I tried using headerRenderers and though I'm able to set the color and font of the header (using getTableCellRendererComponent method)I can't change the size.
Pls some one help me..it's very urgent.
Thanks in advance.
Regards,
Naval

JTable.getColumnModel().getColumn(i).setWidth(width). There are also setPreferredWidth, setMaxWidth and setMinWidth methods.

Similar Messages

  • Please help me :How to set the width and height for my View page "test.htm"

    Hi,
        I have controller class. When i call the view[test.htm]from this controller class ,i am getting the view with output tableview..it is fine.
    My requirement:
                 the output view window is showing full browser window. I want the view output like showModeldialog. I want to set the width and height for the output view window. How is possible?
                 or
    i want to call the test.view in the window.showModelDialog..
    Please help me .. Urgent requirement.

    Yes you can set the width & Height of the view as follows..
    <div style="width:580px; height:750px; margin-top:15px; overflow:auto;">
    <htmb:form......>
    </htmlb:form>
    </div>
    <i>*Reward each useful answer</i>
    Raja T

  • JTable Model   --  How to set the width of columns

    Hello,
    This project of mine is due in 2 days. :(
    I am using AbstractTableModel and I can't figure out how to set the columns' width inside my JTable?
    This following code does not work.
    int vColIndex = 1;
    TableColumn col = table.getColumnModel().getColumn(vColIndex);
    int width=399;
    col.setPreferredWidth(width);Please remember, that I'm using AbstractTableModel and not just simple JTables.
    Thanks in advance.

    The DataModel (AbstractTableModel or otherwise) has nothing to do with the table column size. The DataModel is used to store data.
    When you create a JTable using a DataModel then a TableColumn is created for each column in the DataModel using a default column size. The normal order of creation would be:
    TableModel model = new DefaultTableModel(...);
    JTable table = new JTable(model);
    Now that the table and table columns are created you can change the size of the columns:
    int vColIndex = 1;
    TableColumn col = table.getColumnModel().getColumn(vColIndex);
    int width=399;
    col.setPreferredWidth(width);
    So your code looks ok.
    However, if somewhere in you code you do:
    a) table.setModel(...)
    b) fireTableStructureChanged();
    then the table columns are recreated based on the current DataModel and the table column size would be reset to the default values.

  • How to set the width for a selectManyShuttle component

    Hi,
    I'm using selectManyShuttle component from Oracle ADF Core and some of the items in the showing list are long, therefore the width of selectManyShuttle expands the page. How to set the width property for selectManyShuttle component? After that does selectManyShuttle provide horizontal scrollbar as well?
    Thanks in advance,
    lapi
    Message was edited by:
    [email protected]
    Message was edited by:
    [email protected]

    Solution here:
    Re: ADF Faces Scrollable Panel or Scroll Bar inside a component
    Regards
    Grant

  • How to set the WIDTH and ALIGN of h:column in h:dataTable ??

    How to set the WIDTH and ALIGN of <h:column> in <h:dataTable>??
    Thanks a lot!

    Hi,thanks to your reply.
    Now I find a more convenient appraoch to set column's width and align respectively:
    <h:dataTable ...>
    <h:column>
    <f:facet name='header'>
    </f:facet>
    <h:outputText style="width:80px; text-align: right;" value='#{row.fieldA}'/>
    </h:column>
    <h:column>
    <f:facet name='header'>
    </f:facet>
    <h:outputText style="width:120px; text-align: left;" value='#{row.fieldB}'/>
    </h:column>
    </h:dataTable>
    It works fine.
    ^-^

  • How to set the data fields column wide at sqlplus

    Dear Sir/Madam
    I would like to know how to set the data fields column wide at sqlplus
    Thanks
    Francis

    see
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch6.htm#sthref1131
    and the FORMAT clause of the COLUMN command in
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12013.htm#BACHCABF

  • How to set the width of a Column

    Hi friends
    I have problem with setting up the Width for each column. Let us i want to set different column width for each Column.
    That is for first column the Width may be Different and the other column the width may be different.
    So please help me out on this Issue
    Cheers
    Jofin

    How to set the width of a ColumnWhat component are you talking about? Are you talking about the width of a column in a JTextPane?
    Have you read the API for the component in question?
    Have you followed the link titled "How to Use...." to the Swing tutorial?
    Learn to read the API and ask a proper question with all the relevant information.

  • How to set the width of DataGridColumn dynamically?

    What I want to do is, load data from a text file and put into a DataGrid component, the fields of ech record in the text have fixed length, and are seperated by a space, like this:
    personal.txt
    50 Uvwxyz  Male    123456789
    60 Hijklmn  Male    67890123456789
    30 Abcdefg Male    123456789012345
    40 Opqrst   Female 987654321012345678
    the configuration file is column.xml:
    <dgcolumn>
         <personal>
              <len>20</len>
              <title>Name</title>
         </personal>
         <personal>
              <len>3</len>
              <title>Age</title>
         </personal>
         <personal>
              <len>6</len>
              <title>Sex</title>
         </personal>
         <personal>
              <len>20</len>
              <title>IdNumber</title>
         </personal>
    </dgcolumn>
    First I load the column.xml into an arrColumn, then read the personal.txt and seperate the record by the width( "len" in the xml file ), and put the seperated fields into another arrField, set the arrayFld as the dataProvider of a DataGrid, thus, the title can be showed as the headerText of the DataGrid and the data can be loaded correctly.
    private function handleComplete( event:Event ):void
         var arrField:Array = new Array();
         var arrFile:Array = loader.data.split(/\n/);
         for( var i:int = 0; i < arrColumn.length; i ++ )
              arrField[i] = convIcom( arrFile[i] );
         adgFile.dataProvider = arrField;
         trace( "The data has successfully loaded" );
    private function convIcom( strRecord:String ):Object
         var key:String = null;
         var dataField:String = null;
         var offset:int = 0;
         var obj:Object = new Object();
         if( strRecord.length > 0 )
              for( var i:int = 0; i < arrColumn.length; i ++ )
                   dataField = strRecord.substr( offset, arrColumn[i].len );
                   key = arrColumn[i].title;
                   obj[key] = dataField;
                   offset += arrColumn[i].len + 1;
         return obj;
    <mx:DataGrid x="10" y="100" width="400" id="dgFile" />
    The problem is, the width of the DataGridColumn is average, how to set the column width by the length of each field? I can calculate the rate of each field ( field / fields ), but I don't know how to change the property of the DataGridColumn.width.
    Thanks for helping.

    In the above post, I pasted an old version of personal.txt, so I paste it again:
    personal.txt
    Uvwxyz  50 Male   123456789
    Hijklmn 60 Male   67890123456789
    Opqrst  40 Female 987654321012345678
    Abcdefg 30 Male   123456789012345
    And I have another question, when the data is loaded into the DataGrid, the fields of each record are ordered in alphabetical order ( the "Age" column will appear firstly, then "IdNumber", "Name", "Sex" ), not as the order in column.xml, how to make it keep the sequence of the xml file?
    Thanks again.

  • How to set the width of a cell in JTable?

    I have created a JTable and I want to set the width of cells.How can I do that?

    This is now the third person to tell you that Swing questions should be posted in the Swing forum.
    You have several postings out there where you have been given an answer but you haven't bothered to respond to the posting. Indicating whether the suggestion was helpfull or not. I guess you really don't want help from people in the future.

  • How to set the width of a shuttle?

    Hi
    I have a group which is shown in intersection-shuttle style but the problem is that it breaks some rows into two lines and i want to make the shuttle a bit wider. How could I set the width of the shuttle. Apparently the Group Width attribute of the group doesn't work for this.

    You could try this using the inlineStyle property of the shuttle component in the generated page. Not sure that works though. You better ask this on the JDeveloper forum.
    If it works you can create a custom template to include the inlineStyle property during generation.
    Steven Davelaar,
    Jheadstart Team.

  • How to set the width: IF_WD_SELECT_OPTIONS- add_parameter_field

    Hi everyone,
    I would like to know if there's a way to set the width of UI controls defined for IF_WD_SELECT_OPTIONS.
    In particular I've created a selection screen using
      wd_this->m_handler_simple_left->add_parameter_field( i_id = 'CONTRACT_DESCRIPTION'  i_value = lr_field
                                                        i_description = 'Contract description'
                                                        i_within_block = 'BL01'  ).
    but I'm unable to set the width of this field and the final rendering isn't very nice at all (all input fields have different data types and different size).
    Thank you.
    Regards

    Hi,
    I think we dont have any width type parameter to set width in selectoptions. The width comes directly from Domain.
    Cheers,
    Kris.

  • Set default width of columns in JTable

    i have a JTable which has multiple columns.
    the rows dont fit into the JTAble normally so i needed to add a horizontal scroll pane which was done by
            table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);the problem now is that the columns are squashed into table,
    i want to be able to set the width of the columns, is there anyway of doing this?

    good tutorial on JTable

  • How to set the width and heigh in the popup window

    Hi All,
    I tried to show a report in a popup window style.
    In the column link section, I defined the URL like the following:
    javascript:popupURL('f?p=&APP_ID.:128:&SESSION.::&DEBUG.::P128_PAY_RATE,P128_PAY_TERMS:#PAY_RATE#,#PAY_TERMS#'). how and where to set the height and width for page 128?
    Thank you,
    spark

    Here is a sample of the JavaScript function I re-use that opens a popup window. You'll notice that it includes the width and height of the popup window:
      function callTCPopup (formItem1) {
        var formVal1 = formItem1;
         var url;
      url = 'f?p=&APP_ID.:1111:&APP_SESSION.::::P1111_TC_ID:' + formVal1;
      w = open(url,"winLov","Scrollbars=1,resizable=1,width=800,height=600");
      if (w.opener == null)
      w.opener = self;
      w.focus();
      }You could also look at using a Modal Page (Skillbuilders' plugin - watch the video for use).

  • How to set the border of header of JTable

    I am using the following code to set the border of my JTable headers but it doesn't seem to work!! The headers do get CENTER aligned but somehow they do not show the right border. Please Help.
    class cellAlignRenderer extends DefaultTableCellRenderer
    cellAlignRenderer()
    setHorizontalAlignment(JLabel.CENTER);
    Border b = BorderFactory.createEtchedBorder() ;
    setBorder(b);
    jTable.getColumn(0).setHeaderRenderer( new cellAlignRenderer());

    try this
    public class YourTableHeaderRenderer extends DefaultTableCellRenderer
    public YourTableHeaderRenderer()
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column)
    JLabel comp = (JLabel) super.getTableCellRendererComponent(table,value,
    isSelected,hasFocus,row,column);
    try
    comp.setBorder(BorderFactory.createBevelBorder(0,Color.lightGray,Color.darkGray));
    setFont(new java.awt.Font("Dialog", 0, 15));
    setHorizontalAlignment(SwingConstants.CENTER);
    catch(Exception err)
    err.printStackTrace();
    return this;

  • How to set the row height in a JTable

    Is there a way to set the height of a row (actually all rows) in a JTable?
    I have tried setting the font to be bigger but then the cells are not big enough.

    Use "rowHeight" method of JTable class.
    For more information about JTable class, please read the API documentation at http://java.sun.com/j2se/1.3/docs/api/javax/swing/JTable.html
    /Sreenivasa Kumar Majji.
    Is there a way to set the height of a row (actually
    all rows) in a JTable?
    I have tried setting the font to be bigger but then
    the cells are not big enough.

Maybe you are looking for

  • P2P with Mac Intel??

    Hi there, Curious if anyone could recommend good P2P program for the ntel macbook. I'm using Auquisition right now, and i'm not getting the results i want. Can you run SoulSeek on an Intel Mac? Anyy feedback would be great Thanks

  • IPhoto 6 Rebuilding Thumbnails

    I recently upgraded from iPhoto 5 to 6, and since then, 3 times in the past week iPhoto has told me that it needs to rebuild my thumbnails. This takes about 10 minutes, so it's really getting on my nerves. Is anyone else having this problem or know h

  • Ias10gr2 and oracle XE

    do you know if it's possible of create a DAD to point a schema on a DB Oracle XE I haven't got any problems with any Oracle DB 10g and 11 but I've got some problems with the XE thank you

  • IPhoto imports pictures in small resolution!

    This issue wasn't happening until a couple of weeks. When connecting my iPhone 4 to the computer and starting iPhone to import my photos, the result files are smaller than the original files. The information consigned in the iPhoto panel is that my p

  • How to created cost centre

    hi all how to create cost centre regards JK rao