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?
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.
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!
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.
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?
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.
CLUCK LIKE A CHICKEN! Now look at this tiny ad:
Gift giving made easy with the permaculture playing cards