Column width in JTables.Help needed!!!!

Hi
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!!!!

java.lang.NullPointerException
     at database_testing.SLAMS.sizeAllColumnsToFitData(SLAMS.java:473)
     at database_testing.SLAMS.getInfo(SLAMS.java:364)
     at database_testing.SLAMS.getInfo_actionPerformed(SLAMS.java:434)
     at database_testing.SLAMS_getInfo_actionAdapter.actionPerformed(SLAMS.java:527)
     at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
     at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)
     at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
     at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
     at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
     at java.awt.Component.processMouseEvent(Component.java:5134)
     at java.awt.Component.processEvent(Component.java:4931)
     at java.awt.Container.processEvent(Container.java:1566)
     at java.awt.Component.dispatchEventImpl(Component.java:3639)
     at java.awt.Container.dispatchEventImpl(Container.java:1623)
     at java.awt.Component.dispatchEvent(Component.java:3480)
     at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
     at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
     at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
     at java.awt.Container.dispatchEventImpl(Container.java:1609)
     at java.awt.Window.dispatchEventImpl(Window.java:1590)
     at java.awt.Component.dispatchEvent(Component.java:3480)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)Also 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)

Similar Messages

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

  • Resize column width for JTable without column headers?

    Hi,
    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,
    David

    Hi,
    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 {
    width:10px;
    max-width:300px !important;
    </style>And you can try add
    table.apexir_WORKSHEET_DATA {
    width: 100% !important;
    table-layout: fixed !important;
    }Regards,
    Jari
    My Blog: http://dbswh.webhop.net/htmldb/f?p=BLOG:HOME:0
    Twitter: http://www.twitter.com/jariolai

  • 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);

  • 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(0).setHeaderValue("Index");
    getDataTbl().getColumnModel().getColumn(1).setHeaderValue(" Data ");
    int width = ((String)getDataTbl().getColumnModel().getColumn(0).getHeaderValue()).length();
    getDataTbl().getColumnModel().getColumn(0).setPreferredWidth(width);
    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?
    Thanks.

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

  • 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();
              super.columnMarginChanged(event);
    // setting here custom columns widths via table column model ...java.lang.Exception: stack trace
         at mtu.gui.TrackList$1.columnMarginChanged(TrackList.java:30)
         at javax.swing.table.DefaultTableColumnModel.fireColumnMarginChanged(DefaultTableColumnModel.java:615)
         at javax.swing.table.DefaultTableColumnModel.propertyChange(DefaultTableColumnModel.java:679)
         at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(SwingPropertyChangeSupport.java:264)
         at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(SwingPropertyChangeSupport.java:232)
         at javax.swing.table.TableColumn.firePropertyChange(TableColumn.java:249)
         at javax.swing.table.TableColumn.firePropertyChange(TableColumn.java:255)
         at javax.swing.table.TableColumn.setWidth(TableColumn.java:482)
         at javax.swing.JTable$2.setSizeAt(JTable.java:2242)
         at javax.swing.JTable$5.setSizeAt(JTable.java:2336)
         at javax.swing.JTable.adjustSizes(JTable.java:2372)
         at javax.swing.JTable.adjustSizes(JTable.java:2340)
         at javax.swing.JTable.setWidthsFromPreferredWidths(JTable.java:2250) <======
         at javax.swing.JTable.doLayout(JTable.java:2165)
         at java.awt.Container.validateTree(Container.java:1089)
         at java.awt.Container.validateTree(Container.java:1096)
         at java.awt.Container.validateTree(Container.java:1096)
         at java.awt.Container.validateTree(Container.java:1096)
         at java.awt.Container.validateTree(Container.java:1096)
         at java.awt.Container.validateTree(Container.java:1096)
         at java.awt.Container.validateTree(Container.java:1096)
         at java.awt.Container.validateTree(Container.java:1096)
         at java.awt.Container.validateTree(Container.java:1096)
         at java.awt.Container.validateTree(Container.java:1096)
         at java.awt.Container.validateTree(Container.java:1096)
         at java.awt.Container.validateTree(Container.java:1096)
         at java.awt.Container.validate(Container.java:1064)
         at java.awt.Window.show(Window.java:455)
         at java.awt.Component.show(Component.java:1134)
         at java.awt.Component.setVisible(Component.java:1089) <=====
         at mtu.gui.Test.test_03(Test.java:56)
         at mtu.gui.Test.main(Test.java:29)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         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.
    PC&#178;

  • JTable help needed!!!

    I want to display JTextArea
    which should be scrollable. each cell of my JTable contains a JTextArea and I want to have scrollbars appear only for those JTextArea where the text doesn't fit in the JTextArea. I have tried using Cell Renderer JTextArea in ScrollPane, but still the scroll bars doesn't appear. I have put my JTable in a scrollPane. But I also need scrollBars to appear for my individual JTextAreas in the cells. Any help is appreciated. Here is a small code and hope it helps:
    public class MultiLineCellRenderer extends JTextArea implements TableCellRenderer{
    public MultiLineCellRenderer() {
    setLineWrap(true);
    setWrapStyleWord(true);
    setOpaque(true);
    setAutoscrolls(true);
    JScrollPane treeEditorPane = new JScrollPane( this,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    can any one help me in getting the scroll bars on my JTextArea too. In my main program I am doing this
    JScrollPane scroll = new JScrollPane( table );
    it puts scrollbars arround the whole table but I also need scrollbars to come arround each JTextArea too.
    Thanks for any help

    Try something like this:
    <pre>
    package com.hbo.common.ui;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.border.*;
    import java.awt.*;
    * @version 1.0 11/09/98
    public class MultiLineCellRenderer extends JTextArea implements TableCellRenderer {
    public MultiLineCellRenderer() {
    setLineWrap(true);
    setWrapStyleWord(true);
    setOpaque(true);
    private int cellSpace = 40;
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
    if (isSelected) {
    setForeground(table.getSelectionForeground());
    setBackground(table.getSelectionBackground());
    } else {
    setForeground(table.getForeground());
    setBackground(table.getBackground());
    setFont(table.getFont());
    if (hasFocus) {
    setBorder( UIManager.getBorder("Table.focusCellHighlightBorder") );
    if (table.isCellEditable(row, column)) {
    setForeground( UIManager.getColor("Table.focusCellForeground") );
    setBackground( UIManager.getColor("Table.focusCellBackground") );
    } else {
    setBorder(new EmptyBorder(1, 2, 1, 2));
    setText((value == null) ? "" : value.toString());
    setToolTipText((value == null) ? "" : stringToHtml(value.toString()));
    return this;
    public String stringToHtml(String aString) {
              String aStringToReturn = "<HTML><BODY>";
              while (findNextSpace(aString, cellSpace) > -1) {
                   int i = findNextSpace(aString, cellSpace);
                   aStringToReturn += aString.substring(0, i) + "<P>";
                   aString = aString.substring(i);
              aStringToReturn += aString;
              aStringToReturn += "</BODY></HTML>";
              return aStringToReturn;
         public static int findNextSpace(String s, int i) {
    int index = -1;
    if (s == null || s.length() < i ) {
    return index;
    index = i;
    while (s.length() > (index + 1) ) {
    String st = s.substring(index, index+1);
    if (st.equals(" ") || st.equals("\n")) {
         break;
    index++;
    return index;
    </pre>

  • Major Jtable help needed

    Hello all,
    i am trying to extend the JTable class to create a table in which i can enter numbers. I would also like to channge the default renderer so i can change the colours of the cell lines. Aslo, i would like to add colum headers and row headers. I want the colum and row headers to be namesd after the dimensions passed to the new Table class. This may seem trivial to some, but i cant seem to get it going. I know i should have to extend the abstract table model, but i dont know what to put into it.
    The only bit of code i have got going so far which definatly works in the class definition. I cant seem to find any good documentation about how to do the abogve...the sun tutorial only confuses me..could anyone please please help.
    Thanks in advance, regards, Rupesh
    public class SpreadTable extends JTable {
         private CellRenderer _renderer;
         public SpreadTable(int x, int y){
              super(x,y);
              setCellSelectionEnabled(true);
      public boolean isCellEditable(int row, int column) {return true;}

    Hi - thanks for your post. I would be eager to see some of your furure results. I have been trying to get my Table to have editable cells, and trying to get the cells to be of a different size, and colour, and have finally come up with some code, but it doesnt seem to work. This error i get is
    .\SpreadTable.java:58: cannot resolve symbol
    symbol : method getTableCellRendererComponent (SpreadTable.CellRenderer,java.l
    ng.Object,boolean,boolean,int,int)
    location: class javax.swing.JLabel
    super.getTableCellRendererComponent(this, value, isSelected, ha
    Focus, row, column);
    ^
    1 error
    Here is the code.
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class SpreadTable extends JTable {
         private CellRenderer renderer;
         public SpreadTable(int x, int y){
              super(x,y);
              setCellSelectionEnabled(true);
              renderer = new CellRenderer();
              try {
             setDefaultRenderer(Class.forName("java.lang.Object" ), renderer );
         } catch (ClassNotFoundException ex) {
             System.out.println("SpreadSheet() Can't modify renderer");
         TableColumn       aColumn   = getColumnModel().getColumn(0);
         TableCellRenderer aRenderer = getTableHeader().getDefaultRenderer();
        Component aComponent = aRenderer.getTableCellRendererComponent(this,
                                              aColumn.getHeaderValue(),
                                              false, false, -1, 0);
      public boolean isCellEditable(int row, int column) {return true;}
       public class CellRenderer extends JLabel implements TableCellRenderer  {
          private LineBorder  selectBorder;
          private EmptyBorder emptyBorder;
          private Dimension   dim;
          public CellRenderer() {
         super();
         emptyBorder  = new EmptyBorder(1, 2, 1, 2);
         selectBorder = new LineBorder(Color.red);
         setOpaque(true);
         setHorizontalAlignment(SwingConstants.CENTER);
         dim = new Dimension();
         dim.height = 22;
         dim.width  = 100;
         setSize(dim);
          public Component getTableCellRendererComponent (JTable table, Object value,
                                        boolean isSelected,
                                        boolean hasFocus,
                                        int row, int column) {
              super.getTableCellRendererComponent(this, value, isSelected, hasFocus, row, column);
              if (isSelected) {
           setBorder(selectBorder);
         } else {
           setBorder(emptyBorder);
         return this;
    }

  • Adding Image in JTable - help needed(Urgent).

    Hai Friends,
    i want to add two icon in the cells of JTable... i dont know where am going wrong... the icon is not getting displayed in the cell but instead if i double click the cell the name of the icon is displayed in editable mode... any suggestion...
    this is my code... i got this from the forum only... but tis not working....
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TableIcon extends JFrame
         public TableIcon()
              String[] columnNames = {"Picture", "Description"};
              Object[][] data =
                   {new ImageIcon("juggler.ico"), "Copy"},
                   {new ImageIcon("favicon.gif"), "Add"},
              DefaultTableModel model = new DefaultTableModel(data, columnNames);
              JTable table = new JTable( model )
                   //  Returning the Class of each column will allow different
                   //  renderers to be used based on Class
                   public Class getColumnClass(int column)
          System.out.println("getValueAt(0, column)"+getValueAt(0, 0));
                        return getValueAt(0, 0).getClass();
              table.setPreferredScrollableViewportSize(table.getPreferredSize());
              JScrollPane scrollPane = new JScrollPane( table );
              getContentPane().add( scrollPane );
         public static void main(String[] args)
              TableIcon frame = new TableIcon();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible(true);
    }Urgent... pls help...
    Regards,
    Ciya.

    Hai Chris,
    Thanks for ur reply,
    Now Its throwing null pointer exception in the URL....
    Can u pls look into d code and tell me pls...
    import java.awt.Component;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.Insets;
    import java.net.URL;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.table.TableCellRenderer;
    public class MyIcon extends JPanel
      private JScrollPane jScrollPane1 = new JScrollPane();
      private JTable jTable1;
      private GridBagLayout gridBagLayout1 = new GridBagLayout();
      public MyIcon()
        try
          jbInit();
        catch(Exception e)
          e.printStackTrace();
      private void jbInit() throws Exception
        this.setLayout(gridBagLayout1);
        jTable1 = new JTable(new AbstractTableModel()
         URL lURL = getClass().getResource("file:///D:/Eg/TWEETY.GIF");
          URL lURL2 = getClass().getResource("file:///D:/Eg/TWEETY.GIF");
        Object[][] data =
            {new ImageIcon(lURL), "Copy"},
            {new ImageIcon(lURL), "Add"},
          public int getRowCount()
            return 2;
         public int getColumnCount()
           return 2;
         public Object getValueAt(int row, int column)
           return data[row][column];
        jTable1.getColumnModel().getColumn(0).setCellRenderer(new Renderer());
        jScrollPane1.getViewport().add(jTable1, null);
        this.add(jScrollPane1, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(60, 20, 125, 25), -97, -287));
      public static void main(String a[])
        MyIcon c = new MyIcon();
        JFrame f = new JFrame();
        f.getContentPane().add(c);
        f.setSize(400,400);
        f.setVisible(true);
      class Renderer extends JLabel implements TableCellRenderer {
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected,
    boolean hasFocus,
    int row, int column) {
    setIcon((ImageIcon) value);
    return this;
    }Ciya...

  • JTable -  Horizontal Scrollbar - Column Width

    I wish to add a horizontal scrollbar(which for some stupid reason Java has not included) to my JTable which is inside a JScrollPane and also make sure that the width of the fourth column is longer and can fit the String that i wish to display. Now, i have searched the forum for solutions but none of them seem to work. The setting of the column width with the help of TableColumnModel does not seem to work and not to mention the fact that when i turn auto rezise off for the JTable, the JTable does give me a horizontal scrollbar but then it makes the columns so less in width that i have gray area left on the right hand side and the setColumnsToFit method does not work. I have five columns and here is the code, any help would be greatly appreciated Thanks:
    excepTable = new JTable(excepTableModel);
    excepTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    int width = 100;
    TableColumnModel tcm;
    TableColumn tc;
    for(int i = excepTable.getColumnCount(); i > 0; i--)
    tcm = (TableColumnModel)excepTable.getColumnModel();
    tc = tcm.getColumn(i);
    if(i == 3)
    width = 400;
    tc.setWidth(width);
    tc.setMinWidth(width);
    tc.setMaxWidth(width);
    tc.setPreferredWidth(width);
    width = 100;
    exScroller = new JScrollPane(excepTable);

    .I've set a horizontal scrollbar by using 'table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);You are welcome.
    i want the column widht to be adjusted according to the length of column names and record length.so please tell me how to do it?Search the forum. This question has been asked and answered before.

  • 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

  • Set JTable column width

    Hi,
    I would like to set the column width of JTable.
    ========================================
    JTable table;
    DefaultTableModel tableModel;
    tableModel = new DefaultTableModel();
    table = new JTable( tableModel);
    JScrollPane scrollPane = new JScrollPane(table);
    for(int i = 0; i < heading.length; i++)
    tableModel.addColumn( heading[ i ]);
    ========================================

    Did you run the tutorial code? Did it work?
    Now compare the tutorial code with your code to determine what is different.
    We can't tell you what is different based on the one line of code you posted:
    colModel.getColumn(i).setPreferredWidth(100);

  • Column width issue in SharePoint 2010 Reports using SSRS webpart

    Dear sir,
    We need to adjust column width for output of reports. We are using SSRS webpart to generate reports. It is taking unexpected column width.
    We show that dynamically we cannot set the column width but we are passing the query statically is there any way or chances to mange column width.
    Please help.

    If it's important, I'd suggest ringing Microsoft Premier Support and logging a call.  The working world is probably just getting back to their offices.
    For both columns, you can think about some JQuery to isolate the appropriate selectors and just reside them in the page rendering.  You'll need JavaScript enabled in your browser for this but this code within a CEWP should do the trick. 
    <!--ADJUST TABLE COLUMN WIDTH-->
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"
    type="text/javascript"></script>
    <script type="text/javascript">
    $(function(){
    $("TH.ms-vh2-nograd:contains('Status description')").css("width", "150px");
    $("TH.ms-vb:contains('Type of Work')").css("width", "150px");
    </script>
    You'll need to link to a JQuery instance of course and change the capture text for your columns.
    Credit to the code to Kjell-Sverre Jerijærvi from his
    blog post.
    Steven Andrews
    SharePoint Business Analyst: LiveNation Entertainment
    Blog: baron72.wordpress.com
    Twitter: Follow @backpackerd00d
    My Wiki Articles:
    CodePlex Corner Series
    Please remember to mark your question as "answered" if this solves (or helps) your problem.

  • Controlling Column Width in Report Region

    I have a report region based on a simple select statement. I'd like the table to be the full width of the region and I'd like the columns to be spaced evenly so that they are also the full width of the region. I have figured out how to set the table width via Report Attributes Substitution, but I am unable to set the column width. Any help would be greatly appreciated.
    Mark

    Hi take a look into this post:
    Translated in English:
    http://translate.google.de/translate?sl=de&tl=en&js=n&prev=_t&hl=de&ie=UTF-8&layout=2&eotf=1&u=http%3A%2F%2Fwww.apex-at-work.com%2F2010%2F08%2Fsilbentrennung-hyphenation-in-apex-ger.html
    Code must be extracted from Original post:
    http://www.apex-at-work.com/2010/08/silbentrennung-hyphenation-in-apex-ger.html
    This could be also interesting for your:
    http://www.apex-at-work.com/2010/03/automatic-linebreak-if-word-breaks-out.html
    Tobias
    http://apex-at-work.com

  • How to size JTable Column width?? Need help

    Using the following logic to size column width, but only the 1st column is sized. How can I get the other columns sized??
    int widthsSummary[] = {340,60,150,60,60};
    for (int i=0; i<1; i++)
    column = getScrollPaneTableSummary).getColumnModel ().getColumn(i);
    column.setMinWidth(widthsSummary);
    column.setMaxWidth(widthsSummary[i]+50);
    column.setPreferredWidth(widthsSummary[i]);          

    First, take a look at your for loop
    for (int i=0; i<1; i++)i starts at 0 and cannot be equal to or greater than 1. This loop will only occur once, when i = 0.
    Second, take a look at your set...Width calls
    column.setMinWidth(widthsSummary);
    column.setMaxWidth(widthsSummary+50);
    column.setPreferredWidth(widthsSummary); widthsSummary is an array. You need a number to set widths. Try ...set...width(widthsSummary);
    Hope that helps.

Maybe you are looking for