This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

empty JTable

 
Vijay
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JTable whose values gets filled only dynamically.
At times, when the table is empty, I want to show a message like
"no records found" just under the table header.
Just like how in windows machine, when you make a search and if it doesnt
return any records, it prints "Search is complete. There are no results to display"
(stretching many columns) under the table header. I considered using JLabel
(as shown below) but there is always some space b/w the two components.
Let me know ur suggestions. Until then, lemme try out other Layout managers.
Just a code snippet:


(N. Pruett - fixed page-widening code.)
[ March 08, 2004: Message edited by: Nathan Pruett ]
 
Nam Ha Minh
Ranch Hand
Posts: 502
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, I suggest you to use a TableModel (e.g. AbstractTableModel) to separate data from the GUI.
 
Rob Camick
Ranch Hand
Posts: 2612
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can temporarily add the label to the table:



Then when you start adding data to the table you would need to remove the label from the table.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic