Arnes wrote:...although I always have to enter the location where the file will be stored which isn't very user-friendly...
Maneesh Godbole wrote:What all information do you wish to display to the user? What options does he have? Can the user download multiple files at the same time? That would decide what component to use.
e.g.
1) File name, type, date, download button
2) JList with file names and a common download button
Arnes wrote:...although I always have to enter the location where the file will be stored which isn't very user-friendly...
You can ask the user the first time. On the UI provide a checkbox which says something like "Download all files to this location {download_location}". Check if this box is checked, else ask the user.
PS. In case your user needs to manually type the download location, check out JFileChooser#showSaveDialog()
Do I take id along with his name and other info from database (except binary data) and put name and other needed info for the user to see in a JList..
Maneesh Godbole wrote:I am with Paul here. Constructing an object with the data encapsulated inside is the proper way to go.
Do I take id along with his name and other info from database (except binary data) and put name and other needed info for the user to see in a JList..
If I understand this correctly, you wish to display multiple attributes for a single file. For this I would suggest a JTable instead of a JList.
In pseudo code:
Retrieve the data from the DB.
Wrap the data in an object
Wrap all objects inside a collection like say ArrayList
Create a table model (say DefaultTableModel) from this ArrayList
Associate a JTable with this model.
Once you have the table mode, you can easily control the data which is displayed. Check out the model methods like getRowCount(),getColumnCount(),getValueAt()
Paul Clapham wrote:In Java it would be as easy as creating a class whose objects contained whatever information about the file you needed, and whose toString() method returned whatever you wanted to appear in the JList.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
I fear being seen as a spammer.
Maneesh Godbole wrote:Check the model for methods which will let you remove data.
Maneesh Godbole wrote:
I would approach it this way:
Load data from DB, wrap in Model, display.
When user wants to delete, ask server to delete it from DB, Once the server confirms the delete did happen, delete from your model. This way, you would need to load the data from the server only once.
Consider Paul's rocket mass heater. |