-1

I have one Desktop application and I am trying to Run it with Windows Desktop and while its running correct into Ubuntu.

but while running on windows $nbsp is Replaced with some wired Char. "Â" dont know how to make it fix?

any body can give suggestion?enter image description here

for (int i = 0; i < table.length(); i++) {

                JSONObject data = table.getJSONObject(i);
                 GetStringfromjson.addItem(data.getString("SubActivityName"));
                 getbytesfromjson.addItem(data.getString("SubActivityName").getBytes());
                 gettochararray.addItem(data.getString("SubActivityName").toCharArray());
                 getstringonly.addItem((data.get("SubActivityName").toString().replaceAll("&Acirc;", " ")));
                 //System.out.println(data.get("SubActivityName").toString().trim());
                // System.out.println("*********"+System.getProperty("os.name"));
                 if (System.getProperty("os.name").indexOf("Linux")>=0) {

                    System.out.println(data.get("SubActivityName").toString());
                }
                 if (System.getProperty("os.name").indexOf("win")>=0) {

                    System.out.println(data.get("SubActivityName").toString());
                }
            }
Kishan Bheemajiyani
  • 3,429
  • 5
  • 34
  • 68

1 Answers1

2

Using spaces for formatting in this way is problematic due to platform variations in font metrics and character encoding. Instead, use a custom ListCellRenderer, where you have more control over rendering. A related approach is examined here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • then how can i make it fix and mind well m not using any ListCellRenderer for the same. – Kishan Bheemajiyani Jun 07 '14 at 07:27
  • I'd recommend changing to a custom `ListCellRenderer` to get the indentation effect shown in your illustration. – trashgod Jun 07 '14 at 07:31
  • i have not used ListCellRenderer i told u once. and if u still say that then show me demo code i try according to that. – Kishan Bheemajiyani Jun 07 '14 at 07:33
  • I cited two examples above. Please edit your question to include an [mcve](http://stackoverflow.com/help/mcve) that shows your revised approach. See also [*How do I create screenshots?*](http://meta.stackoverflow.com/questions/99734/how-do-i-create-a-screenshot-to-illustrate-a-post). – trashgod Jun 07 '14 at 07:34
  • how can i make it better? i have uploaded Code which adding items into the Combobox and even screenshots what i am getting output. what more should i post in that? – Kishan Bheemajiyani Jun 07 '14 at 07:37