• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

nx:All of URLy Bird 1.1.3 about JTable

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi:George
I will create client GUI,hope you help me.I will create JTable with DefaultTableModel as its Model,and will add JTable to JScrollPane for displaying.Am i right?
My question is when i create the JTable,i find that the table only has
vertical scroll bar without horizontal scroll bar(although i create many columns).Whehter you can give me some suggestion about resizing the JViewport or associated API?perhaps you have better method?
 
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Liqun,

Originally posted by liqun chang:
[QB]Hi:George
I will create client GUI,hope you help me.I will create JTable with DefaultTableModel as its Model,and will add JTable to JScrollPane for displaying.Am i right?


Yes.


My question is when i create the JTable,i find that the table only has
vertical scroll bar without horizontal scroll bar(although i create many columns).Whehter you can give me some suggestion about resizing the JViewport or associated API?perhaps you have better method?


Take a look at this topic:
Topic: NX: How to add a horizontal scrallbar to a scrollPane?
By the way, most questions are variations of previously asked questions. You can find the answers to many questions using the search capability at the top of this screen. (There's something like 4 years of questions and answers on this forum.) For instance, to find the link listed above I just searched for "horizontal scroll" in the SCJD forum. The best thing about this is that you can find the answer immediately, no waiting.
 
liqun chang
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi George:thanks for your the most valuable suggestion.I will create class and test for a few weeks.If have any questions,I will ask you.
Thanks for your always help.
Gook luck.
I don't know how to say,give you the best beatitude to you and you family.
A chinese teacher!
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Liqun,
You're welcome. Thanks for the kind words. Good luck with your testing.
 
liqun chang
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi:why run this app throw NullPointerException:
Could any expert help me?
 
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi liqun,
Here is snippet for TableColumn from API specs.


getHeaderRenderer
public TableCellRenderer getHeaderRenderer()Returns the TableCellRenderer used to draw the header of the TableColumn. When the headerRenderer is null, the JTableHeader uses its defaultRenderer. The default value for a headerRenderer is null.
Returns:
the headerRenderer property


A snippet from your code where the problem coming is

As you can see, I commented out the code where you are using renderer and returning 1. It runs fine and gave an output table too, though its not the size probably we expected
The reason for getting NullPointerException is the default return value for the method getHeaderRenderer() is null. Try implementing it and it should work.
Good Luck.
 
liqun chang
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Satish:thanks for your response.as you can see,i use this codes for resize column for record and header information.
How could i implements this function?please give me a simple example?
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Liqun

Originally posted by liqun chang:
Hi Satish:thanks for your response.as you can see,i use this codes for resize column for record and header information.
How could i implements this function?please give me a simple example?


I am not doing any re-sizing of column or header in the code. When I populate the JTable they are looking good and so I don't want to put any extra effort on the GUI. There is one problem which I want to look over i.e. the JTable has equal sized columns and I am thinking of making the size of hotel name and location column big than room size and smoking flag columns. But as the table was looking good, I did not think on that again and left that. The GUI has many different features which are not required according to specs and so I simply neglected this issue. Sorry that I could not help here.
Good Luck.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic