Inline edit component in Swing
I'm wondering an inline edit Textfield for Swing does exist. I googled around a bit and checked all swing libraries which I know, but i did not find such a component. Has anyone implemented such a edit-in-place swing component or does someo开发者_StackOverflow中文版ne know such a project?
I know this SO Thread. but I do not want the "spreadsheet feeling".
--- Edit
Because I was not clear what I mean with edit-in-place component:
Essentially the component should look like a Label, but when I click on the Label, it is replaced with a Textfield. Of course this would be trivial to implement with JLabel and JTextfield, but I want a more sophisticated solution. Here a screenshot from a Javascript when hovering the editable field:
And here when clicking on it:
Of course I do not want the picklist here, but this is just for visualization. I hope you get the idea :)
Use a JTextField.
- You can set the text field non-editable and the background to be non-opaque.
- Then you add a MouseLstener to the component. On a mouse click you set the text field editable and make it opaque.
- When the component loses focus you reset the properties again. So you would also need to add a FocusListener to the text field.
I believe JEditorPane
is what you're looking for.
精彩评论