как установить фокусировку JtextArea в правильное положение? - PullRequest
0 голосов
/ 01 ноября 2018

когда я включаю или запрашиваю фокусировку в текстовой области, фокус или что-нибудь, что вы называете, он расположен слева. но когда я начинаю печатать, он меняется на право. пожалуйста, помогите мне сделать это правильно, когда запрос фокусируется (верно); это свойства текстовой области:

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

1 Ответ

0 голосов
/ 01 ноября 2018

Это не идеально, но вы можете попробовать этот код:

textManualIn.setText(" "); // one space
// And use one of the following
textManualIn.setCaretPosition(0);
// -or-
textManualIn.select(0, 1);
...