JTable Column Names Not Displaying

Hi there
I create a JTable by passing the JTable constructor my custom TableModel which extends AbstractTableModel.
For column names I have a String[] containing the column names in my custom TavleModel and have coded the TableModel methods accordingly.
For some reason when I run the code the table is displayed, but the column names are not!?!
Any advance is appreciated!

Sorted!
After looking at sample code in the JTable tutorial, it seems the table likes/needs to be added to a JScrollPane, as once I did this the column headings started appearing.
e.g. JScrollPane scrollPane = new JScrollPane(table);

Similar Messages

  • 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

  • JTable, column names not appearing!

    I am using the following code:
    Vector columnNames = new Vector();
            Vector data = new Vector();
            try
                //  Connect to the Database
                Common.Data.DataAccesser da = new Common.Data.DataAccesser();
                Connection connection = da.getConnection();
                //  Read data from a table
                String sql = "Select * from schedule1";
                Statement stmt = connection.createStatement();
                ResultSet rs = stmt.executeQuery( sql );
                ResultSetMetaData md = rs.getMetaData();
                int columns = md.getColumnCount();
                //  Get column names
                for (int i = 1; i <= columns; i++)
                    columnNames.addElement( md.getColumnName(i) );
                //  Get row data
                while (rs.next())
                    Vector row = new Vector(columns);
                    for (int i = 1; i <= columns; i++)
                        row.addElement( rs.getObject(i) );
                    data.addElement( row );
                rs.close();
                stmt.close();
            catch(Exception e)
                System.out.println( e );
            //  Create table with database data
            JTable table = new JTable(data, columnNames);
            jPanel2.setLayout(new java.awt.BorderLayout());
            jPanel2.add(table, BorderLayout.CENTER);I know its a bit messy, wat im tryin to do is add the table to the panel. the rows are showing perfectly but the column names do not show! Can anyone help?

    1) Please ask Swing questions in the Swing forum.
    2) Don't forget to specifically make the table header display. You do this by adding the table header to the jpanel in the borderlayout NORTH position, and you get the table header by calling getTableHeader. Have a look here for instance:
    http://forum.java.sun.com/thread.jspa?threadID=5235339&tstart=0

  • JTable column is not displaying in JPanel

    I created a JTable with single column like
    New JTable(celldata, columndata);
    and added it into JPanel. In this case only table cells are displying but not the column. If I use JScrollPane, table column name does displyed.
    Any help would be appreciated.
    Thanks
    Satheesh

    That is the correct behaviour of the components. A table won't display the column headers unless it's in a JScrollPane. Though you can get the headers from the table yourself manually using getTableHeader and put them where you want.

  • Column Name not displaying in WinXP

    Hi,
    I have a custom JTable that has the contructor :
    public CustomMatrixTable(TableModel dm)
    super(dm);
    setAutoCreateColumnsFromModel(true);
    setColumnSelectionAllowed(true);
    setRowSelectionAllowed(true);
    setCellSelectionEnabled(true);
    setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    The table model has overrides the getColumnName by retriving the name from a Vector.
    There are two coulmns in my example but the number can vary.
    In Windows 2000 it work perfectly. In XP the first column's name can be displayed but not the next.
    In fact the column header does not appear.
    please help.
    thanks
    Phill

    ok, it would seem that the work around is to declare a TableCellRenderer to be assigned as the column's header renderer. Unfortunately I have to do it for each column, nice if you want to make colourful column headers, but really one should be able to assign the column header renderer to be used by all column headers.

  • JTable Column Headings not displaying

    Hi
    I have recently made a Jtable a node of a Jtree.
    My table shows (semi-correctly) and is editable.
    I can't seem to see the headings of each column. and the left hand border line of the table is missing.
    Anyone know why this is?? I presume that I cant resize my columns due to the fact I cant see the headings.
    Thanks
    mike

    If you don't want to put the table in a scrollpane you can put it on a JPanel too...but use the BorderLayout and add the table to the center and the tableheader to the North portion.

  • Image content type in Site Asset Image library: The Preview and Thumbnail Preview columns do not display the picture of the item.

    I have two different Site Asset libraries.  The Site Asset Picture library has items of
    content type picture.  The Site Asset Image Library has items of
    content type image. 
    1) I do not quite understand the different between a picture content type versus an image content type. 
    2) the thumbnail and preview columns do not display the image in the Site Asset
    Image Library.  (the image does display in the thumbnail column of the Site Asset Picture library.)  I expected the image to display in the Site Asset Image Library the same as it does in the Site Asset Picture library. 
    Why doesn't it?
    Betty
    Betty Stolwyk

    I have subsequently found out that our "Site Asset Images" library is a Document Library to which someone must have replaced the Document content type with an Image content type.  I also found out that picture previews/thumbnails cannot be displayed
    in Document libraries.  So the problem was the library type, not the content type.
    So I simply created a new Picture Library (whose content type = picture) and copied the files into that and the thumbnails displayed just fine!
    I bet what led to this is the default "Site Assets" library that is created for a new Team site.  It is just a document library but sounds very similar to the "Assets" library.  I can imagine someone thinking the "Site Assets" library was a standard
    container for images, and simply changed the name to better identify the content! 
    As far as 'image' vs 'picture' content types, I noticed that a new Picture Library contains a content type of 'picture', but an Asset Library contains a content type of 'image' (as well as audio and video).  Although the 'image' content type has a few
    more fields than the 'picture' content type (picture content type does not have thumbnail), the actual Picture Library contains pretty much all the same fields, including the thumbnail.  So for all practical purposes, either library type can be used for
    storage of pictures.  I am guessing that the Pictures Library which uses the picture content type is for backwards compatibility purposes, and that the 'image' content type is newer, being derived from the new "Rich Media Asset" content type and used
    in the new Asset Library which can hold audio and video in addition to pictures.  
    Microsoft Help also mentioned that a Picture Library has a slide view which an Asset library does not.  So my take on that is that if you want the potential of seeing your pictures as a slide show, put them in a Picture library which is still using
    the 'picture' content type of previous SharePoint versions.  If you want to keep pictures organized with audio/video files, then put them into an Asset library which uses the  'image' content type derived from the new Rich Media Asset content type.
    Betty Stolwyk

  • Columns are not displaying in a Dimension in the presentation layer

    Hi All,
    I have a Dimension in one of the subject area which has 3 columns. It was working fine but yesterday, we have an issue about this. These columns are not displaying anymore in the dimension.
    I have checked in the Repository and from the Presentation services for the permissions and they look fine. Is there anything else am missing. If so, where I need to check.
    Kindly help me on this.
    Thanks,
    Imtiaz.

    Hi,
    Check three things.
    1. Try to login Admin user and check whether those columns are present or not.
    2. Try to login different browser.
    3. Cross check privileges for login user (what role has assigned ).
    Note: Clear the browser cache and all Bi server cache and check.
    Hope this help's
    Thanks,
    Satya Ranki redddy

  • How to know column name (not an expression) used by function-based index?

    Hi guys,
    Is there any way to know exact column name used by FBI? If I correct, there is SYS.ICOLDEP$ table that has mapping between index/table columns, but I don't see how it could be uniquely joined with the rest. I know about USER_IND_EXPRESSIONS, but the task is to know exact column name, not it's expression.
    This required by our so-called SQL preprocessing of DB schema update utility, which parses stmt (INSERT in our case) and should check against PK/UNIQUE key values.
    Thanks!

    I don't think this is possible in 10g or 11g because :
    1. dictionary keeps track of column number in index and not in table
    2. the expression used in CREATE INDEX is a system generated column
    You would have to parse the expression from USER_IND_EXPRESSIONS:
    SQL> create table t(x int, y int);
    Table created.
    SQL> create index fbi on t(y+1);
    Index created.
    SQL> column index_name format a10
    SQL> column column_name format a20
    SQL> column column_expression format a10
    SQL> select i.index_name, ic.column_name, ic.column_position as iccn, ie.column_position as iecn, ie.column_expression
      2  from user_indexes i , user_ind_columns ic, user_ind_expressions ie
      3  where i.index_name = ic.index_name
      4  and i.index_name = ie.index_name
      5  and i.index_name =  'FBI';
    INDEX_NAME COLUMN_NAME                ICCN       IECN COLUMN_EXP
    FBI        SYS_NC00003$                  1          1 "Y"+1

  • Strange error "Invalid column name 'not applicable'

    When I am trying this piece of code on Solaris 10 having sybase ASE 12.5 installed :
    ResultSet rs = stmt.executeQuery("sp_helpdb master");
    while(rs.next()){
    System.out.println(rs.getString(1));
    I am getting the following error:
    Invalid column name 'not applicable'
    This query returns multiple result sets.
    I am able to print all values in the first result set only.
    Its failing in rs.next();
    I am using jConnect 5.2 driver.
    The same query is executing fine on Solaris 8 having ASE 12.0 installed.
    If i use :
    ResultSet rs = stmt.executeQuery("sp_helpdb master");
    then there is no problem in Solaris 10
    Plz help me.
    Its urgent

    You need to use execute() not executeQuery() in the scenario below and use the multi-result set logic
    If you are using jConnect, see the samples for an example.

  • Datform's Rows & Columns are not displaying in Capital Expense Planning

    Hi ,
    Any one let me know why the Dataforms Row's & Columns are not displaying in Summary Reports Dataforms in Capital Expense Planning ,in 9.3.1 Version.
    Any help on this appreciable...
    Thanks.........

    As John mentioned, make sure that you aren't supressing the data. If there is no data in essbase and you are supressing missing data then there will be no rows. You can unselect "supress missing data" by going to admin>manage data forms. Select the data form in question and click edit, then navigate to the row/column tab and under row properties, ensure that the "supress missing data" check box is unselected.
    You will want this unselected if users are going to input data in this form.
    DQ

  • Error in COLMAP clause. Column name not found

    Hi guys,
    I must be missing something extremely simple here but I can't figure it out. I have a very simple test I am trying to perform. Remap a column from 1 table into another on replicat.
    I have created the defgens file.
    * Definitions created/modified 2013-02-12 13:08
    * Field descriptions for each column entry:
    * 1 Name
    * 2 Data Type
    * 3 External Length
    * 4 Fetch Offset
    * 5 Scale
    * 6 Level
    * 7 Null
    * 8 Bump if Odd
    * 9 Internal Length
    * 10 Binary Length
    * 11 Table Length
    * 12 Most Significant DT
    * 13 Least Significant DT
    * 14 High Precision
    * 15 Low Precision
    * 16 Elementary Item
    * 17 Occurs
    * 18 Key Column
    * 19 Sub Data Type
    Definition for table BILLING.B1
    Record length: 92
    Syskey: 0
    Columns: 2
    B_ID 64 50 0 0 0 1 0 50 50 50 0 0 0 0 1 0 1 2
    B_F_NAME 64 30 56 0 0 1 0 30 30 0 0 0 0 0 1 0 0 0
    End of definition
    Definition for table BILLING.B2
    Record length: 92
    Syskey: 0
    Columns: 2
    B_ID 64 50 0 0 0 1 0 50 50 50 0 0 0 0 1 0 1 2
    B_L_NAME 64 30 56 0 0 1 0 30 30 0 0 0 0 0 1 0 1 0
    End of definition
    I have setup the replicat to read the sourcedefs and remap the column
    -- Identify the Replicat group:
    REPLICAT rxtest
    -- State that source and target definitions are identical:
    --ASSUMETARGETDEFS
    SOURCEDEFS /u12/oracle/golden_gate_11_rep/dirsql/defgen_billing.sql
    --Discard Setup
    DISCARDFILE /u12/oracle/golden_gate_11_rep/dirout/rxtest.txt , PURGE
    SETENV (NLS_LANG="AMERICAN_AMERICA.WE8MSWIN1252")
    -- Specify database login information as needed for the database:
    USERID gg, PASSWORD
    -- Specify error handling rules:
    REPERROR (DEFAULT, ABEND)
    DDL EXCLUDE ALL
    MAP billing.b1, TARGET billing.r1,
    COLMAP (
    B_ID = id,
    b_f_name = f_name);
    Now when I try and start the rxtest replicat I get this error in the report.
    MAP resolved (entry BILLING.B1):
    MAP BILLING.B1, TARGET billing.r1, COLMAP ( B_ID = id, b_f_name = f_name);
    ...( B_ID = id, b_f_name = f_name...
    ^
    Error in COLMAP clause. Column name not found.
    Any ideas? Thanks

    desc billing.r1 - does that table have columns that you've included in the map clause?
    But, check the ordering of the columns in colmap - it goes target_column_name = source_column_name, looks like you have that reversed.
    I don't know why people insist on using SQL file extensions on def files, and placing them in the dirsql directory. What was wrong with using the (already created for you) dirdef directory? And naming the file with an extension like def or defs? It is not a SQL file.

  • Column names not visible in JTable

    Hello everyone,
    i have an Object array columns that i pass to the constructor of JTable, but for some reason the column names are not visible in my table.
    private final Object[] columns = {"Zeit", "Termin"};
    private Object[][] rows;
    //the next line fills the two-dimensional rows-array
    fillRows();
    //here the constructor
    JTable table = new JTable(rows, columns);
    table.setColumnSelectionAllowed(false);
    table.setDragEnabled(false);
              table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    TableColumnModel colModel = table.getColumnModel();
    TableColumn column = colModel.getColumn(1);
    column.setCellRenderer(new BookedCellRenderer(new int[] {3,4}));What are possible reasons/sollutions for this problem?

    Gosh, thanks! Usually i always use a jscrollpane for
    jtables and was about to use it too, but i got
    confused because of the headers when i tried to see
    whether the data in the table was right.You're welcome. The JTableHeaders object can be displayed in, say,
    the NORTH part of a BorderLayout while the JTable itself is displayed
    int the CENTER part. You can even display the headers SOUTH of
    the table itself if you like. A JTable object is quite flexible.
    kind regards,
    Jos

  • Table column names not getting displayed

    Hi
    When i do a SELECT statement i am not getting the column names
    SQL> SELECT * FROM EE;
    aa physics 100
    bb physics 200
    PLease let me know how can i set it.
    Thank you
    Marium Thomas

    Did you modify some of the default settings (e.g. HEADING or PAGESIZE)?
    Try
    set heading onhttp://download-uk.oracle.com/docs/cd/B10501_01/server.920/a90842/ch13.htm#1011230

  • JTable column headers not showing up

    I have a JTable inside a JScrollPane which, in turn, is inside a JTabbedPane.
    I created a TableModel which extends AbstractTableModel as per the java Swing Tutorial examples.
    In that model is an Object[][] object for the data called rowData, and all the data displays in the table perfectly.
    I also have a String[] object called columnNames to define the column headers. ..the column names are coded directly into the object.
    i.e.: String[] columnNames = {"John", "Janet", "Jamie", "Jennifer"};But the column names don't display at all.....all I get in the column headers is 'A', 'B', 'C', etc.
    I need to know either
    1)how to set this up correctly in the first place or
    2)how I can reset the columns manually.
    I have tried adding the table 2 ways..as follows...but neither one gets the headers right:
    JScrollPane jScrollPane = new javax.swing.JScrollPane(getTable());or
    JScrollPane jScrollPane.setViewportView(getTable());Note: getTable()..is where the new javax.swing.JTabel(new TableModel())stuff is done.
    thx, ESW

    You mentioned the you columnNames array. I suggest you declare it as static and accessible from within your custom table modelprivate static final String[] COLUMN_NAMES = {"John", "Janet", "Jamie", "Jennifer"};Then you override/implement the following methods in your TableModel :public String getColumnName(int column) {
         return COLUMN_NAMES[column];
    public int getColumnCount() {
         return COLUMN_NAMES.length;
    }That should do the trick.

Maybe you are looking for

  • How to stop a movie clip moving

    I'm not newbie to flash but I am newbie to coding using actionscript!!! I am trying to create a button that moves a movie clip ("content1") diagonally across the screen but once the movie clip reaches a certain x co-ordinate I want it to stop and the

  • Word has not been started on this computer - Windows 7, RoboHelp 9

    I followed the discussion threads and adapted them to RoboHelp 9 (9.0.2.271) and Windows 7. This also addresses "The macros in this project are disabled" issue. Followed Olaf's suggestion: Changed the location for the "user templates" and "startup" t

  • Viewing rental videos on different computer

    A couple weeks ago I downloaded a movie to rent on my (windows) desktop.  since then I have purchased a newer (PC) laptop which has a better sound and video card.  I want to watch this video on my new machine, but can not figure out how to do it.  An

  • Need help with nested table

    Hi, I am using the following code which is failing with no data found error. While if i hardcode the same value the code works. create table test(input varchar2(10),result varchar2(10)); insert into test values('4093163','SUCCESS') declare TYPE accti

  • How to create CVI drivers from existing LabView HP816x.fp

    I downloaded an instrument driver from the www.agilent.com; Instructions are provided to convert drivers for LabView from the provided HP816x.fp, however, I need to create them for LabWindows CVI.