"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Alberto Aparicio wrote:I have another question??
How can i make sure the "previous" text in the JTextArea is not erased everytime i push the >Send> button.
Maneesh Godbole wrote:I would recommend using JTextArea#append(String text) instead of concatenating and then setting the text.
luck, db
There are no new questions, but there may be new answers.
Maneesh Godbole wrote:I would recommend using JTextArea#append(String text) instead of concatenating and then setting the text.
Alberto Aparicio wrote:I'v tried to use JTextArea#append(String text) in my Java code. But where exactly should i put JTextArea#append(String text)? Can you give me an example, i only get a lot of ERRORS.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Alberto Aparicio wrote:Thanks for all the help! i have learnt a lot. I have made the changes like Pete said.
but you must understand that i'm really not good at Java, but i have to do this project for my school.
So if you use a lot of theorie of Java, it's really dificult to understand for me. So i hope you have a little pattience with me.
you'll still need to address:
if there are any conditions prior to printing the row's data e'g' if no date, ignore row
cell still in edit mode when 'send' pressed will print cell's pre-edit value
public void tableChanged(TableModelEvent e) {
}
TableModelEvent(source); // The data, ie. all rows changed
TableModelEvent(source, HEADER_ROW); // Structure change, reallocate TableColumns
TableModelEvent(source, 1); // Row 1 changed
TableModelEvent(source, 3, 6); // Rows 3 to 6 inclusive changed
TableModelEvent(source, 2, 2, 6); // Cell at (2, 6) changed
TableModelEvent(source, 3, 6, ALL_COLUMNS, INSERT); // Rows (3, 6) were inserted
TableModelEvent(source, 3, 6, ALL_COLUMNS, DELETE); // Rows (3, 6) were deleted
How can i make sure that only the data that is edited in a ROW, is printed (in the JTextArea).
I want the hole row to be printed. For example "Valk 10-10-2010 Gelderland 3 23".
The rows that are not edited must not be printed.
Alberto Aparicio wrote:I have lookt at TableModelListener and found a method called tablechanged!
How can i make sure that only the data that is edited in a ROW, is printed (in the JTextArea).
I want the hole row to be printed. For example "Valk 10-10-2010 Gelderland 3 23".
The rows that are not edited must not be printed.
I'm also a little confused as in your previous examples, the event that triggered updating the JTextArea's text was a JButton press, not a change the JTable's model. Which one will it be? Or in other words, can you explain your event model more clearly?
this is indeed correct! I only want the data in the row that has been changed, to be "send" to the TextArea.On looking at your images, it still looks to me as if you want to use the selected row when the SEND JButton has been pressed. If this is indeed correct,
don't use a TableModelListener but rather simply use the JButton's ActionListener and in the actionPerformed method, use the JTable's model to get the selected row and then to get the row data.
Consider Paul's rocket mass heater. |