text selection conflict between JTextPane and JTextField

后端 未结 4 494
-上瘾入骨i
-上瘾入骨i 2021-01-27 03:43

Why the text in JTextPane cannot be selected programmatically if there is a JTextField present? Has something to do with focus i think. Thx.

import java.awt.Flow         


        
4条回答
  •  别那么骄傲
    2021-01-27 04:19

    The text in the JTextPane is selected. The trouble is that it does not give any visual indication unless the component is focused. Try tabbing to the component once the GUI is shown.


    so, i should release note this?

    No, you should redesign your broken GUI that uses text selection to identify text of interest. Text selection is more something for the end user to do, not the application.

    Given JTextPane is a component that supports formatting, possibly make the text bold or italic for instance.

提交回复
热议问题