If I understood what are you trying, you are trying to put the values of both of your fields on the clipboard, and than read them and populate the fields again.
The clipboard is way too simple for that, it can only hold one String basically. What I propose is to create a structure you will put on the clipboard, and which structure is better for describing data as a String than JSON :-) . Just create JSON content like this:
[
{
"label":"field1",
"content":"contentFromField1"
},
{
"label":"field2",
"content":"contentFromField2"
}
]
And put it on the clipboard. Of course, you always have to check after reading the clipboard is the content actually deserializable.
For creating content like this you can use a Java library like json-simple . A simple example with the content like above:
JSONObject obj1 = new JSONObject();
obj1.put("label", "field1");
obj1.put("content", "contentFromField1);
JSONObject obj2 = new JSONObject();
obj2.put("label", "field2");
obj2.put("content", "contentFromField2);
JSONArray list = new JSONArray();
list.add(obj1);
list.add(obj2);