java - 在 JTextArea 中添加动态文本值
问题描述
我正在尝试添加动态文本值,它是 JTextArea 中的一个字符串,但是通过 methodname.add 或 methodname.addElement 的一些方法给了我一个错误。这是我正在尝试的代码部分。
代码:
ipList = new JTextArea();
ipList.setForeground(new Color(0, 0, 128));
ipList.setFont(new Font("Calibri", Font.BOLD, 18));
ipList.setBackground(new Color(245, 245, 245));
scrollPane.setViewportView(ipList);
byte[] ip = localhost.getAddress();
for (int i = 1; i <= 254; i++)
{
ip[3] = (byte)i;
InetAddress address = InetAddress.getByAddress(ip);
String hostName = address.getHostName();
if (address.isReachable(1000))
{
ipList.addElement(address.toString().split("/")[1]+ " "+"Device Name: "+hostName);
ipList.addElement(address.hostName());
// System.out.println(address.toString().split("/")[1]+ " "+"Device Name: "+hostName);
// System.out.println(address.getHostName());
}
}
解决方案
推荐阅读
- r - 使用来自另一列的替换值进行逐行模式替换
- r - 如何从 st_sample (R package sf) 中获取六角型样本?
- r - 如何在 R(igraph) 中检查我的网络是否是无标度的
- javascript - React UseEffects 显示警告“方法表达式不是函数类型”
- c - 在 C 中使用 fscanf 获取输入
- database - 在 Laravel 中使用随机条目更新数据库
- javascript - 将 cordova-plugin-firebase-authentication 身份验证转换为 Firebase JS-SDK 身份验证
- c - 如何将库路径添加到makefile?
- marklogic - 禁用计划任务的 MarkLogic 功能
- typescript - 跨多个文件合并打字稿“模块”