Results 1 to 4 of 4
  1. #1
    phil128 is offline Member
    Join Date
    Sep 2008
    Posts
    40
    Rep Power
    0

    Default JTable doesnt show columun names!

    Hello. I'm trying to use JTable in my application and at the same time using tabbes to switch between my different JPanels. And within one of them panels i've got a JTable showing but it doesn't show the columun names of the cells! I'm really stuck in the mud :-(. This is my code:



    public class EditPanel extends MainPanel { //inherit MainPanel

    JPanel editPane;
    final JTable table;


    public EditPanel(){


    String data[][] = {{"vinod","BCA","A"},{"Raju","MCA","b"},
    {"Ranjan","MBA","c"},{"Rinku","BCA","d"}};
    String col[] = {"Course","Grade"};



    editPane = new JPanel();
    table = new JTable(data,col);

    tabs.addTab("Edit", editPane);

    editPane.setLayout(new BorderLayout());


    editPane.add(table, BorderLayout.SOUTH);
    editPane.setOpaque(true);




    }




    }

    Can anybody see where i'm going wrong please? Driving me nuts

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    first put the jtable into a jscrollpane, THEN place it in your jpanel. Either that or you will have to take pains to display the table header -- usually placing the table in its own panel borderlayout.center and the header borderlayout.north. Easiest though is my first recommendation.

  3. #3
    phil128 is offline Member
    Join Date
    Sep 2008
    Posts
    40
    Rep Power
    0

    Default

    Excellent! I'm so happy you've helped me out! I'm thankfully greatfull!

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. java doesnt allow vista to work
    By 10rosas in forum New To Java
    Replies: 5
    Last Post: 12-22-2008, 04:23 PM
  2. Replies: 2
    Last Post: 05-15-2008, 10:15 AM
  3. netbeans 6.0 not show commpunent or show blank page
    By fahimaamir in forum NetBeans
    Replies: 1
    Last Post: 01-26-2008, 06:20 AM
  4. Drive names
    By alwz_nikhil in forum New To Java
    Replies: 0
    Last Post: 11-28-2007, 10:04 AM
  5. My program doesnt display anything
    By Bojevnik in forum AWT / Swing
    Replies: 2
    Last Post: 10-19-2007, 02:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •