Программисты JAVA общаются здесь
Anonymous
JTextArea не устанавливает текстовый индикатор справа перед началом печати
Сообщение
Anonymous » 29 янв 2025, 00:16
Единственная проблема, с которой я сталкиваюсь, заключается в том, что текстовый индикатор всегда отображается с левой стороны, пока я не начну набирать.
После набора:
Код: Выделить всё
JTextArea textArea = new JTextArea();
textArea.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
JScrollPane scroll = new JScrollPane(textArea);
scroll.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
< /code>
Вот полный код: < /p>
import java.awt.ComponentOrientation;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class Test extends JFrame {
public Test() {
this.setSize(300, 100);
JTextArea textArea = new JTextArea();
textArea.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
JScrollPane scroll = new JScrollPane(textArea);
scroll.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
this.add(scroll);
this.setVisible(true);
}
}
Я использую Java 11 в Windows 10, кстати.
Подробнее здесь:
https://stackoverflow.com/questions/691 ... art-typing
1738099008
Anonymous
Единственная проблема, с которой я сталкиваюсь, заключается в том, что текстовый индикатор всегда отображается с левой стороны, пока я не начну набирать. После набора: [code]JTextArea textArea = new JTextArea(); textArea.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); JScrollPane scroll = new JScrollPane(textArea); scroll.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); < /code> Вот полный код: < /p> import java.awt.ComponentOrientation; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; public class Test extends JFrame { public Test() { this.setSize(300, 100); JTextArea textArea = new JTextArea(); textArea.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); JScrollPane scroll = new JScrollPane(textArea); scroll.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); this.add(scroll); this.setVisible(true); } } [/code] Я использую Java 11 в Windows 10, кстати. Подробнее здесь: [url]https://stackoverflow.com/questions/69189871/jtextarea-doesnt-set-the-text-indicator-on-the-right-before-start-typing[/url]