My final version of a table with row headers and column footers

This version is superior to the one I posted yesterday
as it is better designed and responds to changes in
size correctly. You can also have a header/footer with
multiple columns/rows.
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumnModel;
import java.awt.*;
import java.awt.event.AdjustmentListener;
import java.awt.event.AdjustmentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.ComponentEvent;
public class HeaderFooterTablePanel extends JPanel {
    static abstract class AbstractHeaderFooterTableModel extends AbstractTableModel {
        public abstract int getRowHeaderColumnCount();
        public abstract Object getRowHeaderValueAt(int rowIndex,
                                                   int columnIndex);
        public abstract int getFooterRowCount();
        public abstract Object getFooterValueAt(int rowIndex,
                                                int columnIndex);
    static class RowHeaderTableModel extends AbstractTableModel {
        private AbstractHeaderFooterTableModel abstractHeaderFooterTableModel;
        public RowHeaderTableModel(AbstractHeaderFooterTableModel abstractHeaderFooterTableModel) {
            super();
            this.abstractHeaderFooterTableModel = abstractHeaderFooterTableModel;
        public String getColumnName(int column) {
            return "";
        public int getColumnCount() {
            return abstractHeaderFooterTableModel.getRowHeaderColumnCount();
        public int getRowCount() {
            return abstractHeaderFooterTableModel.getRowCount();
        public Object getValueAt(int rowIndex, int columnIndex) {
            return abstractHeaderFooterTableModel.getRowHeaderValueAt(rowIndex, columnIndex);
    static class ColumnFooterTableModel extends AbstractTableModel {
        private AbstractHeaderFooterTableModel abstractHeaderFooterTableModel;
        public ColumnFooterTableModel(AbstractHeaderFooterTableModel abstractHeaderFooterTableModel) {
            super();
            this.abstractHeaderFooterTableModel = abstractHeaderFooterTableModel;
        public String getColumnName(int column) {
            return "";
        public int getColumnCount() {
            return abstractHeaderFooterTableModel.getColumnCount();
        public int getRowCount() {
            return abstractHeaderFooterTableModel.getFooterRowCount();
        public Object getValueAt(int rowIndex, int columnIndex) {
            return abstractHeaderFooterTableModel.getFooterValueAt(rowIndex, columnIndex);
    static class SyncColumnWidths implements TableColumnModelListener {
        private final JTable centerTable;
        private final JTable footerTable;
        public SyncColumnWidths(JTable centerTable,
                                JTable footerTable) {
            this.centerTable = centerTable;
            this.footerTable = footerTable;
        // Change the column widths of the footer table when the column widths
        // of the center table change.
        public void columnMarginChanged(ChangeEvent e) {
            TableColumnModel centerTableColumnModel = centerTable.getColumnModel();
            TableColumnModel footerTableColumnModel = footerTable.getColumnModel();
            for (int i = 0; i < centerTableColumnModel.getColumnCount(); i++) {
                int width = centerTableColumnModel.getColumn(i).getPreferredWidth();
                footerTableColumnModel.getColumn(i).setPreferredWidth(width);
        public void columnSelectionChanged(ListSelectionEvent e) {
        public void columnAdded(TableColumnModelEvent e) {
        public void columnMoved(TableColumnModelEvent e) {
        public void columnRemoved(TableColumnModelEvent e) {
    private JTable centerTable;
    private JTable rowHeaderTable;
    private JTable columnFooterTable;
    public HeaderFooterTablePanel(AbstractHeaderFooterTableModel abstractHeaderFooterTableModel) {
        super();
        // Create the center, rowHeader and columnFooter tables
        centerTable = new JTable(abstractHeaderFooterTableModel);
        rowHeaderTable = new JTable(new RowHeaderTableModel(abstractHeaderFooterTableModel));
        columnFooterTable = new JTable(new ColumnFooterTableModel(abstractHeaderFooterTableModel));
        // Disabled column re-ordering
        centerTable.getTableHeader().setReorderingAllowed(false);
        columnFooterTable.getTableHeader().setReorderingAllowed(false);
        // We are using scroll panes, so no auto resizing of table.
        centerTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        columnFooterTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        // Only allow the user to change the column widths from the center table, not the
        // columnFooter.
        columnFooterTable.getTableHeader().setResizingAllowed(false);
        // When the center table column widths change, change those in the columnFooter table.
        SyncColumnWidths syncColumnWidths = new SyncColumnWidths(centerTable, columnFooterTable);
        centerTable.getColumnModel().addColumnModelListener(syncColumnWidths);
        // Set the width of the row header before adding it to the center scroll pane
        // as the row header.
        Dimension rowHeaderSize = rowHeaderTable.getPreferredScrollableViewportSize();
        rowHeaderSize.width = rowHeaderTable.getPreferredSize().width;
        rowHeaderTable.setPreferredScrollableViewportSize(rowHeaderSize);
        rowHeaderTable.setRowHeight(centerTable.getRowHeight());
        // Create the center scroll pane and set the row header table as the row header.
        final JScrollPane centerScrollPane = new JScrollPane(centerTable);
        centerScrollPane.setRowHeaderView(rowHeaderTable);
        // We will handle horizontal scrolling with our own scrollbar.
        centerScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        // Now we create the panel to hold the columnFooter table and the horizontal
        // scrollbar.
        final JPanel columnFooterPanel = new JPanel(new BorderLayout());
        // Keep the space below the row header empty.
        Component westGlue = Box.createHorizontalStrut(rowHeaderSize.width);
        // Set height of the columnFooterTable before adding it to the columnFooter scroll pane
        // as the view.
        Dimension columnFooterSize = columnFooterTable.getPreferredScrollableViewportSize();
        columnFooterSize.height = columnFooterTable.getPreferredSize().height;
        columnFooterTable.setPreferredScrollableViewportSize(columnFooterSize);
        columnFooterTable.setRowHeight(centerTable.getRowHeight());
        // The scroll pane which holds the columnFooterTable.
        final JScrollPane columnFooterScrollPane = new JScrollPane(columnFooterTable);
        // We do our own horizontal scrolling and the columnFooterScrollPane never scrolls vertically.
        columnFooterScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        columnFooterScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
        // The scrollbar we use to scroll horizontally.
        final JScrollBar horizontalScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
        // Sync up all the scrolling. See the method for details.
        syncScrolling(centerScrollPane, horizontalScrollBar, columnFooterScrollPane);
        // Keep the space below the vertical scrollbar empty.
        final JScrollBar verticalScrollBar = centerScrollPane.getVerticalScrollBar();
        int verticalScrollBarWidth = verticalScrollBar.getPreferredSize().width;
        final Component eastGlue = Box.createHorizontalStrut(verticalScrollBarWidth);
        // Set the center viewport size to match to table size
        Dimension centerTablePreferredsize = centerTable.getPreferredSize();
        centerTable.setPreferredScrollableViewportSize(centerTablePreferredsize);
        centerScrollPane.getViewport().setSize(centerTablePreferredsize);
        // The panel that holds the columnFooterTable and the horizontal scrollbar below it.
        final JPanel footerPanel = new JPanel(new BorderLayout());
        footerPanel.add("North", columnFooterScrollPane);
        footerPanel.add("South", horizontalScrollBar);
        footerPanel.setMinimumSize(footerPanel.getPreferredSize());
        // Assemble our columnFooterPanel.
        columnFooterPanel.add("West", westGlue);
        columnFooterPanel.add("Center", footerPanel);
        columnFooterPanel.add("East", eastGlue);
        // This keeps the columnFooterPanel at its minimum height
        JPanel northPanel = new JPanel(new BorderLayout());
        northPanel.add("North", columnFooterPanel);
        // Assemble the center scroll pane, below it the panel containing the column
        // footer panel, and then vertical glue to eat up any available vertical space.
        Box box = Box.createVerticalBox();
        box.add(centerScrollPane);
        box.add(northPanel);
        box.add(Box.createVerticalGlue());
        // Hide/show the eastGlue and the horizontalScrollBar, and recalculate the
        // minimum size of the footerPanel in response to size and visibility changes.
        syncScrollBarVisibility(centerScrollPane, eastGlue, horizontalScrollBar, footerPanel);
        setLayout(new BorderLayout());
        add("Center", box);
    private void syncScrollBarVisibility(final JScrollPane centerScrollPane,
                                         final Component eastGlue,
                                         final JScrollBar horizontalScrollBar,
                                         final JPanel footerPanel) {
        // Hide/show the eastGlue accoring to whether or not the vertical scrollbar
        // is visible.
        centerScrollPane.getVerticalScrollBar().addComponentListener(new ComponentListener() {
            private void checkVisibleStatus(boolean b) {
                if (eastGlue.isVisible() != b) {
                    eastGlue.setVisible(b);
            public void componentHidden(ComponentEvent e) {
                checkVisibleStatus(false);
            public void componentMoved(ComponentEvent e) {
            public void componentResized(ComponentEvent e) {
            public void componentShown(ComponentEvent e) {
                checkVisibleStatus(true);
        // Hide/show the horizontal scrollbar according to whether or not it's needed.
        centerScrollPane.getViewport().addComponentListener(new ComponentListener() {
            public void componentHidden(ComponentEvent e) {
            public void componentMoved(ComponentEvent e) {
            public void componentResized(ComponentEvent e) {
                int centerScrollPaneWidth = centerScrollPane.getViewport().getSize().width;
                int centerTablePreferredWidth = centerTable.getPreferredSize().width;
                if (centerScrollPaneWidth >= centerTablePreferredWidth) {
                    horizontalScrollBar.setVisible(false);
                } else {
                    horizontalScrollBar.setVisible(true);
            public void componentShown(ComponentEvent e) {
        // Set the minimum size of the footerPanel according to whether or not the
        // horizontalScrollBar is visible.
        horizontalScrollBar.addComponentListener(new ComponentListener() {
            public void componentHidden(ComponentEvent e) {
                footerPanel.setMinimumSize(footerPanel.getPreferredSize());
            public void componentMoved(ComponentEvent e) {
            public void componentResized(ComponentEvent e) {
            public void componentShown(ComponentEvent e) {
                footerPanel.setMinimumSize(footerPanel.getPreferredSize());
    private void syncScrolling(final JScrollPane centerScrollPane,
                               final JScrollBar columnFooterScrollBar,
                               final JScrollPane columnFooterScrollPane) {
        // When the view of the center scroll pane changes position,
        // change the value of the columnFooterScrollBar to match.
        centerScrollPane.getViewport().addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                int x = ((Component) e.getSource()).getLocation().x * -1;
                JViewport viewport = (JViewport) e.getSource();
                int extentWidth = viewport.getExtentSize().width;
                int viewWidth = viewport.getViewSize().width;
                int value = Math.max(0, Math.min(viewport.getViewPosition().x, viewWidth - extentWidth));
                columnFooterScrollBar.setValues(value, extentWidth, 0, viewWidth);
        // When the columnFooterScrollBar (horizontal scroll bar) value changes,
        // change the position of the view in the center scroll pane to match.
        columnFooterScrollBar.addAdjustmentListener(new AdjustmentListener() {
            public void adjustmentValueChanged(AdjustmentEvent e) {
                JViewport viewport = centerScrollPane.getViewport();
                viewport.setViewPosition(new Point(e.getValue(), viewport.getViewPosition().y));
                viewport = columnFooterScrollPane.getViewport();
                viewport.setViewPosition(new Point(e.getValue(), viewport.getViewPosition().y));
        // When the view of the row header changes position,
        // change the value of the vertical scrollbar of the center
        // scroll pane to match.
        centerScrollPane.getRowHeader().addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                JViewport viewport = (JViewport) e.getSource();
                int extentHeight = viewport.getExtentSize().height;
                int viewHeight = viewport.getViewSize().height;
                int value = Math.max(0, Math.min(viewport.getViewPosition().y, viewHeight - extentHeight));
                centerScrollPane.getVerticalScrollBar().setValues(value, extentHeight, 0, viewHeight);
    public JTable getCenterTable() {
        return centerTable;
    public JTable getRowHeaderTable() {
        return rowHeaderTable;
    private JTable getColumnFooterTable() {
        return columnFooterTable;
    public static void main(String[] args) {
        AbstractHeaderFooterTableModel tableModel = new AbstractHeaderFooterTableModel() {
            public int getRowCount() {
                return 25;
            public int getColumnCount() {
                return 10;
            public Object getValueAt(int rowIndex, int columnIndex) {
                return "Cell " + rowIndex + ":" + columnIndex;
            public String getColumnName(int column) {
                return "Column #" + column;
            public Object getRowHeaderValueAt(int rowIndex, int columnIndex) {
                return "Header " + rowIndex + ":" + columnIndex;
            public int getRowHeaderColumnCount() {
                return 2;
            public Object getFooterValueAt(int rowIndex, int columnIndex) {
                return "Footer " + rowIndex + ":" + columnIndex;
            public int getFooterRowCount() {
                return 3;
        JFrame frame = new JFrame();
        HeaderFooterTablePanel tablePanel = new HeaderFooterTablePanel(tableModel);
        // Render the cells in the row header and footer like the center table column headers.
        TableCellRenderer columnRenderer = tablePanel.getCenterTable().getTableHeader().getDefaultRenderer();
        tablePanel.getRowHeaderTable().setDefaultRenderer(Object.class, columnRenderer);
        tablePanel.getColumnFooterTable().setDefaultRenderer(Object.class, columnRenderer);
        frame.getContentPane().add("Center", tablePanel);
        frame.setSize(300, 300);
        frame.setLocation(300, 200);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
}

i was wondering why this topic has NO replies! and then i realized that there is NO question??? so do you have a question, or are you just starting a new thread cuz you feel like it???
just trying to work out why you didnt post this is the old thread???
http://forum.java.sun.com/thread.jspa?threadID=5130131&messageID=9466400#9466400

Similar Messages

  • My version of a table with row headers and column footers

    I checked the web and some java books over the
    weekend. Didn't find any examples so I'm
    probably not the only one wanting this.
    Here's my version:
    import javax.swing.*;
    import javax.swing.table.JTableHeader;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.table.TableColumnModel;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    public class RowHeaderColumnFooterTableExample extends JFrame {
        private static class TableDataModel extends AbstractTableModel {
            public TableDataModel() {
                super();
            public String getColumnName(int column) {
                return "Column #" + column;
            public Object getRowHeader(int rowIndex) {
                return "Row #" + rowIndex;
            public Object getRowFooter(int columnIndex) {
                return "Footer #" + columnIndex;
            public int getColumnCount() {
                return 25;
            public int getRowCount() {
                return 25;
            public Object getValueAt(int rowIndex, int columnIndex) {
                return "Cell " + rowIndex + ":" + columnIndex;
        private static class RowHeaderTableModel extends AbstractTableModel {
            private TableDataModel tableDataModel;
            public RowHeaderTableModel(TableDataModel tableDataModel) {
                super();
                this.tableDataModel = tableDataModel;
            public String getColumnName(int column) {
                return "";
            public int getColumnCount() {
                return 1;
            public int getRowCount() {
                return tableDataModel.getRowCount();
            public Object getValueAt(int rowIndex, int columnIndex) {
                return tableDataModel.getRowHeader(rowIndex);
        private static class FooterTableModel extends AbstractTableModel {
            private TableDataModel tableDataModel;
            public FooterTableModel(TableDataModel tableDataModel) {
                super();
                this.tableDataModel = tableDataModel;
            public String getColumnName(int column) {
                return tableDataModel.getRowFooter(column).toString();
            public int getColumnCount() {
                return tableDataModel.getColumnCount();
            public int getRowCount() {
                return 0;
            public Object getValueAt(int rowIndex, int columnIndex) {
                throw new RuntimeException("This model holds column names only - no values.");
        private static class SyncColumnWidths implements TableColumnModelListener {
            private final JTable centerTable;
            private final JTable footerTable;
            public SyncColumnWidths(JTable centerTable,
                                    JTable footerTable) {
                this.centerTable = centerTable;
                this.footerTable = footerTable;
            // Change the column widths of the footer table when the column widths
            // of the center table change.
            public void columnMarginChanged(ChangeEvent e) {
                TableColumnModel centerTableColumnModel = centerTable.getColumnModel();
                TableColumnModel footerTableColumnModel = footerTable.getColumnModel();
                for (int i = 0; i < centerTableColumnModel.getColumnCount(); i++) {
                    int width = centerTableColumnModel.getColumn(i).getPreferredWidth();
                    footerTableColumnModel.getColumn(i).setPreferredWidth(width);
            public void columnSelectionChanged(ListSelectionEvent e) {
            public void columnAdded(TableColumnModelEvent e) {
            public void columnMoved(TableColumnModelEvent e) {
            public void columnRemoved(TableColumnModelEvent e) {
        public RowHeaderColumnFooterTableExample() {
            super();
            // Create the main table data model
            TableDataModel tableDataModel = new TableDataModel();
            // Create the center, rowHeader and footer tables
            final JTable centerTable = new JTable(tableDataModel);
            final JTable rowHeaderTable = new JTable(new RowHeaderTableModel(tableDataModel));
            final JTable footerTable = new JTable(new FooterTableModel(tableDataModel));
            // Render the cells in the row header like the column headers.
            rowHeaderTable.setDefaultRenderer(Object.class, new JTableHeader().getDefaultRenderer());
            // Disabled column re-ordering
            centerTable.getTableHeader().setReorderingAllowed(false);
            footerTable.getTableHeader().setReorderingAllowed(false);
            // We are using scroll panes, so no auto resizing of table.
            centerTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            footerTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            // Only allow the user to change the column widths from the center table, not the
            // footer.
            footerTable.getTableHeader().setResizingAllowed(false);
            // When the center table column widths change, change those in the footer table.
            SyncColumnWidths syncColumnWidths = new SyncColumnWidths(centerTable, footerTable);
            centerTable.getColumnModel().addColumnModelListener(syncColumnWidths);
            // Set the width of the row header before adding it to the center scroll pane
            // as the row header.
            Dimension rowHeaderSize = rowHeaderTable.getPreferredScrollableViewportSize();
            rowHeaderSize.width = rowHeaderTable.getPreferredSize().width;
            rowHeaderTable.setPreferredScrollableViewportSize(rowHeaderSize);
            rowHeaderTable.setRowHeight(centerTable.getRowHeight());
            // Create the center scroll pane and set the row header table as the row header.
            final JScrollPane centerScrollPane = new JScrollPane(centerTable);
            centerScrollPane.setRowHeaderView(rowHeaderTable);
            // We will handle horizontal scrolling with our own scrollbar.
            centerScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
            // Now we create the panel to hold the footer table and the horizontal
            // scrollbar.
            JPanel footerPanel = new JPanel(new BorderLayout());
            // Keep the space below the row header empty.
            Component westStrut = Box.createHorizontalStrut(rowHeaderSize.width);
            // Set height of the footer table before adding it to the footer scroll pane
            // as the view.
            Dimension footerSize = footerTable.getPreferredScrollableViewportSize();
            footerSize.height = footerTable.getPreferredSize().height;
            footerTable.setPreferredScrollableViewportSize(footerSize);
            footerTable.setRowHeight(centerTable.getRowHeight());
            // The scroll pane which holds the footer table.
            final JScrollPane footerScrollPane = new JScrollPane(footerTable);
            // We do our own horizontal scrolling and the footer never scrolls vertically.
            footerScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
            footerScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
            // The scrollbar we use to scroll horizontally.
            final JScrollBar footerScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
            // The panel that holds the footer table and the horizontal scrollbar below it.
            JPanel footerCenterPanel = new JPanel(new GridLayout(2, 0));
            footerCenterPanel.add(footerScrollPane);
            footerCenterPanel.add(footerScrollBar);
            // Sync up all the scrolling. See the method for details.
            syncScrolling(centerScrollPane, footerScrollBar, footerScrollPane);
            // Keep the space below the vertical scrollbar empty.
            JScrollBar verticalScrollBar = centerScrollPane.getVerticalScrollBar();
            int verticalScrollBarWidth = verticalScrollBar.getPreferredSize().width;
            Component eastStrut = Box.createHorizontalStrut(verticalScrollBarWidth);
            // Assemble our footer Panel.
            footerPanel.add("West", westStrut);
            footerPanel.add("Center", footerCenterPanel);
            footerPanel.add("East", eastStrut);
            // Final assembly.
            Container contentPane = getContentPane();
            contentPane.setLayout(new BorderLayout());
            contentPane.add("Center", centerScrollPane);
            contentPane.add("South", footerPanel);
        private void syncScrolling(final JScrollPane centerScrollPane,
                                   final JScrollBar footerScrollBar,
                                   final JScrollPane footerScrollPane) {
            // When the view of the center scroll pane changes position,
            // change the value of the footer scrollbar to match.
            centerScrollPane.getViewport().addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    int x = ((Component) e.getSource()).getLocation().x * -1;
                    JViewport viewport = (JViewport) e.getSource();
                    int extentWidth = viewport.getExtentSize().width;
                    int viewWidth = viewport.getViewSize().width;
                    int value = Math.max(0, Math.min(viewport.getViewPosition().x, viewWidth - extentWidth));
                    footerScrollBar.setValues(value, extentWidth, 0, viewWidth);
            // When the footer scroll bar (horizontal scroll bar) value changes,
            // change the position of the view in the center scroll pane to match.
            footerScrollBar.addAdjustmentListener(new AdjustmentListener() {
                public void adjustmentValueChanged(AdjustmentEvent e) {
                    JViewport viewport = centerScrollPane.getViewport();
                    viewport.setViewPosition(new Point(e.getValue(), viewport.getViewPosition().y));
                    viewport = footerScrollPane.getViewport();
                    viewport.setViewPosition(new Point(e.getValue(), viewport.getViewPosition().y));
            // When the view of the row header changes position,
            // change the value of the vertical scrollbar of the center
            // scroll pane to match.
            centerScrollPane.getRowHeader().addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    JViewport viewport = (JViewport) e.getSource();
                    int extentHeight = viewport.getExtentSize().height;
                    int viewHeight = viewport.getViewSize().height;
                    int value = Math.max(0, Math.min(viewport.getViewPosition().y, viewHeight - extentHeight));
                    centerScrollPane.getVerticalScrollBar().setValues(value, extentHeight, 0, viewHeight);
        public static void main(String[] args) {
            RowHeaderColumnFooterTableExample rowHeaderColumnFooterTableExample = new RowHeaderColumnFooterTableExample();
            rowHeaderColumnFooterTableExample.setSize(300, 300);
            rowHeaderColumnFooterTableExample.setLocation(300, 200);
            rowHeaderColumnFooterTableExample.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            rowHeaderColumnFooterTableExample.setVisible(true);
    }null
    Message was edited by:
    NY_Consultant
    Message was edited by:
    NY_Consultant

    Just for reference, you can also check here for a RowHeader example
    http://www.crionics.com/products/opensource/faq/swing_ex/JTableExamples1.html
    and here for a column footer (or total row)
    http://www.crionics.com/products/opensource/faq/swing_ex/JTableExamples3.html
    as well as numerous other useful ideas. The source can also be found at
    http://www.physci.org/codes/tame/
    though without the screen shots.

  • How to create a datatable with row headers and column headers

    Hi,
    I am trying to create a two dimensional datatable which has both column headers and row headers. using <h:datatable> i could create a datatable with only column headers.
    Thanks in advance

    Are you saying that you want a column with only th's? You could also just apply some CSS on that specific column that its rows look like headers.

  • Repeat header's column in a table with row height that greater then 200px

    == Issue
    ==
    I have another kind of problem with Firefox
    == Description
    ==
    I develop a website and encounter some problem about web page printing. I try to repeat header's column in a table with row's height that greater than or equal to 198px, but it doesn't work. Another size that lower than 198px works fine. If somebody has seen this issue before and know a solution, please help me. Thanks in advance.
    == This happened
    ==
    Every time Firefox opened
    == Firefox version
    ==
    3.6.6
    == Operating system
    ==
    Windows XP
    == User Agent
    ==
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6
    == Plugins installed
    ==
    *-6.0.12.1739
    *RealPlayer(tm) LiveConnect-Enabled Plug-In
    *PDF-XChange Viewer Netscape Gecko Plugin
    *Default Plug-in
    *Shockwave Flash 8.0 r22
    *Adobe Shockwave for Director Netscape plug-in, version 11.0
    *3.0.40624.0
    *Office Live Update v1.3
    *Windows Presentation Foundation (WPF) plug-in for Mozilla browsers
    *Next Generation Java Plug-in 1.6.0_18 for Mozilla browsers
    *Npdsplay dll
    *DRM Store Netscape Plugin
    *DRM Netscape Network Object

    Try posting at the Web Development / Standards Evangelism forum at MozillaZine. The helpers over there are more knowledgeable about web page development issues with Firefox.
    [http://forums.mozillazine.org/viewforum.php?f=25]
    You'll need to register and login to be able to post in that forum.

  • Row chaining in table with more than 255 columns

    Hi,
    I have a table with 1000 columns.
    I saw the following citation: "Any table with more then 255 columns will have chained
    rows (we break really wide tables up)."
    If I insert a row populated with only the first 3 columns (the others are null), is a row chaining occurred?
    I tried to insert a row described above and no row chaining occurred.
    As I understand, a row chaining occurs in a table with 1000 columns only when the populated data increases
    the block size OR when more than 255 columns are populated. Am I right?
    Thanks
    dyahav

    user10952094 wrote:
    Hi,
    I have a table with 1000 columns.
    I saw the following citation: "Any table with more then 255 columns will have chained
    rows (we break really wide tables up)."
    If I insert a row populated with only the first 3 columns (the others are null), is a row chaining occurred?
    I tried to insert a row described above and no row chaining occurred.
    As I understand, a row chaining occurs in a table with 1000 columns only when the populated data increases
    the block size OR when more than 255 columns are populated. Am I right?
    Thanks
    dyahavYesterday, I stated this on the forum "Tables with more than 255 columns will always have chained rows." My statement needs clarification. It was based on the following:
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/schema.htm#i4383
    "Oracle Database can only store 255 columns in a row piece. Thus, if you insert a row into a table that has 1000 columns, then the database creates 4 row pieces, typically chained over multiple blocks."
    And this paraphrase from "Practical Oracle 8i":
    V$SYSSTAT will show increasing values for CONTINUED ROW FETCH as table rows are read for tables containing more than 255 columns.
    Related information may also be found here:
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96524/c11schem.htm
    "When a table has more than 255 columns, rows that have data after the 255th column are likely to be chained within the same block. This is called intra-block chaining. A chained row's pieces are chained together using the rowids of the pieces. With intra-block chaining, users receive all the data in the same block. If the row fits in the block, users do not see an effect in I/O performance, because no extra I/O operation is required to retrieve the rest of the row."
    http://download.oracle.com/docs/html/B14340_01/data.htm
    "For a table with several columns, the key question to consider is the (average) row length, not the number of columns. Having more than 255 columns in a table built with a smaller block size typically results in intrablock chaining.
    Oracle stores multiple row pieces in the same block, but the overhead to maintain the column information is minimal as long as all row pieces fit in a single data block. If the rows don't fit in a single data block, you may consider using a larger database block size (or use multiple block sizes in the same database). "
    Why not a test case?
    Create a test table named T4 with 1000 columns.
    With the table created, insert 1,000 rows into the table, populating the first 257 columns each with a random 3 byte string which should result in an average row length of about 771 bytes.
    SPOOL C:\TESTME.TXT
    SELECT
      SN.NAME,
      MS.VALUE
    FROM
      V$MYSTAT MS,
      V$STATNAME SN
    WHERE
      SN.NAME = 'table fetch continued row'
      AND SN.STATISTIC#=MS.STATISTIC#;
    INSERT INTO T4 (
    COL1,
    COL2,
    COL3,
    COL255,
    COL256,
    COL257)
    SELECT
    DBMS_RANDOM.STRING('A',3),
    DBMS_RANDOM.STRING('A',3),
    DBMS_RANDOM.STRING('A',3),
    DBMS_RANDOM.STRING('A',3)
    FROM
      DUAL
    CONNECT BY
      LEVEL<=1000;
    SELECT
      SN.NAME,
      MS.VALUE
    FROM
      V$MYSTAT MS,
      V$STATNAME SN
    WHERE
      SN.NAME = 'table fetch continued row'
      AND SN.STATISTIC#=MS.STATISTIC#;
    SET AUTOTRACE TRACEONLY STATISTICS
    SELECT
    FROM
      T4;
    SET AUTOTRACE OFF
    SELECT
      SN.NAME,
      SN.STATISTIC#,
      MS.VALUE
    FROM
      V$MYSTAT MS,
      V$STATNAME SN
    WHERE
      SN.NAME = 'table fetch continued row'
      AND SN.STATISTIC#=MS.STATISTIC#;
    SPOOL OFFWhat are the results of the above?
    Before the insert:
    NAME                      VALUE                                                
    table fetch continue        166
    After the insert:
    NAME                      VALUE                                                
    table fetch continue        166                                                
    After the select:
    NAME                 STATISTIC#      VALUE                                     
    table fetch continue        252        332  Another test, this time with an average row length of about 12 bytes:
    DELETE FROM T4;
    COMMIT;
    SPOOL C:\TESTME2.TXT
    SELECT
      SN.NAME,
      MS.VALUE
    FROM
      V$MYSTAT MS,
      V$STATNAME SN
    WHERE
      SN.NAME = 'table fetch continued row'
      AND SN.STATISTIC#=MS.STATISTIC#;
    INSERT INTO T4 (
      COL1,
      COL256,
      COL257,
      COL999)
    SELECT
    DBMS_RANDOM.STRING('A',3),
    DBMS_RANDOM.STRING('A',3),
    DBMS_RANDOM.STRING('A',3),
    DBMS_RANDOM.STRING('A',3)
    FROM
      DUAL
    CONNECT BY
      LEVEL<=100000;
    SELECT
      SN.NAME,
      MS.VALUE
    FROM
      V$MYSTAT MS,
      V$STATNAME SN
    WHERE
      SN.NAME = 'table fetch continued row'
      AND SN.STATISTIC#=MS.STATISTIC#;
    SET AUTOTRACE TRACEONLY STATISTICS
    SELECT
    FROM
      T4;
    SET AUTOTRACE OFF
    SELECT
      SN.NAME,
      SN.STATISTIC#,
      MS.VALUE
    FROM
      V$MYSTAT MS,
      V$STATNAME SN
    WHERE
      SN.NAME = 'table fetch continued row'
      AND SN.STATISTIC#=MS.STATISTIC#;
    SPOOL OFFWith 100,000 rows each containing about 12 bytes, what should the 'table fetch continued row' statistic show?
    Before the insert:
    NAME                      VALUE                                                
    table fetch continue        332 
    After the insert:
    NAME                      VALUE                                                
    table fetch continue        332
    After the select:
    NAME                 STATISTIC#      VALUE                                     
    table fetch continue        252      33695The final test only inserts data into the first 4 columns:
    DELETE FROM T4;
    COMMIT;
    SPOOL C:\TESTME3.TXT
    SELECT
      SN.NAME,
      MS.VALUE
    FROM
      V$MYSTAT MS,
      V$STATNAME SN
    WHERE
      SN.NAME = 'table fetch continued row'
      AND SN.STATISTIC#=MS.STATISTIC#;
    INSERT INTO T4 (
      COL1,
      COL2,
      COL3,
      COL4)
    SELECT
    DBMS_RANDOM.STRING('A',3),
    DBMS_RANDOM.STRING('A',3),
    DBMS_RANDOM.STRING('A',3),
    DBMS_RANDOM.STRING('A',3)
    FROM
      DUAL
    CONNECT BY
      LEVEL<=100000;
    SELECT
      SN.NAME,
      MS.VALUE
    FROM
      V$MYSTAT MS,
      V$STATNAME SN
    WHERE
      SN.NAME = 'table fetch continued row'
      AND SN.STATISTIC#=MS.STATISTIC#;
    SET AUTOTRACE TRACEONLY STATISTICS
    SELECT
    FROM
      T4;
    SET AUTOTRACE OFF
    SELECT
      SN.NAME,
      SN.STATISTIC#,
      MS.VALUE
    FROM
      V$MYSTAT MS,
      V$STATNAME SN
    WHERE
      SN.NAME = 'table fetch continued row'
      AND SN.STATISTIC#=MS.STATISTIC#;
    SPOOL OFFWhat should the 'table fetch continued row' show?
    Before the insert:
    NAME                      VALUE                                                
    table fetch continue      33695
    After the insert:
    NAME                      VALUE                                                
    table fetch continue      33695
    After the select:
    NAME                 STATISTIC#      VALUE                                     
    table fetch continue        252      33695 My statement "Tables with more than 255 columns will always have chained rows." needs to be clarified:
    "Tables with more than 255 columns will always have chained rows +(row pieces)+ if a column beyond column 255 is used, but the 'table fetch continued row' statistic +may+ only increase in value if the remaining row pieces are found in a different block."
    Charles Hooper
    IT Manager/Oracle DBA
    K&M Machine-Fabricating, Inc.
    Edited by: Charles Hooper on Aug 5, 2009 9:52 AM
    Paraphrase misspelled the view name "V$SYSSTAT", corrected a couple minor typos, and changed "will" to "may" in the closing paragraph as this appears to be the behavior based on the test case.

  • How to create table with rows and columns in the layout mode?

    One of my friends advised me to develop my whole site on the
    layout mode as its better than the standard as he says
    but I couldnot make an ordinary table with rows and columns
    in th layout mode
    is there any one who can tell me how to?
    thanx alot

    Your friend is obviously not a reliable source of HTML
    information.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Mr.Ghost" <[email protected]> wrote in
    message
    news:f060vi$npp$[email protected]..
    > One of my friends advised me to develop my whole site on
    the layout mode
    > as its
    > better than the standard as he says
    > but I couldnot make an ordinary table with rows and
    columns in th layout
    > mode
    > is there any one who can tell me how to?
    > thanx alot
    >

  • How to create table with row type in smart forms

    How to create table with row type in smart forms with out line type
    please explain me the procedure

    HI,
    A table type describes the structure and functional attributes of an internal table in ABAP. In ABAP programs you can reference a table type TTYP defined in the ABAP Dictionary with the command DATA <inttab> TYPE TTYP. An internal table <inttab> is created in the program with the attributes defined for TTYP in the ABAP Dictionary.
    A table type is defined by:
    its line type, that defines the structure and data type attributes of a line of the internal table
    the options for managing and accessing the data ( access mode) in the internal table
    the key ( key definition and key category) of the internal table
    The row type is defined by directly entering the data type, length and number of decimal places or by referencing a data element, structured type ( structure, table or view) or other table type. Or the row type can be a reference type.
    <b>for more info :</b> http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb366d358411d1829f0000e829fbfe/content.htm
    Internal table
    Regards
    Sudheer

  • How to create a table with varied number of columns?

    I am trying to create a balance table. The colunms should include years between the start year and end year the user will input at run time. The rows will be the customers with outstanding balance in those years.
    If the user input years 2000 and 2002, the table should have columns 2000, 2001, 2002. But if the user input 2000 and 2001, the table will only have columns 2000 and 2001.
    Can I do it? How? Thanka a lot.

    Why did you create a new thread for this?
    How to create a table with varied number of columns?

  • How can i export the data to excel which has 2 tables with same number of columns & column names?

    Hi everyone, again landed up with a problem.
    After trying a lot to do it myself, finally decided to post here..
    I have created a form in form builder 6i, in which on clicking a button the data gets exported to excel sheet.
    It is working fine with a single table. The problem now is that i am unable to do the same with 2 tables.
    Because both the tables have same number of columns & column names.
    Below are 2 tables with column names:
    Table-1 (MONTHLY_PART_1)
    Table-2 (MONTHLY_PART_2)
    SL_NO
    SL_NO
    COMP
    COMP
    DUE_DATE
    DUE_DATE
    U-1
    U-1
    U-2
    U-2
    U-4
    U-4
    U-20
    U-20
    U-25
    U-25
    Since both the tables have same column names, I'm getting the following error :
    Error 402 at line 103, column 4
      alias required in SELECT list of cursor to avoid duplicate column names.
    So How can i export the data to excel which has 2 tables with same number of columns & column names?
    Should i paste the code? Should i post this query in 'SQL and PL/SQL' Forum?
    Help me with this please.
    Thank You.

    You'll have to *alias* your columns, not prefix it with the table names:
    $[CHE_TEST@asterix1_impl] r
      1  declare
      2    cursor cData is
      3      with data as (
      4        select 1 id, 'test1' val1, 'a' val2 from dual
      5        union all
      6        select 1 id, '1test' val1, 'b' val2 from dual
      7        union all
      8        select 2 id, 'test2' val1, 'a' val2 from dual
      9        union all
    10        select 2 id, '2test' val1, 'b' val2 from dual
    11      )
    12      select a.id, b.id, a.val1, b.val1, a.val2, b.val2
    13      from data a, data b
    14      where a.id = b.id
    15      and a.val2 = 'a'
    16      and b.val2 = 'b';
    17  begin
    18    for rData in cData loop
    19      null;
    20    end loop;
    21* end;
      for rData in cData loop
    ERROR at line 18:
    ORA-06550: line 18, column 3:
    PLS-00402: alias required in SELECT list of cursor to avoid duplicate column names
    ORA-06550: line 18, column 3:
    PL/SQL: Statement ignored
    $[CHE_TEST@asterix1_impl] r
      1  declare
      2    cursor cData is
      3      with data as (
      4        select 1 id, 'test1' val1, 'a' val2 from dual
      5        union all
      6        select 1 id, '1test' val1, 'b' val2 from dual
      7        union all
      8        select 2 id, 'test2' val1, 'a' val2 from dual
      9        union all
    10        select 2 id, '2test' val1, 'b' val2 from dual
    11      )
    12      select a.id a_id, b.id b_id, a.val1 a_val1, b.val1 b_val1, a.val2 a_val2, b.val2 b_val2
    13      from data a, data b
    14      where a.id = b.id
    15      and a.val2 = 'a'
    16      and b.val2 = 'b';
    17  begin
    18    for rData in cData loop
    19      null;
    20    end loop;
    21* end;
    PL/SQL procedure successfully completed.
    cheers

  • REMOVE_ELEMENT in a Table with ( tree by key Column )

    Hi all,
    Designed a table with Tree by key column ( a Normal table with tree )
    In one of the row there is a Drop down field provided for selection.
    We have delete button provided to the customer.
    In this delete button handeled removing the Lead selected row using the method  REMOVE_ELEMENT of COntext_node.
    so in the context node if we are having 15  elements. The particluar hierarchy selected can have minimun 4 elements
    In the UI display the total node( total hierarchy node) is getting deleted but in the debugging mode the node is having  14 elements.
    Kindly suggest how to handle it so that in the node also i have the total hierarchy deleted.
    Thank you,
    Usha

    Hello Usha,
    For this you need write the logic. If you are deleting a context element of ID say 'ROW1', then you need to take care of deleting all the context element which has parent key as 'ROW1'.
    BR, Saravanan

  • Table with varying number of columns

    Hello experts,
    my issue:
    I need to print a table with varying number of columns. Depending on if all cells of a certain column are initial the
    whole column should disappear. Hiding is not enough.
    If this columns is in the middle of the table the following columns should move left to fill the gap.
    my approach: (maybe there is an easier one)
    There are 4 different possible situations. My approach was to create 4 different tables with different amount of
    columns. In the interface I fill the table that is really needed from the source table data and fill a flag that characteristics
    the situation, possible values (1,2,3,4).
    In the form I'd like to print the appropriate table depending on the situations.
    my problem:
    How to place all 4 possible tables lying upon each other in the form and print only the needed one depending on the flag value?
    my question:
    Is my approach ok? Or is there an easier one?
    If it is ok. How can I solve the problem regarding printing the right table.
    Thanks in advance!
    Heinz

    Hi Heinz,
    You can handle it with FormCalc Script at initialization.
    Suppose you have a table with name TABLE having a header HEADER and data row DATA:
    TABLE-->HEADER(Cell1...Cell2...Cell3...Cell4)
              --->DATA(Cell1...Cell2...Cell3...Cell4)
    Suppose you want to hide Cell3 for null values, then write below code at initialization of DATA:
    if(DATA[*].Cell3.rawValue eq null)
    then
    DATA[*].Cell3.presence = "hidden"
    HEADER.Cell3.presence = "hidden"
    else
    DATA[*].Cell3.presence = "visible"
    HEADER.Cell3.presence = "visible"
    endif
    Hope it would help.
    Regards,
    Vaibhav

  • Table with two headers

    i have a designed a table with 2 headers(say H1 AND H2), and  dynamic body rows (with three columns)
    the issue is when the table is oveflowing in to next page only one of the header is showing on the next page,
    i have noticed that the option 
    " INCLUDE HEADER ROW IN SUBSEQUENT PAGES" would not check for both the header rows , if i check it for say H1 then that option for H2 gets deselected. How do i resolve it..?
    Thanks in advance

    Hi Paul,
    Thanks for your suggestion
    so,
    now i am looking in to combining two headers together , but i am not sure how to do,
    right now i had wrapped the whole table in to  a subform , say S5
    and there are now two header rows
    Header row[0]
    header row[1]
    and
    body row
    i am trying to wrap the two headers as you suggested , but not sure how to proceed on. i have attached the pdf, can you please suggest me the changes. The table :"Table2"  is  Page 3 of the form.
    Thank you

  • I HAVE A SOURCE TABLE WITH 10 RECORDS AND TARGET TABLE 15 RECORDS. MY WUESTION IS USING WITH THE TABLE COMPARISON TRANSFORM I WANT TO DELETE UNMATCHED RECORDS FROM THE TARGET TABLE ??

    I HAVE A SOURCE TABLE WITH 10 RECORDS AND TARGET TABLE 15 RECORDS. MY QUESTION IS USING WITH THE TABLE COMPARISON TRANSFORM .I WANT TO DELETE UNMATCHED RECORDS FROM THE TARGET TABLE ?? HOW IT IS ??

    Hi Kishore,
    First identify deleted records by selecting "Detect deleted rows from comparison table" feature in Table Comparison
    Then Use Map Operation with Input row type as "delete" and output row type as "delete" to delete records from target table.

  • How to create a table with more tan 20 columns

    I created a A4 landscape document to make a calendar for the next year.
    To add the date information I need to insert a table with 32 columns (name of month + 31 days). It should be possible to create a table with a over all width of 29.7 cm (consisting of 1 column of 4.9 cm and 31 columns with 0.8 cm)?
    Remark: Yet reduced all indention's (? German: Einzug) and other spacers and the size of used font of the table.

    Hello Till,
    unfortunatly Pages connot create a table with more than 20 columns. This is no question of size or place.
    But you can create two tables, set the most right border of the fist table to "no line" and align the second table (with the other 12 columns) at the right side of the first table. Now you have "one" table with 32 columns.
    I have done this with my driving book (Fahrtenbuch, um es korrekt zu schreiben and it works fine.
    Frank.

  • How to create a table with datatype blob and insert a pdf file (ravi)

    how to create a table with datatype blob and insert a pdf file,
    give me the explain asap
    1.create the table?
    2.insert the pdffiles into tables?
    3.how to view the files?
    Thanks & Regards
    ravikumar.k
    Edited by: 895044 on Dec 5, 2011 2:55 AM

    895044 wrote:
    how to create a table with datatype blob and insert a pdf file,
    give me the explain asapPerhaps you should read...
    {message:id=9360002}
    especially point 2.
    We're not just sitting here waiting to answer your question as quickly as possible for you.

Maybe you are looking for