我做了一个TextFlow,因为我需要使用多个字体姿势(我已将特定的"文本"设置为斜体或正常).一旦我显示TextFlow,它就不可选择/可复制.我需要的是TextFlow一旦在场景中显示就可以选择,因此它可以复制/粘贴.
带有font-posture的文本示例(仅举例一个例子):
Text volumeText = new Text(volume.getText());
volumeText.setFill(Color.WHITE);
volumeText.setFont(Font.font("arial", FontPosture.ITALIC, 13));
TextFlow reference = new TextFlow(
lastNameText, miscelanous1, firstNameText, miscelanous2);
reference.setLayoutX(115);
reference.setLayoutY(480);
reference.setMaxWidth(500);
control.getChildren().add(reference);
Run Code Online (Sandbox Code Playgroud) 我正在尝试比较2个单独字符串中的字符,这个想法是我将返回一个值,该值对应于两个字符串共享多少个字符。例如,如果字符串1是“ mouse”,而字符串2是“ house”。他们将共享4/5个字符。重要的是要注意,只有在相同的“索引位置”下,它们才会共享一个字符
def compareWords(word1, word2):
result = 0
if word1[0] in word2[0]:
result += 1
if word1[1] in word2[1]:
result += 1
if word1[2] in word2[2]:
result += 1
if word1[3] in word2[3]:
result += 1
if word1[4] in word2[4]:
result += 1
if word1[5] in word2[5]:
result += 1
print result, '/5'
Run Code Online (Sandbox Code Playgroud)