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.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
        jTable1.setCellSelectionEnabled(true);
        jTable1.setMinimumSize(new java.awt.Dimension(340, 90));
        jTable1.setTableHeader(null);

Try to place JTable inside of JScrollPane.
Generated code:
    private void initComponents() {
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        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"
        jScrollPane1.setViewportView(jTable1);
        getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
        pack();
    }

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:
    http://public.ceving.de/2012050900/postaladdress_10g.png
    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

    Hi,
    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,
    Tom
    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
    Regards
    sam

    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
    alex

    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:
    setReorderingAllowed(false);

  • 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("Drive");
         cN.add("Location");
         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.
    *http://kb.mozillazine.org/Website_colors_are_wrong
    *http://kb.mozillazine.org/Websites_look_wrong

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

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

    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;
      }Thanks
    Richard

  • 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
    table.setTableHeader(null);
    that will do the trick;
    cheers
    krishna

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

    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: www.exampledepot.com 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?
    Cheers?

    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"},
                       {"1-0","1-1","1-2"},
                       {"2-0","2-1","2-2"}};
         JTable myTable = new JTable(data,head);
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         Container content = getContentPane();
         content.add(new JScrollPane(myTable), BorderLayout.CENTER);
         setSize(200,200);
         show();
        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));
         this.app=app;
         img = app.getImage(app.getCodeBase(), "cloud.gif");
    public void paint(Graphics g)
         g.drawImage(img,50,50,this);
    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();
    canvas.init(this);
    //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
    /*JButtons*/
         button1_JPanel = new JPanel();
    button1_JPanel.setLayout(new BorderLayout());
    button1_JPanel.add(button1);
    button2_JPanel = new JPanel();
    button2_JPanel.setLayout(new BorderLayout());
    button2_JPanel.add(button2);
    button3_JPanel = new JPanel();
    button3_JPanel.setLayout(new BorderLayout());
    button3_JPanel.add(button3);
    button4_JPanel = new JPanel();
    button4_JPanel.setLayout(new BorderLayout());
    button4_JPanel.add(button4);
    button5_JPanel = new JPanel();
    button5_JPanel.setLayout(new BorderLayout());
    button5_JPanel.add(button5);
    button6_JPanel = new JPanel();
    button6_JPanel.setLayout(new BorderLayout());
    button6_JPanel.add(button6);
    button7_JPanel = new JPanel();
    button7_JPanel.setLayout(new BorderLayout());
    button7_JPanel.add(button7);
    button8_JPanel = new JPanel();
    button8_JPanel.setLayout(new BorderLayout());
    button8_JPanel.add(show_button8);
    // all JButtons JPanel
    JButtons = new JPanel();
    JButtons.setLayout(new FlowLayout());
    JButtons.setBackground(new Color(228, 241, 250));
    JButtons.add(button1_JPanel);
    JButtons.add(button2_JPanel);
    JButtons.add(button3_JPanel);
    JButtons.add(button4_JPanel);
    JButtons.add(button5_JPanel);
    JButtons.add(button6_JPanel);
    JButtons.add(button7_JPanel);
    JButtons.add(button8_JPanel);
    //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());
    tables_JButtons_JPanel.add("North",table);
    tables_JButtons_JPanel.add("South",JButtons);
    // Display the JPanels..
         this.setLayout(new BorderLayout());     
    add("North",topic);
    add("Center",canvas); // here i want to add some images and drawings
    add("South",tables_JButtons_JPanel);
    }// 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","","","","","",""},
                             {"Utilities","","","","","",""},
                             {"Groceris","","","","","",""},
                             {"Clothes","","","","","",""},
                             {"Bills","","","","","",""},
                             {"Automobile","","","","","",""},
    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>Wealthy</BR>"
                   +"<BR>and</BR>"
                   +"<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));
              table.getColumnModel().getColumn(0).setPreferredWidth(70);
              table.getColumnModel().getColumn(1).setPreferredWidth(10);
              table.getColumnModel().getColumn(2).setPreferredWidth(10);
              table.getColumnModel().getColumn(3).setPreferredWidth(10);
              table.getColumnModel().getColumn(4).setPreferredWidth(10);
              table.getColumnModel().getColumn(5).setPreferredWidth(10);
              table.getColumnModel().getColumn(6).setPreferredWidth(10);
              table.getTableHeader();
              JScrollPane sp = new JScrollPane(table);
              sp.add(table);
              east.add(quote);
              east.add(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

  • XI 7.0 Software Component on SLD

    Hi, i am new in using XI 7.0 based on NW2004s i can not delete Software Component Versions i created, remove buttom is disable. how can i delete SWC? i can delete product, but not software component when i create software componet, what is unit? than

  • How can you detect all words and phrases in a text document using java?

    Is there some java API which would help me extract all words, multi-word phrases, punctuations in an English text document? I would also like to get the order in which they appear with sentence detection. I've been searching for this in java NLP pack

  • Transfering ppurchased music to other computer

    i purchased several albums from itune store to my laptop. and burnd audio CD to import to tower computer. when put CD in tower, it's said "song names not be found online." and playlist information did not show, shows only track number. why music info

  • How can I Increase the Thickness of Blinking Cursor in adobe reader?

    I sometimes refer to another part of file of pdf and to get back, blinking cursor is supposed to help me but it is tiny blinking I have hard time to find it back. How can I increase the thickiness of blinking cursor in adobe reader?

  • No Covers in grid and list modes, but in Cover Flow and Information

    I have Itunes 9.0.2 and the Covers of the songs are only shown in Cover Flow and under Information. If I'm in grid mode or other modes they are not shown. In the left down corner there is only black. Any idea?