Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: JTable

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JTable

    hey this is a simple request, i've recently began utilizing GUIs and i want to implement a JTable with vertical scroll bar and title headers. unfortunately after looking around i haven't found anything example code
    so you could could drop me the most basic and simplest code for creating a JTable with those properties it would be a great place for me to start from and dissect
    thanks


  2. #2

  3. #3
    Junior Member
    Join Date
    Apr 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JTable

    i've been the several times however this time i noticed that the code COULD be access if you clicked the hyperlinks, without that code the lessons were useless so i continued on. imagine how frustrating it was to find this
    thanks copeg for bringing it to light once again

    i am able to create a scrollpane but nothing is showing up inside
     JScrollPane scrollbar = new JScrollPane( table );
            scrollbar.setPreferredSize(new Dimension(100, 200));
            scrollbar.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            scrollbar.setHorizontalScrollBarPolicy(JScrollPane .HORIZONTAL_SCROLLBAR_ALWAYS);
           // scrollbar.setViewportView(table);
            table.setVisible(true);
     
            scrollbar.add(table);
    Last edited by timmin; April 3rd, 2011 at 11:34 AM. Reason: new problems

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: JTable

    Do not call add() on the JScrollPane to add the table - use setViewportView (which is called in the constructor so there shouldn't be a need to make this call unless you wish to dynamically change the view).

Similar Threads

  1. [SOLVED] JTable Problem
    By aussiemcgr in forum Java Theory & Questions
    Replies: 0
    Last Post: October 15th, 2010, 04:33 PM
  2. Hello everyone! I need help with JTable
    By hektor in forum AWT / Java Swing
    Replies: 6
    Last Post: October 11th, 2010, 10:11 AM
  3. JTable CheckBoxes
    By aussiemcgr in forum AWT / Java Swing
    Replies: 1
    Last Post: August 9th, 2010, 01:04 PM
  4. JTable Questions
    By aussiemcgr in forum AWT / Java Swing
    Replies: 21
    Last Post: August 9th, 2010, 02:34 AM
  5. Populating a JTable
    By crism85 in forum AWT / Java Swing
    Replies: 0
    Last Post: February 20th, 2010, 01:57 PM