开发者

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:

Inline edit component in Swing

And here when clicking on it:

Inline edit component in Swing

Of course I do not want the picklist here, but this is just for visualization. I hope you get the idea :)


Use a JTextField.

  1. You can set the text field non-editable and the background to be non-opaque.
  2. Then you add a MouseLstener to the component. On a mouse click you set the text field editable and make it opaque.
  3. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜