【问题标题】:change the textArea font with selecting items from comboBox通过从组合框中选择项目来更改 textArea 字体
【发布时间】:2018-12-11 10:10:52
【问题描述】:

亲爱的 Java 开发人员,我遇到了一些问题,希望得到您的帮助,如果可以的话,请帮助我,我添加了一个 textArea 和一个组合框,每当我从组合框选择字体大小时,我想更改 textArea 的字体大小textArea 应该会自动更改enter image description here

【问题讨论】:

  • 请发布您的代码而不是图片!

标签: java user-interface graphics combobox textarea


【解决方案1】:

您需要首先向您的组合框添加一个侦听器。之后,只需使用所选值更改字体大小即可。

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));
        }
    });

【讨论】:

  • 现在我在您的图片上看到您使用的不是 SWT。无论如何,代码应该非常相似。正如其他人提到的,您应该放置代码而不是图片,并明智地选择标签
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-11-06
  • 1970-01-01
  • 1970-01-01
  • 2012-04-28
  • 2019-07-05
  • 2013-12-04
  • 2015-01-03
相关资源
最近更新 更多