Help for adjusting columns of a JTAble in a Table Model

Hello community,
In order to have a good display of by DataBase in a JTable, I've wrote some code to adjust columns in function of datas. Those datas are displayed with a TableModel ( which I've declared in a class JDBCAdapter ).
When I start my application, I call adjustColumns(), and all is great but when I add information to my DB and display it, the columns of my JTable return to default width...
So I want to incorporate my function adjustColumns in my TableModel, and I need help...
     void adjustColumns()
     // Ajuste les colonnes aux donnes pour que tout soit visible
     int nbRow,nbCol;
     nbRow = JTable1.getRowCount();
     nbCol = test.getColumnCount();
     for ( int i = 0; i < nbCol; i++ )
     com.sun.java.swing.table.TableColumn column = null;
     column = JTable1.getColumnModel().getColumn(i);
     int dataLength = 0;
     for ( int j = 0; j< nbRow; j++ )
     FontMetrics fm;
     int dataLengthTmp;
     String valueTable;
     fm = JTable1.getFontMetrics(JTable1.getFont());
     if ( test.getValueAt(j, i) == null )
     System.out.println("Valeur nulle...");
     dataLengthTmp = 0;
     else
     valueTable = test.getValueAt(j, i).toString();
     dataLengthTmp = fm.stringWidth(valueTable);
     System.out.println(valueTable + " = " + dataLengthTmp);
     if ( dataLengthTmp > dataLength )
     dataLength = dataLengthTmp;
     if ( dataLength != 0 )
column.setWidth(dataLength + 5);
else
column.sizeWidthToFit();
JTable1.setModel(test);
JTable1.repaint();
import java.util.Vector;
import java.sql.*;
import com.sun.java.swing.table.AbstractTableModel;
import com.sun.java.swing.event.TableModelEvent;
public class JDBCAdapter extends AbstractTableModel {
Connection connection;
Statement statement;
ResultSet resultSet;
String[] columnNames = {};
Vector rows = new Vector();
ResultSetMetaData metaData;
public JDBCAdapter(String url, String driverName,
String user, String passwd) {
try {
Class.forName(driverName);
System.out.println("Ouverture de la connexion a la base de donnee...");
connection = DriverManager.getConnection(url, user, passwd);
statement = connection.createStatement();
catch (ClassNotFoundException ex) {
System.err.println("Cannot find the database driver classes.");
System.err.println(ex);
catch (SQLException ex) {
System.err.println("Cannot connect to this database.");
System.err.println(ex);
public void executeQuery(String query) {
if (connection == null || statement == null) {
System.err.println("There is no database to execute the query.");
return;
try {
resultSet = statement.executeQuery(query);
metaData = resultSet.getMetaData();
int numberOfColumns = metaData.getColumnCount();
columnNames = new String[numberOfColumns];
// Get the column names and cache them.
// Then we can close the connection.
for(int column = 0; column < numberOfColumns; column++) {
columnNames[column] = metaData.getColumnLabel(column+1);
// Get all rows.
rows = new Vector();
while (resultSet.next()) {
Vector newRow = new Vector();
for (int i = 1; i <= getColumnCount(); i++) {
newRow.addElement(resultSet.getObject(i));
rows.addElement(newRow);
// close(); Need to copy the metaData, bug in jdbc:odbc driver.
fireTableChanged(null); // Tell the listeners a new table has arrived.
catch (SQLException ex) {
System.err.println(ex+" query = "+query);
public void executeUpdate(String query) {
if (connection == null || statement == null) {
System.err.println("There is no database to execute the query.");
return;
try {
statement.executeUpdate(query);
// close(); Need to copy the metaData, bug in jdbc:odbc driver.
fireTableChanged(null); // Tell the listeners a new table has arrived.
catch (SQLException ex) {
System.err.println(ex+" query = "+query);
public void close() throws SQLException {
System.out.println("Fermeture de la connection a la base de donnee... Bye !");
resultSet.close();
statement.close();
connection.close();
protected void finalize() throws Throwable {
close();
super.finalize();
// Implementation of the TableModel Interface
// MetaData
public String getColumnName(int column) {
if (columnNames[column] != null) {
return columnNames[column];
} else {
return "";
public Class getColumnClass(int column) {
int type;
try {
type = metaData.getColumnType(column+1);
catch (SQLException e) {
return super.getColumnClass(column);
switch(type) {
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
return String.class;
case Types.BIT:
return Boolean.class;
case Types.TINYINT:
case Types.SMALLINT:
case Types.INTEGER:
return Integer.class;
case Types.BIGINT:
return Long.class;
case Types.FLOAT:
case Types.DOUBLE:
return Double.class;
case Types.DATE:
return java.sql.Date.class;
default:
return Object.class;
public boolean isCellEditable(int row, int column) {
try {
return metaData.isWritable(column+1);
catch (SQLException e) {
return false;
public int getColumnCount() {
return columnNames.length;
// Data methods
public int getRowCount() {
return rows.size();
public Object getValueAt(int aRow, int aColumn) {
Vector row = (Vector)rows.elementAt(aRow);
return row.elementAt(aColumn);
public String dbRepresentation(int column, Object value) {
int type;
if (value == null) {
return "null";
try {
type = metaData.getColumnType(column+1);
catch (SQLException e) {
return value.toString();
switch(type) {
case Types.INTEGER:
case Types.DOUBLE:
case Types.FLOAT:
return value.toString();
case Types.BIT:
return ((Boolean)value).booleanValue() ? "1" : "0";
case Types.DATE:
return value.toString(); // This will need some conversion.
default:
return "\""+value.toString()+"\"";
public void setValueAt(Object value, int row, int column) {
try {
String tableName = metaData.getTableName(column+1);
// Some of the drivers seem buggy, tableName should not be null.
if (tableName == null) {
System.out.println("Table name returned null.");
String columnName = getColumnName(column);
String query =
"update "+tableName+
" set "+columnName+" = "+dbRepresentation(column, value)+
" where ";
// We don't have a model of the schema so we don't know the
// primary keys or which columns to lock on. To demonstrate
// that editing is possible, we'll just lock on everything.
for(int col = 0; col<getColumnCount(); col++) {
String colName = getColumnName(col);
if (colName.equals("")) {
continue;
if (col != 0) {
query = query + " and ";
query = query + colName +" = "+
dbRepresentation(col, getValueAt(row, col));
System.out.println(query);
System.out.println("Not sending update to database");
// statement.executeQuery(query);
catch (SQLException e) {
// e.printStackTrace();
System.err.println("Update failed");
Vector dataRow = (Vector)rows.elementAt(row);
dataRow.setElementAt(value, column);
Thanks to help me.

Hi,
OK. I have read your code sample again. It looks like the JDBCAdapter class is reloading table data in the executeQuery method. Why not call adjustColumns at the end of this method after the new rows and columns are loaded? Perhaps it also should be called at the end of executeUpdate. Have you tried doing that?
I would still set
JTable1.setAutoCreateColumnsFromModel (false); to prevent Java from readjusting the size automatically at some other time.
regards,
Terry

Similar Messages

  • Jtable, sql, default table model

    Hi all,
    I need help. How do I create JTable, generaly Default table model and query which will work with the database. Thx.

    Look to this example
    [http://jfxstudio.wordpress.com/2009/05/25/the-graphic-database-front-end-ii/|http://jfxstudio.wordpress.com/2009/05/25/the-graphic-database-front-end-ii/]
    tables, database and advanced graphics

  • Is it posiible to paging up paging down in Jtable using Default Table Model

    Hi All!
    Is it possible to do Page up and Page down in JTable using Default Tble Model?
    Kindly reply!

    yes
    it is posiible to paging up paging down in Jtable using Default Table Model. just go thru the JAVA API you will get the results.

  • Context Help in diferents Columns in a JTable

    I want to put Context Help in the diferents columns in a JTable (in columns, in headers or cells); but I don't know how I can do it.
    Please, if somebody can help me, or simply say me that this is not possible (if is really impossible).

    Carlos,
    You can write your own F1 listener for JTable (or if you prefer a right click help menu option then a mouse listener). In the listener determine what cell has focus or is clicked over. From this generate a help topicID. Then call showTopic on the CSHManager or Help.
    Note the table has an editor component (e.g., JTextField), the make sure that the correct topicID is associated with this editor component.
    Cheers,
    Craig Cummings.
    Oracle Help Team

  • How to disable/enable the cells for editing column wise in JTable in java?

    Hi All,
    Can any one tell me how to disable the cells for editing by column wise in JTable?
    Here depending upon the radio button selected, I need 2 disable some columns for editing
    and enable some columns for editing?
    how can I do tat using JAVA?
    Any sample code is of great help to me.
    Thanks in Advance

    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
    ~

  • ALV: F4 help for a column wanted, but without any check

    Hello,
    I have an ALV and I use a DDIC structure for the field catalog. My requirement is that for all columns in ALV, the F4 should appear normally (using the DDIC information), but I do not want an automatic check for the value entered by user.
    So .e.g. if in F4, possible values are 1, 2, 3 then the ALV throws an error if user leaves the field blank (because blank was not a possible value for the domain of the field). How, can I by-pass this automatic check by ALV (while still keeping the F4 help)?
    Regards,
    Mohit

    Hi hope u know the difference between value table and check table.
    In this case you have to give value table as F4 reference but not check table.
    I mean consider the field Plant. if you are defining plane with reference to master table T001w and u r entering a value not in T001W it will give error. because here it is check table. where as define the plant with refence to MARC. then MARC will be value table. and dont give error if you enter any plane value not there in MARC.
    Try to find out value tables for your fields and use. Then it will work.

  • F4 help for a column in tableview

    Hi all,
    I have achieved F4 help using java script for input field, but i want to use it to fill each value of a column, i am using iterator for the column properties. Is the method of displaying help same as used for input field. I want to do it without using the concept of MVC.
    Any pointers are welcome...
    Regards,
    Rohit Khetarpal

    Rohit,
    Here you go. Using Flowlogic..used Flight example to narrate this..
    Just i added pieces which is mandatory so that you can develope the full code..
    In Iterator of Main Tableview:
    IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START
    DATA col_inputField TYPE REF TO CL_HTMLB_INPUTFIELD.
          CREATE OBJECT col8_inputField.
          col_inputField->id        = p_cell_id.
          col_inputField->width     = '100%'.
          col_inputField->maxlength = 40.
          col_inputField->showHelp = 'X'.
          row_index = p_row_index.
          condense row_index.
          concatenate `openF4Window('` row_index `','` p_cell_id `');` into javascript.
          col_inputField->onValueHelp = javascript.
          _value = p_row_index.
          condense _value.
          concatenate 'flights[' _value '].connid' into attribute_path.
          col_inputField->_value   = p_cell_binding.
          p_replacement_bee         = col_inputField.
    <b>Main page Layout:</b>
      <htmlb:page>
        <script language="JavaScript" type="text/javascript">
          function openF4Window(row_index,p_cell_id)
            document.getElementById("row_index").value=row_index;
            document.getElementById("p_cell_id").value=p_cell_id;
            var s=0;
            var r=1;
            var w=260;
            var h=100;
            var x=screen.width/2;
            x=x-w/2;
            var y=screen.height/2;
            y=y-h/2;
            popUp=window.open('f4.htm', '_blank', 'Emp Details','width=100,height=300');
        </script>
          <htmlb:tableView id               = "main"
                           width            = "200"
                           headerVisible    = "true"
                           design           = "alternating"
                           visibleRowCount  = "10"
                           fillUpEmptyRows  = "true"
                           selectionMode    = "SINGLESELECT"
                           selectedRowIndex = "<%= row_index %>"
                           onRowSelection   = "MyEventRowSelection"
                           showNoMatchText  = "true"
                           filter           = "server"
                           sort             = "server"
                           onHeaderClick    = "MyEventHeaderClick"
                           table            = "<%= it_sflight %>"
                           iterator         = "<%= iterator %>" >
    <b>f4.htm page Layout:</b>
    <%@page language="abap" %>
    <%@extension name="htmlb" prefix="htmlb" %>
    <htmlb:content design="design2003" >
      <htmlb:page title="Test" >
        <htmlb:form id="my_window" >
          <%
      data TV_ITERATOR Type Ref To zcl_itr." - Iterator Function
      data iterator type ref to IF_HTMLB_TABLEVIEW_ITERATOR.
      create object tv_iterator exporting appl_cons = application.
      iterator = tv_iterator.
          %>
          <htmlb:tableView id               = "pop"
                           width            = "200"
                           headerVisible    = "true"
                           design           = "alternating"
                           visibleRowCount  = "10"
                           fillUpEmptyRows  = "true"
                           selectionMode    = "SINGLESELECT"
                           selectedRowIndex = "<%= row_index %>"
                           onRowSelection   = "MyEventRowSelection"
                           showNoMatchText  = "true"
                           filter           = "server"
                           sort             = "server"
                           onHeaderClick    = "MyEventHeaderClick"
                           table            = "<%= it_help %>"
                           iterator         = "<%= iterator2 %>" >
          </htmlb:tableView>
          <%
      if connid is not initial.
          %>
          <htmlb:inputField id      = "checked"
                            visible = "FALSE"
                            value   = "<%= lv_checked %>" />
                <script for="checked" language="javascript" even="onLoad()">
            var row_index=opener.document.getElementById("row_index").value;
            var p_cell_id=opener.document.getElementById("p_cell_id").value;
            opener.document.forms[0][p_cell_id].value=document.getElementById("connid").value;
                       window.self.close();
          </script>
          <%
      endif.
          %>
        </htmlb:form>
      </htmlb:page>
    </htmlb:content>
    <b>Oninputprocessing of F4.htm</b>
    DATA: IND TYPE I.
      DATA: TV TYPE REF TO CL_HTMLB_TABLEVIEW.
      DATA: EVENT1 TYPE REF TO CL_HTMLB_EVENT.
      EVENT1 = CL_HTMLB_MANAGER=>GET_EVENT( RUNTIME->SERVER->REQUEST ).
      TV ?= CL_HTMLB_MANAGER=>GET_DATA(
      REQUEST = RUNTIME->SERVER->REQUEST
      NAME = 'tableView'
      ID = 'pop' ).
      IF TV IS NOT INITIAL.
        DATA: TV_DATA TYPE REF TO CL_HTMLB_EVENT_TABLEVIEW.
        TV_DATA = TV->DATA.
        IF TV_DATA->SELECTEDROWINDEX IS NOT INITIAL.
          DATA: ROW LIKE LINE OF APPL->ITAB.
          READ TABLE APPL->ITAB INDEX TV_DATA->SELECTEDROWINDEX INTO ROW.
          DATA VALUE TYPE STRING.
          APPL->CONNID = ROW-CONNID.
        ENDIF.
      ENDIF.
    Hope this will solve your problem.
    Raja T

  • JTable column headers not displaying using custom table model

    Hi,
    I'm attempting to use a custom table model (by extending AbstractTableModel) to display the contents of a data set in a JTable. The table is displaying the data itself correctly but there are no column headers appearing. I have overridden getColumnName of the table model to return the correct header and have tried playing with the ColumnModel for the table but have not been able to get the headers to display (at all).
    Any ideas?
    Cheers

    Class PublicationTableModel:
    public class PublicationTableModel extends AbstractTableModel
        PublicationManager pubManager;
        /** Creates a new instance of PublicationTableModel */
        public PublicationTableModel(PublicationManager pm)
            super();
            pubManager = pm;
        public int getColumnCount()
            return GUISettings.getDisplayedFieldCount();
        public int getRowCount()
            return pubManager.getPublicationCount();
        public Class getColumnClass(int columnIndex)
            Object o = getValueAt(0, columnIndex);
            if (o != null) return o.getClass();
            return (new String()).getClass();
        public String getColumnName(int columnIndex)
            System.out.println("asked for column name "+columnIndex+" --> "+GUISettings.getColumnName(columnIndex));
            return GUISettings.getColumnName(columnIndex);
        public Publication getPublicationAt(int rowIndex)
            return pubManager.getPublicationAt(rowIndex);
        public Object getValueAt(int rowIndex, int columnIndex)
            Publication pub = (Publication)pubManager.getPublicationAt(rowIndex);
            String columnName = getColumnName(columnIndex);
            if (columnName.equals("Address"))
                if (pub instanceof Address) return ((Address)pub).getAddress();
                else return null;
            else if (columnName.equals("Annotation"))
                if (pub instanceof Annotation) return ((Annotation)pub).getAnnotation();
                else return null;
            etc
           else if (columnName.equals("Title"))
                return pub.getTitle();
            else if (columnName.equals("Key"))
                return pub.getKey();
            return null;
        public boolean isCellEditable(int rowIndex, int colIndex)
            return false;
        public void setValueAt(Object vValue, int rowIndex, int colIndex)
        }Class GUISettings:
    public class GUISettings {
        private static Vector fields = new Vector();
        private static Vector classes = new Vector();
        /** Creates a new instance of GUISettings */
        public GUISettings() {
        public static void setFields(Vector f)
            fields=f;
        public static int getDisplayedFieldCount()
            return fields.size();
        public static String getColumnName(int columnIndex)
            return (String)fields.elementAt(columnIndex);
        public static Vector getFields()
            return fields;
    }GUISettings.setFields has been called before table is displayed.
    Cheers,
    garsher

  • Query Help - Add a column that doesn't exist in table

    Hello,
    i have an application that runs a query in code off of a main query, and that query in code requires a column that does not exist in the main query that I created. how do I go about adding a column to a query that does not actually exist in the table or database that I am querying?
    For Example:
    SELECT PROJ_ID, PROJECT_NAME
    FROM PROJECT
    I need a column called "DELETE_SESSION_ID" and this database/table does not contain that column anywhere. Is it best to create a view that creates the column somehow? I would prefer not having to create the column inside of the table. Any ideas are greatly appreciated.
    Thanks,
    Jeff

    user10249614 wrote:
    Hello,
    i have an application that runs a query in code off of a main query, and that query in code requires a column that does not exist in the main query that I created. how do I go about adding a column to a query that does not actually exist in the table or database that I am querying?
    For Example:
    SELECT PROJ_ID, PROJECT_NAME
    FROM PROJECT
    I need a column called "DELETE_SESSION_ID" and this database/table does not contain that column anywhere. Is it best to create a view that creates the column somehow? I would prefer not having to create the column inside of the table. Any ideas are greatly appreciated.
    Thanks,
    JeffYou need a way to obtain the value you need - a function to generate it, perhaps. A view using such a function or aquiring the value by other means should work well.
    Pipelined functions work well to generate values that aren't in the database at run time - if your version of Oracle supports them

  • Transfer Data from a JTable to the table model

    Hi
    I' looking for a simple method to transfer the last user input in a table to the table model.
    For example:
    In a Dialog the user insert in a JTable a few values and leaves with OK. But the last input is not saved in the model. It is just saved after selecting a new field in the JTable before leaving the Dialog.
    Is there a call to transfer all input to the model?
    Thanks
    Guido

    class MyJTable extends JTable (
    public boolean validateInput() {
    if(isEditing()) {
    return cellEditor.stopCellEditing();
    return true;
    Call this method whenever you want the input value to be stored in the table model. The return value can be false if the input isn't valid, this will depend on the cell editor.
    The idea is:
    Ask if the table has an editor activated. (isEditing())
    If so, request the editor to store the value in the model.
    I haven't prouved the code, sorry, but I hope you get the idea and helps.

  • JButton in JTable with custom table model

    Hi!
    I want to include a JButton into a field of a JTable. I do not know why Java does not provide a standard renderer for JButton like it does for JCheckBox, JComboBox and JTextField. I found some previous postings on how to implement custom CellRenderer and CellEditor in order to be able to integrate a button into the table. In my case I am also using a custom table model and I was not able to create a clickable button with any of the resources that I have found. The most comprehensive resource that I have found is this one: http://www.java2s.com/Code/Java/Swing-Components/ButtonTableExample.htm.
    It works fine (rendering and clicking) when I start it. However, as soon as I incorporate it into my code, the clicking does not work anymore (but the buttons are displayed). If I then use a DefaultTableModel instead of my custom one, rendering and clicking works again. Does anyone know how to deal with this issue? Or does anyone have a good pointer to a resource for including buttons into tables? Or does anyone have a pointer to a resource that explains how CellRenderer and CellEditor work and which methods have to be overwritten in order to trigger certain actions (like a button click)?
    thanks

    Yes, you were right, the TableModel was causing the trouble, everything else worked fine. Somehow I had this code (probably copy and pasted from a tutorial - damn copy and pasting) in my TableModel:
            public boolean isCellEditable(int row, int col) {
                //Note that the data/cell address is constant,
                //no matter where the cell appears onscreen.
                if (col < 3) {
                    return false;
                } else {
                    return true;
    }A pretty stupid thing when you want to edit the 3rd column...

  • JTable Problem(Default Table Model)

    Hi all,
    iam using Default Table model for my jtable i want to do pageup and pagedown operation .
    TableColumnModel cm1 = new DefaultTableColumnModel();
    DefaultTablemodel md = new DefaultTableModel(row,col);
    JTable t = new JTable(md,cm1);
    i have 500 rows currently in my database i want to display 100 in the first page and if i press the pagedown button the next 100 has to be diplayed wether this is possible here.. if possible please help mee.

    sample code :
    // PagingModel.java
    // A larger table model that performs "paging" of its data. This model reports a
    // small number of rows (e.g., 100 or so) as a "page" of data. You can switch pages
    // to view all of the rows as needed using the pageDown( ) and pageUp( ) methods.
    // Presumably, access to the other pages of data is dictated by other GUI elements
    // such as up/down buttons, or maybe a text field that allows you to enter the page
    // number you want to display.
    import javax.swing.table.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    class PagingModel extends AbstractTableModel {
    protected int pageSize;
    protected int pageOffset;
    protected Record[] data;
    public PagingModel( ) {
    this(10000, 100);
    public PagingModel(int numRows, int size) {
    data = new Record[numRows];
    pageSize = size;
    // Fill our table with random data (from the Record( ) constructor).
    for (int i=0; i < data.length; i++) {
    data[i] = new Record( );
    // Return values appropriate for the visible table part.
    public int getRowCount( ) { return Math.min(pageSize, data.length); }
    public int getColumnCount( ) { return Record.getColumnCount( ); }
    // Work only on the visible part of the table.
    public Object getValueAt(int row, int col) {
    int realRow = row + (pageOffset * pageSize);
    return data[realRow].getValueAt(col);
    public String getColumnName(int col) {
    return Record.getColumnName(col);
    // Use this method to figure out which page you are on.
    public int getPageOffset( ) { return pageOffset; }
    public int getPageCount( ) {
    return (int)Math.ceil((double)data.length / pageSize);
    // Use this method if you want to know how big the real table is. You could also
    // write "getRealValueAt( )" if needed.
    public int getRealRowCount( ) {
    return data.length;
    public int getPageSize( ) { return pageSize; }
    public void setPageSize(int s) {
    if (s == pageSize) { return; }
    int oldPageSize = pageSize;
    pageSize = s;
    pageOffset=(oldPageSize * pageOffset) / pageSize;
    fireTableDataChanged( );
    // Update the page offset and fire a data changed event (all rows).
    public void pageDown( ) {
    if (pageOffset < getPageCount( ) - 1) {
    pageOffset++;
    fireTableDataChanged( );
    // Update the page offset and fire a data changed (all rows).
    public void pageUp( ) {
    if (pageOffset > 0) {
    pageOffset--;
    fireTableDataChanged( );
    // We provide our own version of a scrollpane that includes
    // the Page Up and Page Down buttons by default.
    public static JScrollPane createPagingScrollPaneForTable(JTable jt) {
    JScrollPane jsp = new JScrollPane(jt);
    TableModel tmodel = jt.getModel( );
    // Don't choke if this is called on a regular table . . .
    if (! (tmodel instanceof PagingModel)) {
    return jsp;
    // Go ahead and build the real scrollpane.
    final PagingModel model = (PagingModel)tmodel;
    final JButton upButton = new JButton("Up");
    upButton.setEnabled(false); // Starts off at 0, so can't go up
    final JButton downButton = new JButton("Down");
    if (model.getPageCount( ) <= 1) {
    downButton.setEnabled(false); // One page...can't scroll down
    upButton.addActionListener(new ActionListener( ) {
    public void actionPerformed(ActionEvent ae) {
    model.pageUp( );
    // If we hit the top of the data, disable the Page Up button.
    if (model.getPageOffset( ) == 0) {
    upButton.setEnabled(false);
    downButton.setEnabled(true);
    downButton.addActionListener(new ActionListener( ) {
    public void actionPerformed(ActionEvent ae) {
    model.pageDown( );
    // If we hit the bottom of the data, disable the Page Down button.
    if (model.getPageOffset( ) == (model.getPageCount( ) - 1)) {
    downButton.setEnabled(false);
    upButton.setEnabled(true);
    // Turn on the scrollbars; otherwise, we won't get our corners.
    jsp.setVerticalScrollBarPolicy
    (ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    jsp.setHorizontalScrollBarPolicy
    (ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    // Add in the corners (page up/down).
    jsp.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, upButton);
    jsp.setCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER, downButton);
    return jsp;
    // Record.java
    // A simple data structure for use with the PagingModel demo
    class Record {
    static String[] headers = { "Record Number", "Batch Number", "Reserved" };
    static int counter;
    String[] data;
    public Record( ) {
    data = new String[] { "" + (counter++), "" + System.currentTimeMillis( ),
    "Reserved" };
    public String getValueAt(int i) { return data[i]; }
    public static String getColumnName(int i) { return headers[i]; }
    public static int getColumnCount( ) { return headers.length; }
    class PagingTester extends JFrame {
    public PagingTester( ) {
    super("Paged JTable Test");
    setSize(300, 200);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    PagingModel pm = new PagingModel( );
    JTable jt = new JTable(pm);
    // Use our own custom scrollpane.
    JScrollPane jsp = PagingModel.createPagingScrollPaneForTable(jt);
    getContentPane( ).add(jsp, BorderLayout.CENTER);
    public static void main(String args[]) {
    PagingTester pt = new PagingTester( );
    pt.setVisible(true);
    }

  • ALV: Search help for editable column using OVS/Input Help Component Usage?

    Hi all,
    Is is possible to assign a value help like OVS or "Input Help Component Usage" to a editable ALV column using Web Dynpro?
    Thanks and regards,
    Ulrich

    Hi Madhu,
    Than I must have made something wrong because this is exactly what I've tried.
    I'll check my freely prgrammed value  and the assigning again.
    Thanks a lot for your quick reply.
    Ulrich

  • Help for fixed columns in web layout

    Hi all,
         I'm facing the problem of Fixing the column of web layout,I know there's a post of solving this,
      Fixed Rows/Columns in Web Interfaces
    but all the download links in this post are expired,could any one send me the file or the how to documents to [email protected]? thank you very much!
       thank you all.

    Denny,
    The easiest way is to use the Microsoft OWC (office Web component) and you can have Excel on the web where you have to publish the layouts for the web. 
    If not, and you use pure web, Olaf Fisher's paper might be published as a how to guide by now.  I would suggest a search on SDN.  I have downloaded the file a long time ago but I think it is on the server in the office.

  • Need Help for Pivoting Columns in table

    I have a data like below in the table
    col1 col2 col3 col4
    a b 10 jan-11
    aa b 20 feb-11
    aab b 30 mar-11
    Need desire o/p like
    col1 col2 jan-11 feb-11 mar-11
    a b 10
    aa b 20
    aab b 30
    Can anyone help me on this? decode is not the option here because my table gets dynamic data and rows count can vary too(eg. 2000).
    Thanks,
    -KP

    Please try searching the forum BEFORE you ask a question.. There are NUMEROUS posting son the subject:
    http://forums.oracle.com/forums/search.jspa?objID=f75&q=pivot
    Thank you,
    Tony Miller
    Webster, TX
    Never Surrender Dreams!
    JMS
    If this question is answered, please mark the thread as closed and assign points where earned..

Maybe you are looking for