通过从 comboBox 中选择项目来更改 textArea 字体
change the textArea font with selecting items from comboBox
亲爱的 Java 开发人员,我遇到了一些问题,我期待您的帮助,如果可以的话,请帮助我,我添加了一个 textArea 和一个 comboBox 我想在我选择时更改 textArea 的字体大小comboBox 的字体大小应自动更改 textAreaenter image description here
您需要先为组合框添加一个侦听器。之后只需使用选择的值更改字体大小。
SWT 示例:
yourCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String currentSelection = combo.getItem(combo.getSelectionIndex());
int fontSize = Integer.valueOf(currentSelection);
yourTextArea.setFont(SWTResourceManager.getFont("Segoe UI", fontSize, SWT.NORMAL));
}
});
亲爱的 Java 开发人员,我遇到了一些问题,我期待您的帮助,如果可以的话,请帮助我,我添加了一个 textArea 和一个 comboBox 我想在我选择时更改 textArea 的字体大小comboBox 的字体大小应自动更改 textAreaenter image description here
您需要先为组合框添加一个侦听器。之后只需使用选择的值更改字体大小。
SWT 示例:
yourCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String currentSelection = combo.getItem(combo.getSelectionIndex());
int fontSize = Integer.valueOf(currentSelection);
yourTextArea.setFont(SWTResourceManager.getFont("Segoe UI", fontSize, SWT.NORMAL));
}
});