Q: |
How do I sort my ArrayList by column? |
A: |
I recommend that you use the Collections.sort(List, Comparator) function. Since an ArrayList implements the List interface, you can pass it right into this function. Write the appropriate Comparator function so that you only sort by the appropriate column, and you're all set. |
Q: |
Does the application need to automatically resort if the user adds a new row? |
A: |
No, you could imagine that this would be annoying if the user wanted to make lots of changes to a row, and it kept moving on them.... |
Q: |
How do you make that gap inbetween the Delete Row button and the Load File button? |
A: |
Look at the method Box.createRigidArea(Dimension). This makes a "space" object which you can add to a panel to make a gap. |
Q: |
How do I get the my FilteredTable to change per keystroke in the JTextField? I can only get it to change when the user hits enter. |
A: |
You're probably using an ActionListener, that only responds to the enter key. To have the table change in "real-time," you need a DocumentListener. Look at the JTextField.getDocument function and go from there. |
Q: |
Although I call my JFrame constructor properly, I don't get a window title in unix. What gives? |
A: |
This seems to be a problem with the default Window Manager in Sweet Hall. Notice that if you switch to fvwm95 you don't get this problem. If you have no idea what I'm talking about, don't worry, count this as a Swing bug and not your own. |
Q: |
If I'm in the middle of editing a cell, and then I hit the sort button, bad things happen. I understand that this is considered a Swing bug, but I'd really like to have this work! |
A: |
Well now you can! The following lines will do the trick: if(mTable.isEditing()) { mTable.getCellEditor().stopCellEditing(); } } Essentially this is forcing the table to hit "Enter" if you're in the middle of editing a cell. |
Q: |
I got points taken off for "Unable to sort sparse data." What does this mean? |
A: |
Look in the criteria directory (accessible from the home page). There is a file called "hardertest.txt" which was our "sparse" data set. If your HW1 can't sort this data set, then that's a problem. |