禁止用户输入但允许在TextArea中突出显示

时间:2019-04-20 16:56:59

标签: java javafx textarea

我有一个文本区域,可在GUI中复制控制台输出。希望用户选择突出显示并复制输出,但不允许他们插入。有办法吗?

现在,我有一个简单的textArea编辑器,我已经尝试过import pandas as pd raw_data = { 'dogs': [42, 39, 86, 15, 23, 57, 68, 81, 86], 'cats': [52, 41, 79, 80, 34, 47, 19, 22, 59], 'sheep': [62, 37, 84, 51, 67, 32, 23, 89, 73], 'lizards': [72, 43, 36, 26, 53, 88, 88, 34, 69], 'birds': [82, 35, 77, 63, 18, 12, 45, 56, 58], } df = pd.DataFrame(raw_data, index=pd.Index(['row_1', 'row_2', 'row_3', 'row_4', 'row_5', 'row_6', 'row_7', 'row_8', 'row_9'], name='Rows'), columns=pd.Index(['dogs', 'cats', 'sheep', 'lizards', 'birds'], name='animals')) print(df) print() # Get a list of all columns names cols = df.columns print(cols) print('*****') for col in cols: print((df[df[col] == df[col].max()])) ''' animals dogs cats sheep lizards birds Rows row_3 86 79 84 36 77 row_9 86 59 73 69 58 animals dogs cats sheep lizards birds Rows row_4 15 80 51 26 63 animals dogs cats sheep lizards birds Rows row_8 81 22 89 34 56 animals dogs cats sheep lizards birds Rows row_6 57 47 32 88 12 row_7 68 19 23 88 45 animals dogs cats sheep lizards birds Rows row_1 42 52 62 72 82 ''' row_3 dogs 86 row_9 dogs 86 row_4 cats 80 row_8 sheep 89 row_6 lizards 88 row_7 lizards 88 row_1 birds 82 。虽然这会禁用用户输入,但也会完全禁止用户突出显示文本。

我将终端文字设置为:

terminalText.setDisable(true);

我发现这会禁用输入;但是我现在无法使用上面的setText()方法输入文本,并且无法突出显示:

public void printToConsole(String s){
    consoleBuilder.append(s);
    terminalText.setText(consoleBuilder.toString());
}

0 个答案:

没有答案