SJSE8 JTable creation doesn;t show column headers

I am a swing/applet newbie. I am using SJSE8 GUI Editor to create an applet containing a JTable. When I use the table poperties to set the column headers and defaults data, I see the data but not the header. What am I doing wrong? The generated code follows:
        jTable1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 51)));
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][]
                {"Elimination", "NFL", "$100+$10", "21/100", "June 1st", "Open", "$2100.00"},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null}
            new String []
                "TYPE", "Sport", "Price", "Players", "Closing", "Status", "Prize Pool"
            Class[] types = new Class []
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            boolean[] canEdit = new boolean []
                false, false, false, false, false, false, false
            public Class getColumnClass(int columnIndex)
                return types [columnIndex];
            public boolean isCellEditable(int rowIndex, int columnIndex)
                return canEdit [columnIndex];
        jTable1.setMinimumSize(new java.awt.Dimension(340, 90));

Try to place JTable inside of JScrollPane.
Generated code:
    private void initComponents() {
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
        getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);

Similar Messages

  • Form results does not show column headers

    I created a form and when I enter info and then view the results, the results page does not show column headers.  How do I correct this?

    I just found out that the engineered version (10g) is also quite strange:
    It shows the values in the columns for the types.
    This looks very buggy.
    Is it not recommended to create views with the data modeler?
    Edited by: 931739 on 09.05.2012 06:38

  • JTable -showing column headers and displaying multi-line strings

    This is two questions really.
    #1 - Does anyone know why my column headers aren't showing in my jtable using the model below?
    #2 - Does anyone know how I can display, mulitple line strings in a jtable? Currently my newline character ('\n') is just being displayed as a character.
    any help very much appreciated,
    private class TaskHistoryTableModel extends AbstractTableModel {
    private List taskHistory = new ArrayList();
    public Object getValueAt(int row, int col) {
    if (col == 0) {
    return ((TaskHistoryItem) taskHistory.get(row)).getText();
    } else {
    return ((TaskHistoryItem) taskHistory.get(row)).getDate().getTime();
    public int getRowCount() {
    return taskHistory == null ? 0 : taskHistory.size();
    public int getColumnCount() {
    return 2;
    /** Getter for property taskHistory.
    * @return Value of property taskHistory.
    public List getTaskHistory() {
    return taskHistory;
    /** Setter for property taskHistory.
    * @param taskHistory New value of property taskHistory.
    public void setTaskHistory(List taskHistory) {
    this.taskHistory = taskHistory;
    public String getColumnName (int col) {
    return col == 0 ? "Text" : "Entered At";
    public boolean isCellEditable(int row, int col) {
    return false;

    fixed my own problem - make your mulit-line string into html format e.g.
    this string will appear on two lines in a jtable
    "<html><p>A much more interesting entry</p> <p>on multiple lines</p></html>"

  • FSG report output does not show column headers (XML Publisher)

    Hi everyone
    Iam required to create a template for an FSG report with 20 columns. Used copy of FSG:Fixed number of columns Template(FSGTEMP) to create the template because i need to do some conditional formatting(need to show negative values in red color).
    here is the problem:
    when i use the template and run the program the output i can see the row data but not the column headers..column headings are blank!
    regarding the conditional formatting, can anybody tell me how to give the condition
    iam able to give the condition for oracle reports but not for FSG reports as i dont see the column name in the 'data field' in conditional format

    Open the report in Edit Mode Click on the reports and in the properties section Uncheck the
    Enable Document Cache Property and your issue should be resolved.

  • Jtable stop mouse hover over column headers

    i have a jatable and when i move the mouse over the column headers
    it does the hover effect and highlights the column header
    in this particular table i don't want any sorting or column moving, so i want to disable this effect
    i have looked through the JTableHeader api's but i am not sure which one to use to turn it off. i tried .setFocusable(false) but that didn't seem to work
    any suggestions ?
    thanks in advance

    by default, JTable does not have the hover effect, highlights of the column header, and sorting. you must have implemented these in your codes.
    as for the column moving, you may try this:

  • JTable column headers missing

    I created a JTable using:
    JTable table = new JTable(v,cN);
    where v is my vector that holds the data and cN is a vector to hold the column names as below:
    Vector cN = new Vector();
         cN.add("Registry Keys");
         cN.add("Program Name");
         cN.add("Key Type");
         cN.add("Leave");It displays the table fine with the data and as I add or remove entries in the cN vector it adds and removes columns - but doesn't display column headers? Any help appreciated.

    Are you using a scrollpane? If not, you have to get the Table Header component and place it appropriately.

  • Firefox doesn't show headers on websites or mail options such as fonts, etc

    Firefox is the only browser that I'm having these problems with. They are as follows:
    In the compose e-mail block of my yahoo, it doesn't show the options for fonts, size of fonts, backgrounds, etc. It also won't let me change the color of the fonts. It just shows blank boxes. Not only can't I change things in individual e-mails that I compose, I can't change my e-mail options.
    In the customize backgrounds and colors for my yahoo page, it doesn't let me change colors or themes.
    In websites, it doesn't show the headers of the website, including name of website and selections. It's blank. The body of the website shows up. Just not the header.
    Is there a way restore Firefox to it's original state? If so, how do I do this? Or do I need to uninstall it and reinstall it? I didn't do this when I first started using Firefox.

    Make sure that you allow pages to choose their colors and that you haven't enabled High Contrast in the Windows Accessibility settings.

  • 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 follows...but neither one gets the headers right:
    JScrollPane jScrollPane = new javax.swing.JScrollPane(getTable());or
    JScrollPane jScrollPane.setViewportView(getTable());Note: getTable() 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.

  • JTable Column Headers are Squashed!

    Hi there,
    I'm using JBuilder, and have created a simple enough JTable that I place inside a JScrollPane. I am using my own implementation of the AbstractTable model.
    When I run the code, the Column headers are only about 5 pixels high! I have hunted around the JBuilder code (which if you have used JBuilder you will know is extensive!), but it doesn't seem to be doing anything extraordinary.
    So has anyone else had this problem? If so, what did you do to rectify.
    Yours hopefully

    Hello there, my abstract implementation looks a little like this:
      public static final String columns[] = { "", "Request Id", "Date", "Component Name", "Version", "Type" };
      public String getColumnName(int columnIndex) {
        return columns[columnIndex];
      public Class getColumnClass(int columnIndex) {
        if (columnIndex == 0) {
          return Boolean.class;
        } else if (columnIndex == 1) {
          return Integer.class;
        } else {
          return String.class;

  • JTable Column Headers

    I want to create a JTable so that the table doesn't have any column headers. Right now I am using my own implementation of the AbstractTableModel Class for use with the tables, but if I leave out the public String getColumnName(int col) method, it makes the headers A, B, C, ... and if I set the column headers up with a blank String, it leaves an obvious thin empty header at the top. Any suggestions on how I can completely leave the column headers off?

    call the method on JTable
    that will do the trick;

  • JTable auto size columns/headers

    How do I autoresize a JTable column/headers so that each column/header is the minium size necessary.
    I've tried setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); and that doesn't
    seem to work.

    You need to calculate the width of the text and set the preferred size of each column.
    If seen solutions posted in the forum (but no I don't know the exact posting) so you can search the forum to find them.

  • JTable column headers missing..kindly help...

    Hello there!
    I have written a program that ultimately deals with database connectivity, but my problem is got more to do with JTable. that's why i decided to post my doubt here.
    my program displays a JTable by reading fields form a database.
    But you see, the column headers are missing!!
    I have used the concept of DefaultTableModel, i first searched google and came upon a website: and studied the sample codes on how insert fields into a JTable using the above....
    i swear to god i have done the exact same things..
    Could you please help me out??
    Thankyou very much and have a great day!

    done that alreadyThen your problem is solved?
    Or does that mean that you had already done it and no headings showed up? In that case there's something wrong with your code.
    And Swing questions should be posted in the Swing forum.

  • JTable without column headers?

    I want a JTable without the column headers.
    How can i do this?

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Test extends JFrame {
        public Test() {
         String[] head = {"","",""};
         String[][] data = {{"0-0","0-1","0-2"},
         JTable myTable = new JTable(data,head);
         Container content = getContentPane();
         content.add(new JScrollPane(myTable), BorderLayout.CENTER);
        public static void main(String[] args) { new Test(); }

  • JTable Header & column Headers

    i want to add a table Header(Level 1 Students)
    and a columns Headers(Name ID Section#)
    How can i do that ?
    Thanks a lot
    This is my code:
    import java.awt.*;
    import java.applet.*;
    import java.applet.Applet;
    import java.awt.image.*;
    import javax.swing.*;
    import java.util.*;
    class DrawingCanvas extends Canvas{
    Applet app;
    Image img;
    public void init(Applet app)
         setBackground(new Color(165, 215, 220));;
         img = app.getImage(app.getCodeBase(), "cloud.gif");
    public void paint(Graphics g)
    public class Table_Button extends JApplet {
         DrawingCanvas canvas;
         // a separate JPanel is associated with each JButton
    JPanel button1_JPanel, button2_JPanel, button3_JPanel, button4_JPanel,button5_JPanel,button6_JPanel,button7_JPanel;
    JPanel button8_JPanel;
    JPanel topic;     //For Topic name
    JPanel JButtons; // for all the JButtons
    JPanel tables_JButtons_JPanel;
    JTable table;
    JButton button1,button2,button3,button4,button5,button6,button7;
    JButton show_button8;
    public void init(){
    canvas = new DrawingCanvas();
    //Controls JButtons
         button1 = new JButton("button1");
    button2 = new JButton("button2");
    button3 = new JButton("button3");
    button4 = new JButton("button4");
    button5= new JButton("button5");
    button6= new JButton("button6");
    button7= new JButton ("button7");
    //button8 JButton
    show_button8= new JButton("Show button8");
    button1.setBackground(new Color(111, 178, 230));
    button2.setBackground(new Color(111, 178, 230));
    button3.setBackground(new Color(111, 178, 230));
    button4.setBackground(new Color(111, 178, 230));
    button5.setBackground(new Color(111, 178, 230));
    button6.setBackground(new Color(111, 178, 230));
    button7.setBackground(new Color(111, 178, 230));
    show_button8.setBackground(new Color(111, 178, 230));
    /*Topic Name*/
    topic = new JPanel();
    topic.setLayout(new BorderLayout());
    topic.add(new JLabel(" Topic Name ",JLabel.CENTER));
    All Controls
         button1_JPanel = new JPanel();
    button1_JPanel.setLayout(new BorderLayout());
    button2_JPanel = new JPanel();
    button2_JPanel.setLayout(new BorderLayout());
    button3_JPanel = new JPanel();
    button3_JPanel.setLayout(new BorderLayout());
    button4_JPanel = new JPanel();
    button4_JPanel.setLayout(new BorderLayout());
    button5_JPanel = new JPanel();
    button5_JPanel.setLayout(new BorderLayout());
    button6_JPanel = new JPanel();
    button6_JPanel.setLayout(new BorderLayout());
    button7_JPanel = new JPanel();
    button7_JPanel.setLayout(new BorderLayout());
    button8_JPanel = new JPanel();
    button8_JPanel.setLayout(new BorderLayout());
    // all JButtons JPanel
    JButtons = new JPanel();
    JButtons.setLayout(new FlowLayout());
    JButtons.setBackground(new Color(228, 241, 250));
    //How to set the table header(title) to (Level 1 Students)
    // How to set the table columns headers to (Name ID Section)
         table = new JTable( 5, 3 );
         tables_JButtons_JPanel = new JPanel();
    tables_JButtons_JPanel.setLayout(new BorderLayout());
    // Display the JPanels..
         this.setLayout(new BorderLayout());     
    add("Center",canvas); // here i want to add some images and drawings
    }// end inti()

    JTable Tutorial didn't specify how to add columns names when using the constructor:
    JTable(int numberofRows,int numberofColumns) Well then use another constructor. For example:
    DefaultTableModel model = new DefaultTableModel(...);
    JTable table = new JTable( model );Also, I forgot to mention don't use AWT components in a Swing application. Canvas is an AWT component. Use JPanel instead.

  • Trouble viewing column headers JTable

    I am having trouble with the column headers showing up. I have added a JScrollPane to the JTable, yet it fails to show up
    Here is the array for the data and column headings:
         String[] tableheadings = {"","Jan", "Feb", "Mar","Apr","Jun", "Jul"};
         Object data[] [] = { { "Rent","","","","","",""},
    and here is the method calling the array and placing into a JTable:
         public void doEside()
              east = new JPanel (new GridLayout(2,1));
              quote = new JLabel ("<HTML><FONT SIZE=+1><CENTER><B>\"Healthy</B>"
                   +"<BR>Wise\"</BR></CENTER></FONT>", JLabel.CENTER);
              table = new JTable(data, tableheadings);
              DefaultTableModel dmodel = new DefaultTableModel(data, tableheadings)
                   public boolean isCellEditable(int row,int column)
                        return false;
              table = new JTable(dmodel);
              table.setPreferredScrollableViewportSize(new Dimension( 200,70));
              JScrollPane sp = new JScrollPane(table);
              add(east, BorderLayout.EAST);

    That's a Swing question, it should be asked in the Swing forum.
    A JTable always represents the values provided by a TableModel.
    The JTable constructor that directly takes the heading and data is just a convenience constructor which creates a DefaultTableModel and populates it using the supplied arguments.
    You code extract creates two JTable object. The first one (the one with the data and headings) is lost for good after you reassign the variable table to the second JTavble instance. And this second instance is created with an empty DefaultTableModel.
    What you want is probably to create one single JTAble object, using a model created as:
    dtmodel = new DefaultTableModel(data, tableheadings);Edited by: jduprez on Nov 19, 2009 1:18 PM

Maybe you are looking for

  • EHP4 upgrade: Error in Phase ACT_UPG

    Hi All, While upgrading to EHP4 on ECC 6 system, we got error in phase MAIN_SHDRUN/ACT_UPG Checks after phase MAIN_SHDRUN/ACT_UPG were negative! Last error code set: Unresolved requests in buffer RH4 Check logfiles 'ACTUPG.ELG' and '/sapdump/SAPehpi/

  • Retrival of  values based on Batch Characteristics

    Dear all I am maintining some characteristics for a material on Batch classes. Like to pull the total stock based on any 1 these characteristics.Kindly suggest what are the tables we can use for this and logic Thanx MK

  • "iPhoto unexpectedly quit while trying to restore its windows"

    When I try to open iPhoto, it says "iPhoto unexpectedly quit while trying to restore its windows," then gives me the option of restoring the windows or not. Whatever one I click, iPhoto opens for a second and displays a blank gray screen, then quickl

  • Ace loadbalancer alerting (4710 standalone unit)

    Hello I wandered if someone can help me with this query. If i set up a VIP with rate-limiting, i want to be able to send the ops a team an alert to say the threshold has been reached, is this possible by syslog or snmp traps? Or what is the best way

  • Process chainTransport requests

    hi all, can you plz. clarify these doubts: 1. If i activate a process chain, a request will be created. In this req. will all the objects(i.e. process) collected ? when we move it will all the objects move? 2. whenever i make changes( modify or add n