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

TableSorter class

 
zohreh talebi
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to sort a table and use TableSorter class.
This part of code that i use TableSorter class.the problem is , my class don't know object of this class . How can i import this class?

public TableSorterDemo() {
super(new GridLayout(1,0));

TableSorter sorter = new TableSorter(new MyTableModel()); //ADDED THIS
//JTable table = new JTable(new MyTableModel()); //OLD
JTable table = new JTable(sorter); //NEW
sorter.setTableHeader(table.getTableHeader()); //ADDED THIS
table.setPreferredScrollableViewportSize(new Dimension(500, 70));

//Set up tool tips for column headers.
table.getTableHeader().setToolTipText(
"Click to specify sorting; Control-Click to specify secondary sorting");

//Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);

//Add the scroll pane to this panel.
add(scrollPane);
}


thanks very much
Zohreh
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



have you compiled your TableSorter.java file or not ?

If Yes so where you replace you tableSorter.class file (I mean in which folder). Is it in the same folder where you compiling your TableSorterDemo.java file ?
[ October 11, 2006: Message edited by: Saif Uddin ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic