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.

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

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

  • 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

  • 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

  • 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

  • Custom JTable column (JCheckBox) not included in row selection.

    I am trying to use JCheckBox (for display only data) as one of my JTable columns. I have written custom cell renderer for the same. Every thing is working fine except that when I select a row, the new custom JCheckBox column is not included in selection. Here is the code that I am using.
        protected class CheckBoxColumnRenderer extends DefaultTableCellRenderer {
            JCheckBox ckb = new JCheckBox();
            public Component getTableCellRendererComponent(JTable table, Object value,
                        boolean isSelected, boolean hasFocus, int row, int column) {
                if (value instanceof Boolean) { // Boolean
                  ckb.setSelected(((Boolean) value));
                  ckb.setHorizontalAlignment(JLabel.CENTER);
                  ckb.setBackground(super.getBackground());
                  if (isSelected || hasFocus) {
                      ckb.setBackground(table.getSelectionBackground());
                return ckb;
        }How can I include the custom cell in the row selection.
    regards,
    nirvan.

    they have lots of dependencies and it is not always easy to strip out an SSCCE without a considerable effort.Exactly. And is the cause of the problem the dependencies or something else. The only way to know for sure is to strip out the code and simplify the problem, that way you truly understand what the problem is.
    The majority of time this can be done with minimal effort as in this case.
    Some times we are sure that the problem is with certain part of the code Is the problem the code or the way the code is invoked? How do we know the TableModel is created properly or that the column class is overwritten correctly when we can't see it?
    someone having a third look at it may actually find the enhancement required with ease.Exactly, but we need to see the big picture.
    So are you sure that I should post an SSCCE with every possible question where coding is involved ?In the majority of cases a SSCCE is easily created in 5-10 minutes, so if you want the fastest help then yes.
    Just twice this past week I was ready to ask a question on the forum and was preparing a SSCCE to post and sure enough both times the creation of the SSCCE caused me to look at the problem differently and I solved it. I would much rather solve a problem on my own then post a question and wait for hours (days) hoping someone else knows the answer.

  • Few values of report column do not display in report while applying filter

    Post Author: anuragg11
    CA Forum: WebIntelligence Reporting
    There are 6 drill filters applied on the report to filter out the report column data. Few values of the report are not displaying in the report when using drill filter. Same issue is with report filter too. If filters are removed then values are appearing in the report. We are using version BO XI R2 & Java runtime JRE 1.4v. It doesn't look issue is with Java version because only few specific data of the report column are not shown in the report when using filter on the data. Example: One of Report data column contains below values: 24.2, 26.9, 120.1, 230, 274.9, 275.8, 333.2 Report is displaying all these values when there is no filter on any data. But report doesn't display data when applying filter on 274.9 or 120.1 howver filter on other values 24.2, 26.9, 230, 275.8, 333.2 are working fine.

    Hello,
    I think i know what your problem is.
    Although in table view your 2 requests combine perfectly and show separate results in pivot view BI unfortunaterly adds them up.
    One work around would be to go in your criteria add in each request a dummy column. This can be obtained the following way:
    1. click on a column to add it in the criteria (it doesnt matter which one)
    2. go into the edit formula of that column
    3. delete the formula and in its place write 'Dummy Column 1'
    Do the same for the second request by adding a "Dummy Column 2'
    Now the Pivot Table should also show up correctly
    Let me know if it goes well or if you have any further questions,
    Kostis

  • If free characteristic is dragged into columns % is not displayed correctly

    Hi,
    I am working on query designer BW3.5,
    In one of my queries I have a key figure for calculating percentage of total number of employees.
    the report is working fine.
    Now end user is saying that if he drags any of the free characteristic into columns such as state or zip, the % is not displayed instead X is dispalyed everywhere.
    Please provide me some pointers as how to resolve this issue.
    Thanks,
    Rashmi.

    Hi,
    you should have a look at the detailed data within that query. In most cases like this it seems to calculate a value by doing a division by zero.

  • Using SharePoint 2013 OIP the "Title" column is not displayed

    Using the SharePoint 2013 OIP against our SharePoint 2013 environment, I am seeing that the "Title" column is never displayed in any of the activities or published data.  This is the only limitation that is preventing me from using this OIP.
     Currently using the scorch OIP and am concerned that it seems is not being actively maintained.  Which by the way shows the Title column in all the same lists I am connecting to with the Microsoft provided OIP.
    Thanks for any guidance you can provide,
    Jim

    Hi Jim, this is something I've seen before. It may be a bug in the SharePoint 2013 IP, though it does work in some cases and not in others, so difficult to say what the cause is. My recommendation is to change your list to make the default Title column optional
    and hidden, and use a new custom field for the name of the item instead. See also:
    http://sharepoint.stackexchange.com/questions/118181/how-to-remove-title-column-in-sharepoint-2013-list
    Noah Stahl | Automys |
    Downloadable Microsoft automation examples and solutions

  • My JTable Column is not removing?

    public class  ClassA extends JPanel
        private DefaultTableModel model = new DefaultTableModel();
        private JTable table = new JTable(model);
         public ClassA ()
         {  this.add(new Table1Panel() );
         public class Table1Panel extends JPanel
         {  clearTable();
            model.addColumn("col1");
            //add 5 rows
         public class Table2Panel extends JPanel
         {  clearTable();
            model.add("col2");
            //add 10 rows
         public void clearTable()
            while(model.getRowCount() != 0)
                model.removeRow(0);
            while(table.getColumnModel().getColumnCount() != 0)
                table.removeColumn(table.getColumnModel().getColumn(0));
    }I've been researching for days and I can't seem to figure out interfacing with JTable.
    How my program is supposed to work - program starts with Table1Panel. When a button is clicked, everything in Table1Panel should be removed and the variables, table and model, are supposed to be cleansed of all rows, data, and columns and Table2Panel is to be displayed with just "col2".
    The problem: When the button is clicked, the columns in the table are never removed and the table displays as "col1 | col2" when it should only be "col2". If I click that button a second time, it will display as "col1 | col2 | col2".
    This is the logic i use to removeColumns. What am I not understanding?
    while(table.getColumnModel().getColumnCount() != 0)
    table.removeColumn(table.getColumnModel().getColumn(0));

    I think I found your problem, it can be demonstarted in the code below:
    You kept adding more and more columns to your model. even though you took the columns away from your JTable because you added columns to your model and made your tables based on that model the columns just kept getting bigger and bigger. Every time you called new table1 or new table2 you added 2 more columns... Test this theory out, this is what I did with your code.
    Not sure this is exactly what you want, but if it needs to do something different for a specific reason let me know and we can play around with it more..
    Only thing about this, not sure if you want it this way or not is that it holds the users imput when switching back and forth.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.table.DefaultTableModel;
    public class ClassA extends JPanel
        private DefaultTableModel model1 = new DefaultTableModel();
        private JTable qtable1 = new JTable(model1);
        private DefaultTableModel model2 = new DefaultTableModel();
        private JTable qtable2 = new JTable(model2);
        private JButton jbButton1 = new JButton ("View Table1");
        private JButton jbButton2 = new JButton ("View Table2");
        private Boolean DEBUG = true;
        JPanel panel = new JPanel();
        public ClassA ()
             //Setup table 1
            model1.addColumn("col1");
            model1.addColumn("col2");
            for (int i=0; i<5; i++)
            { model1.addRow(new Object[]{null,null});  }
            qtable1.getColumnModel().getColumn(0).setPreferredWidth(600);
            qtable1.getColumnModel().getColumn(1).setPreferredWidth(200);
            qtable1.setRowHeight(20);
            qtable1.setPreferredScrollableViewportSize(new Dimension(500,500));
            //Setup table 2
            model2.addColumn("col3");
            model2.addColumn("col4");
            for (int i=0; i<5; i++)
             model2.addRow(new Object[]{null,null});
            qtable2.getColumnModel().getColumn(0).setPreferredWidth(600);
            qtable2.getColumnModel().getColumn(1).setPreferredWidth(200);
            qtable2.setRowHeight(20);
            qtable2.setPreferredScrollableViewportSize(new Dimension(500,500));
            this.setLayout(new FlowLayout());
            panel.add(new table1());
            this.add(panel);
            this.add(jbButton1);
            this.add(jbButton2);
            jbButton1.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e){
                    System.out.println("1");
                    panel.removeAll();
                    panel.add(new table1());
                    panel.revalidate();
                    repaint();
            jbButton2.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e)
                    System.out.println("2");
                    panel.removeAll();
                    panel.add(new table2());
                    panel.revalidate();
                    repaint();
    private class table1 extends JPanel
        public table1 ()
        {    //qtable.setFillsViewportHeight(false);
                JScrollPane scrollPane = new JScrollPane(qtable1);
                this.add(scrollPane);
    private class table2 extends JPanel
           public table2()
             //qtable.setFillsViewportHeight(false);
                JScrollPane scrollPane = new JScrollPane(qtable2);
                this.add(scrollPane);
        public static void main (String[] args)
            JFrame frame = new JFrame("Test ImportQuestionPanel");
            frame.getContentPane().add(new ClassA());
            frame.pack();
            frame.setVisible(true);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

  • 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

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

  • MacBook Pro Stuck in Recovery Loop; Disk Utility Error

    I am getting the error: Disk Utility Stopped Repairing "disk0s2" - says disk utility can't repair the disk and I will need to reformat the disk and restore my files. This appears to be the startup disk (could be wrong) - as I am currently in recovery

  • Article Purchasing tax P8 calculation schema

    Please help with following situation: 1 Purchasing Org for several Comp Codes Purchasing Org is not assigned to any of them Purchasing Info Records are created at Purchasing Org level When tax code P8 is entered for VAT, system issues following error

  • Server connection error 403 on photosmart 5520

    I too have a 403 error code on my photosmart 5520. I have turner off the router & 5520, I have a connection, but still cannot scan to email.

  • Files Crash when using files on a PC server using a Mac

    I have a user that when working in InDesign for awhile the files will crash the app and they loose all the progress they made. the files are stored on a windows file server running 2008r2. the mac os version is 7.5 and the cs version is cs5.5.

  • Issue Credit Memo

    Hi All, Our scenario is like this: PO created.GR done using 101 Movement Type.Invoice posting through ERS run using MRER.Now ,GR is cancelled using 102 Movement Type.Payment and Clearing done using FBZ1 (Manual Outgoing Payment). Now ,we require to g