0

when i enable or request focus in text area the focus or caret anything u name it, it located at left. but when i start typing, it change to right. please help me to make it on right when request focus(true); this is the properties of textarea:

textManualIn = new JTextArea();
textManualIn.setLocale(new Locale("ar", "AE"));
textManualIn.setMinimumSize(new Dimension(5, 22));
textManualIn.setPreferredSize(new Dimension(5, 22));
textManualIn.setFocusCycleRoot(true);
textManualIn.setFocusTraversalPolicyProvider(true);
textManualIn.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
textManualIn.setRequestFocusEnabled(true);
textManualIn.setFont(new Font("Calibri", Font.PLAIN, 14));
textManualIn.setSelectionColor(new Color(153, 255, 255));
textManualIn.setMargin(new Insets(2, 5, 2, 5));
textManualIn.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
textManualIn.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
textManualIn.setCaretColor(Color.BLACK);
textManualIn.setBackground(new Color(255, 255, 255));
mainmanual.add(status);//add to Jpanel
tryingToLearn
  • 10,691
  • 12
  • 80
  • 114
  • Possible duplicate of https://stackoverflow.com/questions/6475320/how-to-set-the-orientation-of-jtextarea-from-right-to-left-inside-joptionpane – Miller Cy Chan Nov 01 '18 at 08:05
  • 1
    https://stackoverflow.com/questions/6475320/how-to-set-the-orientation-of-jtextarea-from-right-to-left-inside-joptionpanethat only set the comp. orientation, but focus of caret still in left. – Dzulfikar Fatahillah Nov 01 '18 at 08:24

1 Answers1

0

This is not perfect, but you can try this code:

textManualIn.setText(" "); // one space
// And use one of the following
textManualIn.setCaretPosition(0);
// -or-
textManualIn.select(0, 1);
prasad_
  • 12,755
  • 2
  • 24
  • 36