Another way to do it would be to implement two TableModels. One to provide the normal list view, the other to display the details view. Or you may use the one details model, but hide the details columns by getting the TableColumnModel from the JTable and setting specific TableColumn objects to 0 maximum width. You will need to consult the Java Documentation for specific method calls as the table system is rather complicated.
Main Topics
Browse All Topics





by: mzimmer74Posted on 2000-12-10 at 20:25:00ID: 8415
Well, I don't know of any built in objects that you can use, but the way I would go about solving this would be to actually break it down into two panels. The first panel would be the detail view, and the second panel would be the list view. The panels would reside on the same part of the frame. I would use a CardLayout to do this. Then, using some action I would switch between the two. Here is sample CardLayout code:
e, "One"); o, "Two");
t e)
....
JPanel main = new JPanel(new CardLayout());
JPanel one = new JPanel();
//put the stuff onto panel one
JPanel two = new JPanel();
//put the stuff onto panel two
main.addLayoutComponent(on
main.addLayoutComponent(tw
...
public void actionPerformed(ActionEven
{
if (actionOne)
main.show(myFrame, "One");//myFrame is the parent frame
else if (actionTwo)
main.show(myFrame, "Two");
}
Basically what you then have to do is find some way of representing the two views, but at least you don't have to change an entire panel. Hope this helps a little.