Jtable not showing column Names

I wrote the following Code and strangely it isn't showing the column Names....
The mistake should be foolish..but i can't figure it out...
can you please help.. or give any alternate way to do the same
import javax.swing.*;
import javax.swing.table.*;
public class test
     public static String[] columnNames = {"User Name","User ID"};
     public static void main(String args[])
          JFrame frame = new JFrame();
          frame.setSize(400, 400);
          DefaultTableModel tabmodel = new DefaultTableModel(columnNames, 15);
          JTable table = new JTable(tabmodel);
          frame.add(table);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setVisible(true);
}

Hi,
A JScrollPane is needed to display the headers.
import javax.swing.*;
import javax.swing.table.*;
public class TestTable {
    public static String[] columnNames = { "User Name", "User ID" };
    public static void main(String args[]) {
     // PB All GUI creation on the EDT
     SwingUtilities.invokeLater(new Runnable() {
         @Override
         public void run() {
          JFrame frame = new JFrame();
          frame.setSize(400, 400);
          DefaultTableModel tabmodel = new DefaultTableModel(columnNames,
               15);
          JTable table = new JTable(tabmodel);
          // PB frame.add(table);
          frame.add(new JScrollPane(table)); // PB
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setVisible(true);
}Piet

Similar Messages

  • JTable not seeing Column names from Abstract table model

    Here is the code for the getColumnNames method
    It is getting called and it is send the correct data However the Headings do not match the data.
    public String getColumnName(int col){
    String s_retval;
    switch (m_iMode){
    case PhoneTableModel.NORMALVIEW:
    default:
    s_retval= m_sHeadingsDefault[col];
    break;
    System.err.println("TableNames "+s_retval);
    return s_retval;
    }

    Why do you show the part of the code that works?!
    Show how you create and display your table!
    What is displayed in the headings then?
    Which JDK on which platform?

  • After upgrading my iPhone 4S to iOS6, my Find My Friends app no longer links to my Contacts and does not show contact names. It only shows e-mail addresses and does not link up to the corresponding email address in my Contacts. How can I fix this?

    After upgrading my iPhone 4S to iOS6, my Find My Friends app no longer links to my Contacts and does not show contact names. It only shows e-mail addresses and does not link up to the corresponding email address in my Contacts. How can I fix this?

    I am also having problems with a site I am building. No matter what websafe font I use it displays as New Times Roman in FireFox. The correct fonts show in both IE9 and Chrome.
    In addition, text shifts in FireFox. I have to position other text objects farther and farther apart as I go down the page or they start to overlap. Nav buttons and other images also have to be positioned in the wrong place for them to be in the correct place when the page is opened in FireFox. FireFox should display pages correctly by default. I can't expect th average user to have to tweek his/her settings to display my site.
    I have been recommending FireFox on my website as the best browser. I might have to change that and abandon FireFox myself.

  • I have an I phone 4s and I have many contacts in my phone.  However, whne my phone rings or I receive a text, the phone does not show the name of the contact person only the phone number.  I have checked every setting I can think of ?

    I have an I phone 4s and I have many contacts in my phone.  However, when my phone rings or I receive a message.  The phone does not show the name of the caller.  It only shows the phone number that is calling.  I am sure this is a setting problem, but I have checked every setting I can think of.  Any suggestions??

    If you are a Verizon user try this:
    Open the phone and dial *228. This is a Verizon over-the-air programming number.
    When the system answer press 1 for "Program or activate your phone"
    Wait for the call to disconnect. You should get a prompt stating "Settings updated."
    Double tap the Home button to bring up the recently used apps list at the bottom.  Locate the Phone, Message, and Contacts apps, swiping if necessary, and press and hold until they jiggle then press the red minus sign to stop them.
    Wait a 3-5 minutes.
    Try your phone again and see if it's fixed.

  • Not displaying column names in dynamic pages?

    I'd like to use a dynamic page as a detail page. In doing this I need a bit more freedom of design than what I now know is possible. Most important - I only need to print out the values returned by the SQL, not the column names as well. And I need to define the colors and fonts of the html table tags surrounding the returned values. How?
    It seems a bit strange that I am allowed to change the look and feel of the surrounding page elements through defining my own templates, and then have Oracle define how the elements placed in the templates are to appear.

    Hi,
    It is not possible to change the format the output coming from the <oracle> tags.
    Thanks,
    Sharmila

  • Not showing Caller Name on E51

    I have upgrade software but after that my phone not showing caller name on the screen.Before upgrading my phone was shwoing caller name when I received call. my all phone numbers are on SIM , can some body let me know how this will work or its setting.

    The problem may be, that you have all your contacts on the SIM card and on the phone as well. Is that possible?
    Duplicate matches for a specific phone number lead to not showing a phone number at all...
    By clicking the "Kudos!" or the "Solution?" button on the right you can say "Thank You" and you´ll show the author and others that the post is useful.
    The day we stop improving is the day we stop being good.

  • 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

  • My iPhone 5 does not show caller name even though the number is saved with a name in contacts

    My iPhone 5 does not show caller name even though the number is saved with a name in contacts

    Contact your carrier. Caller ID is a carrier feature.

  • E52 not showing contacts name in inbox

    Hi,
    iam facing this problem of my e52 not showing contacts names in inbox.
    Some of the contacts name are shown, those which was originally in my phone memory.
    because i do a lot of trading, i constantly adds new numbers to my contacts from the sms they sent. But the main problem is here is even after i added their contact giving them names, the names doesnt show up in inbox, its still just numbers.
    desperately need help for this. how can a business phone have this kind of problem?
    Solved!
    Go to Solution.

    This happens to me too when I store the number under two names, or the synchronization creates double entries, for example:
    Two names:
    1234    Anna    
    1234    Bea
    Double entries
    1234    Anna
    1234    Anna
    When the text message comes in, there's no name. But you can send a message either to Anna or Bea and the message outbox shows the proper name.
    The solution is to delete one entry or merge the duplicate contacts.
    Hope this helps.

  • On OS 5, the contacts with international format do not show the names when they call me. any idea why?

    I have updated my Iphone 4 software to OS5, and since then the names of the people who call me stopped to appear and only their number is showing. after checking, i found out that the contatcs whom local phone number is saved in an international format are affected by this problem. if i save them without the country code, then their names appear.
    Also, some non local numbers that are saved in the format of 00966--------- instead of +966 ------- are also not showing the name of my contact when they call me.
    any idea about this knowing that the older OS version didn't have an issue with this?
    Thanks

    This is the same problem I have.  I thought it was my phone only, but now I realize it is a common thing.  I hope they release a fix to this, as they did in 2007 & 2007 when 3G was released.  Will be waiting and good luck to us all.

  • Bpel console not showing domain name

    Hi
    i have installed a new jdev 10.1.3.1 and also have 10.1.2. first version is working fine examples but bpel console is not showing domain name in 10.1.2.
    pls anyone can tell me what may be the problem.Is it bcoz of two version in same machine.?? Its urgent help out............

    this is understandable - at per default we use oracle lite - which only allows ONE installation on a windows system ..
    to run both in paralell you have to install a db and create the 2 schemas (10.1.2.0.2 and 10.1.3.1) - I posted a blog note on this ..
    http://clemensblog.blogspot.com/2006/04/oracle-bpel-xe-part-2.html
    hth clemens

  • JTable - Help with column names and rowselection

    Hi,
    Is there anyone that can help me. I have successfully been able to load a JTable from an MS access database using vectors. I am now trying to find out how to hardcode the column names into the JTable as a string.
    Can anyone please also show me some code on how to be able update a value in a cell (from ''N'' to ''Y'') by double clicking on that row.
    How can I make all the other columns non-editable.
    Here is my code:
         private JTable getJTable() {
              Vector columnNames = new Vector();
    Vector data = new Vector();
    try
    // Connect to the Database
    String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
    // String url = "jdbc:odbc:Teenergy"; // if using ODBC Data Source name
    String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/Documents " +
              "and Settings/Administrator/My Documents/mdbTEST.mdb";
    String userid = "";
    String password = "";
    Class.forName( driver );
    Connection connection = DriverManager.getConnection( url, userid, password );
    // Read data from a table
    String sql = "select * from PurchaseOrderView";
    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 );
              if (jTable == null) {
                   jTable = new JTable(data, columnNames);
                   jTable.setAutoCreateColumnsFromModel(false);
                   jTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_NEXT_COLUMN);
                   jTable.setShowHorizontalLines(false);
                   jTable.setGridColor(java.awt.SystemColor.control);
                   jTable.setRowSelectionAllowed(true);
                   jTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
                   jTable.setShowGrid(true);     
              return jTable;
         }

    this method has a default behavior to supply exactly what you're seeing: column names consisting of the capitalized letters, "A", "B", "C".Thanks Pete, had seen that but never really thought about it... about 10 days ago somebody needed to obtain Excel column names, I'd offered a rigorous solution and now see it would have been shorter and simpler (if a little heavier) to extend DefaultTableModel and provide the two additional methods needed (getOffsetCol and getColIndex).
    Not much of a difference in LOC but certainly more elegant ;-)
    Darryl

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

  • Listdata.svc - shows column names?

    I have leveraged the REST service using listdata.svc many times. However, we are having trouble with one site in particular.  Cannot use REST with it and getting all sorts of errors in Visual Studio. This post is not about VS or C#, however, just about
    what should be in the REST schema period. I am seeing tons of huge node values when looking at the listdata.svc in a browser.  It appears these are a combination of the list name and the column name.  I didn't think column names showed up at all,
    just list names?
    For example:
    <collection
    href="InvestmentPortfolioAnticipatedProjectTeamSizeFTESContractorsCustomersVendorsEtc">
    <atom:title>InvestmentPortfolioAnticipatedProjectTeamSizeFTESContractorsCustomersVendorsEtc</atom:title>
    I found that Investment Portfolio is a legit list in the site, but the rest of that value is a column name.  Other lists do not have columns listed in this schema when viewing from the browser.  Can someone explain to me why this is happening?
    Thanks

    Hi,
    If you access http://siteurl/_vti_bin/listdata.svc, the preceding url returns all the lists in XML format. There will be no column name included in a <collection> node for normal lists, except when
    there is Choice column in this list.
    There will be extra <collection> nodes listed as the format below for the lists which contains Choice column:
    <collection href="ListnameColumnname">
    <atom:title>ListnameColumnName</atom:title>
    </collection>
    It seems this extra <collection> node is for internally use only which is not designed to be exposed to developers.
    I would suggest you submit a feedback to the Office Developer Platform if there any expectation about the documentation about SharePoint APIs:
    http://officespdev.uservoice.com/
    It is a place for customers provide feedback about Microsoft Office products. What’s more, if a feedback is high voted there by other customers, it will be promising that Microsoft Product Team will take it into consideration when designing the next version
    in the future.
    Regards,
    Rebecca Tu
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • IMessage not showing contact names

    I just recently downloaded and installed OS X Mavericks on my 2011 iMac and trying to get up and running with the new iMessage app. But there are two major bugs I can figure out how to fix if anyone can help me fix these problems or comment if your having the same issues that would be a big help.
    1: When receiving a message from someone in my contacts list/address book, their names do not apper next to the message, but rather only their phone numbers. I have went thought the view options and selected show contacts name and also tried adding a name to the existing number with no results. Does anyone know how to fix this bug?
    2: The lag time between SMS/iphone messages and the time it takes to show up in iMessage on my mac is rather long. There is about a 3 minute delay before the text message conversation shows up from my phone to computer. Any suggestions on how to fix this?
    Thanks

    Hi,
    Re 2).
    This is a bit of a "known Issue" with no current fix.
    The issue is related to the fact a iOS device seems to get the "first " push of the iMessage and that the Mac only gets "Sync" push which seems to be slower (and for some bizarre reason not always in order)
    Re 1) I have seen this reported but maybe not as clearly as your post.
    No-one seemed to make it clear the Contacts were in the Address Book (Contacts app) and that it seemed to be ignoring the Names for just the Numbers.
    Obviously you can use the View Menu > Messages > Show Pictures and Name (or Show Names)
    As you say this should link the ID or iPhone Number being used in the iMessages to the "Real Name" in the Address Card for that person.
    The options are:-
    A) You are receiving an iMessage from an iPhone Number but the link to the Address Card is not working.
    If you make sure you are sending to an Apple ID what do you see ? (Apple ID or Real Name or in fact the iPhone number again)
    This may be because you have lost the ability to "read" the saved data for the Contacts app.
    B) Check the Contacts app and see if it is Syncing properly with any iOS device (i.e that all items have the Name as well as an iPhone number in the Address Card.)
    10:32 pm      Thursday; November 7, 2013
      iMac 2.5Ghz 5i 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

Maybe you are looking for