0

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 :)

Community
  • 1
  • 1
Dominik Obermaier
  • 5,610
  • 4
  • 34
  • 45

2 Answers2

2

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.
camickr
  • 321,443
  • 19
  • 166
  • 288
0

I believe JEditorPane is what you're looking for.

Michael Borgwardt
  • 342,105
  • 78
  • 482
  • 720