Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
555 views
in Technique[技术] by (71.8m points)

java - How to stop editing with DefaultCellEditor when a separate JBtton is pressed

I got a table with a custom TableCellEditor (extending DefaultCellEditor) with a JFormattedTextField as the editor component.

Now I got problem: when I press a separate button while editing. When the button is pressed, the editor remains "open and active" while I'd want it to stop editing so that the changes made would be available for the operations caused by the button.

So how to cause the editing to be stopped when a distinct button is pressed. I tried setFocusLostBehavior(JFormattedTextField.COMMIT) for the JFormattedTextField but it didn't seem to have effect.

Hope somebody has some good ideas =)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You may try

jtable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...