Click to See Complete Forum and Search --> : A couple of things/problems
abcjavaguy
April 24th, 2003, 09:18 AM
Firstly i have a GUI with a few buttons on it and when for example the user presses the view button it should display a table on the GUI. So i'm passing the data back from another bean via a vector and then putting this into a jtable. But how!
Also on the same gui it is displaying the time, but i wish for this to update every second, any ideas?
Thanks
dlorde
April 24th, 2003, 05:48 PM
If you want to display the current time at regular intervals, use a thread that displays the time then sleeps for a defined interval.
For the GUI table question, you'll have to explain more precisely what you're trying to do. I really don't want to start guessing...
Four wheels bad, two wheels good...
abcjavaguy
April 24th, 2003, 06:13 PM
I have a GUI with 3 buttons and the date displayed. What i wish for it to do is when one button is clicked i wish for it to retrieve the table of data as a vector from another java file(a bean) and then for it to place this data into a jtable before displaying it on the GUI.
Also if i then click another button i want the gui to delete the data from the screen (just from the gui, not the actual file!). How would i do this, i.e. the opposite of add()?
Hope that makes sense, it only just does to me!
dlorde
April 24th, 2003, 08:26 PM
You need to add an ActionListener to the button, and in the actionPerformed(...) method you get your data vector from the JavaBean and add it to your table.
To do this, you can either create a new JTable, passing the data vector to its constructor, or better still, use a TableModel (subclass AbstractTableModel) and either add the data to the table model or create a new table model with the data, then set the table model into your JTable.
To clear the data from the display, just set an empty table model into the JTable (making sure you've kept a reference to the old table model or its data somewhere if you want to keep the old data).
A JTable simply displays the data that is stored in a TableModel...
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.