문제

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 someone 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: Editable Screen

And here when clicking on it: Editable Screen2

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top