Hi Daniel,

Which version of ULC are you using?

I am unable to reproduce your problem.

In both the cases I am seeing the column header of  testTable in
columnHeaderView.

Can you please modify the snippet below to demonstrate the problem or point
out if I am missing something?

Thanks and regards,

Janak

>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] Behalf Of
>[EMAIL PROTECTED]
>Sent: Monday, April 02, 2007 5:59 PM
>To: [email protected]
>Cc: [EMAIL PROTECTED]
>Subject: [ULC-developer] Possible Bug in ULCScrollPane setting Views
>
>
>Hello!
>
>There may be a little bug concerning the ULCScrollpane. Setting the
>RowHeaderView, ViewPortView and ColumnHeaderView with the given setter
>methods of ULCScrollPane is order relevant. That means, if I set the the
>scrollpane as follows ...
>
>  TestTable testTable = new TestTable();
>  myScrollPane.setViewPortView(testTable );
>  myScrollPane.setColumnHeaderView(testTable.getTableHeader());
>  myScrollPane.setRowHeaderView(new RowHeaderTable());
>  myScrollPane.setCorner(ULCScrollPane.UPPER_LEFT_CORNER, emptyButton);
>
>... it only shows the rowHeaderTable for ColumnHeaderView and
>RowHeaderView. Now if I set it the following way, it works:
>
>  TestTable testTable = new TestTable();
>  myScrollPane.setRowHeaderView(new RowHeaderTable());
>  myScrollPane.setCorner(ULCScrollPane.UPPER_LEFT_CORNER, emptyButton);
>  myScrollPane.setViewPortView(testTable );
>  myScrollPane.setColumnHeaderView(testTable.getTableHeader());
>
>It seems that setting the RowHeaderView overwrites the ColumnHeaderView.
>
>Greetings and best regards,
>Daniel

import com.ulcjava.base.application.AbstractApplication;
import com.ulcjava.base.application.ULCBoxPane;
import com.ulcjava.base.application.ULCButton;
import com.ulcjava.base.application.ULCFrame;
import com.ulcjava.base.application.ULCListSelectionModel;
import com.ulcjava.base.application.ULCScrollPane;
import com.ulcjava.base.application.ULCTable;
import com.ulcjava.base.application.table.AbstractTableModel;
import com.ulcjava.base.application.util.Dimension;
import com.ulcjava.base.development.DevelopmentRunner;


public class ULCFixedColumnExample extends AbstractApplication {

    private ULCFrame frame;

    Object[][] data;
    Object[] column;
    ULCTable fixedTable, table;

    public ULCFixedColumnExample() {
    }

    public void start() {

        frame = new ULCFrame("Fixed Column Example");
        frame.setSize(new Dimension(400, 150));

        column = new Object[] { "fixed 1", "fixed 2", "flexi 1", "flexi 2"
/*, "c", "d", "e", "f" */};
        data = createData(1000, column.length);

        AbstractTableModel fixedModel = new AbstractTableModel() {
            // We have two fixed rows so report 2 columns from data
            public int getColumnCount() {
                return 2;
            }

            public int getRowCount() {
                return data.length;
            }

            public String getColumnName(int col) {
                return (String)column[col];
            }

            // As only the first two columns are reported this can stay
            // the same
            public Object getValueAt(int row, int col) {
                return data[row][col];
            }

            public void setValueAt(Object obj, int row, int col) {
                // As above
                data[row][col] = obj;
            }

            public boolean isCellEditable(int row, int col) {
                return true;
            }
        };

        AbstractTableModel model = new AbstractTableModel() {
            // This model has two less columns in the data as two are
            // fixed
            public int getColumnCount() {
                return column.length - 2;
            }

            public int getRowCount() {
                return data.length;
            }

            public String getColumnName(int col) {
                // The columns start 2 on in the data
                return (String)column[col + 2];
            }

            public Object getValueAt(int row, int col) {
                // The first two column are for the fixed table so return
                // data after by adding 2
                return data[row][col + 2];
            }

            public void setValueAt(Object obj, int row, int col) {
                // As above
                data[row][col + 2] = obj;
            }

            public boolean isCellEditable(int row, int col) {
                return true;
            }
        };

        fixedTable = new ULCTable(fixedModel);
        fixedTable.setPreferredScrollableViewportSize(new Dimension(150,
0));
        ULCListSelectionModel lsm = fixedTable.getSelectionModel();
        fixedTable.getTableHeader().setResizingAllowed(false);
        fixedTable.setAutoResizeMode(ULCTable.AUTO_RESIZE_OFF);
        fixedTable.setSelectionMode(ULCListSelectionModel.SINGLE_SELECTION);

        table = new ULCTable(model, null, lsm);
        table.setAutoResizeMode(ULCTable.AUTO_RESIZE_OFF);
        table.setSelectionMode(ULCListSelectionModel.SINGLE_SELECTION);

        ULCScrollPane scroll = new ULCScrollPane();
        /* original
        scroll.setViewPortView(table);
        scroll.setRowHeaderView(fixedTable);
        scroll.setCorner(ULCScrollPane.UPPER_LEFT_CORNER,
fixedTable.getTableHeader());
        frame.getContentPane().add(scroll);
        */

        /* first case not working
        scroll.setViewPortView(table);
        scroll.setColumnHeaderView(table.getTableHeader());
        scroll.setRowHeaderView(fixedTable);
        scroll.setCorner(ULCScrollPane.UPPER_LEFT_CORNER, new
ULCButton("Corner"));
       */


        ///* second case working
        scroll.setRowHeaderView(fixedTable);
        scroll.setCorner(ULCScrollPane.UPPER_LEFT_CORNER, new
ULCButton("Corner"));
        scroll.setViewPortView(table);
        scroll.setColumnHeaderView(table.getTableHeader());
       //*/

        frame.getContentPane().add(scroll);
        frame.setVisible(true);
    }

    private Object[][] createData(int row, int col) {
        Object[][] data = new Object[row][col];
        for (int i = 0; i < row; i++) {
            for (int j = 0; j < col; j++) {
                data[i][j] = Integer.toString(i) + Integer.toString(j);
            }
        }
        return data;
    }

    public static void main(String[] args) {
        DevelopmentRunner.setApplicationClass(ULCFixedColumnExample.class);
        DevelopmentRunner.run();
    }

}

_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to