- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在构建一个 Twitter 客户端,但我不想检索和显示全局趋势。到目前为止(在某种程度上感谢 Stack Overflow 的帮助)我可以检索趋势信息,从中提取必要的信息并将趋势发布到控制台。当我尝试将趋势添加到表中时,我只能多次显示第一个趋势,并且我不确定行创建等出了什么问题。
一双新鲜的眼睛将不胜感激!
谢谢
public static void WorldWideTrends() {
Trends WorldWideTrendsList;
try {
WorldWideTrendsList = getTrends();
UI.whatIsDisplayedList.removeAll();
UI.tweetModel = new DefaultTableModel(10, 1);
String trendsInfo = WorldWideTrendsList.toString();
System.out.println(trendsInfo);
Pattern p = Pattern.compile("(#.*?)\\'", Pattern.DOTALL);
Matcher matcher = p.matcher(trendsInfo);
while (matcher.find()) {
for (int i = 0; i < 10; i++) {
String output = matcher.group(0);
System.out.println(output);
UI.tweetModel.insertRow(1, new Object[] {});
UI.tweetModel.setValueAt(
"<html><body style='width: 400px;'><strong>"
+ output + "</strong><html><br>", i, 0);
}
}
} catch (TwitterException e) {
e.printStackTrace();
}
UI.whatIsDisplayedList.setModel(UI.tweetModel);
}
最佳答案
我不确定这样做的目的是什么:
while (matcher.find()) {
for (int i = 0; i < 10; i++) {
String output = matcher.group(0);
...
}
}
但它会处理每场比赛 10 次。仅再次调用 .group()
不会带您进入下一场比赛,您需要再次调用 .find()
。
我认为你想简单地删除 for 循环(但如果存在超过 10 次匹配,这将匹配超过 10 次),或者删除 while 循环并执行类似的操作:
// process the first 10 matches
// no while-loop!
for (int i = 0; i < 10 && matcher.find(); i++) {
String output = matcher.group(0);
...
}
关于java - 使用 Regex 和 DefaultTableModel 将值插入到 JTable 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15560967/
我有一个 jTable,显示一个简单的两列 SQL 表的数据并允许用户维护该列表。这是我的第一个java程序。使其正常工作,以便用户可以编辑数据列表并按“保存”进行更新。我从这行代码获取 jTable
由于某种奇怪的原因,每次我在任何单元格中编辑数据并确认它时一旦我进入下一个,它就会从之前编辑的单元格复制数据 有什么想法吗? public class CheckoutTableModel exten
我有3个类(class) 首先从数据库获取数据 第二个为共同作品 其他用于展示表。 public class TableContent { private final Vector headers;
我的 DefaultTableModel 有问题,它不会向我显示表中的列,有一部分代码: JTable table = new JTable() { public boolean is
我有这个测试文件 text_file我的 TableView 是 enter image description here我想将每一行与每一列相匹配(第一行-第一列,第二行-第二列,等等。)错误在哪里
如何在 DefaultTableModel dtm = new DefaultTableModel(); 上添加标题和数据而不放置 new DefaultTableModel(在此内部)?我尝试使用
我的 Java GUI 中显示了一个表,用户可以通过单击“添加”按钮向其中添加行。添加到表格的行中的单元格默认都是可编辑的,用户可以根据需要选择每一行/单元格。 我现在想要添加从表中删除行的功能,但我
我有数据关系 Person-Attends-Course Person ------- id: integer primary key name: string prename: string age
我正在制作一个 GUI 简单的日历程序。我使用 DefaultTableModel 和 DefaultTableCellRenderer 显示日历的月 View 。我的日历设置为突出显示今天的日期。我
新数据输入数据库后,我的 JTable 没有刷新。我需要终止并再次执行才能看到结果。我包括了 DefaultTableModel 和 fireTableDataChanged。我还错过了什么?谢谢!
http://codepaste.net/ujhdq2 private Connection Econn; private DefaultTableModel examTable =
我使用 SwingWorker 根据数据库中的更改更改 DefaultTableModel。我的问题是:在 doInBackground() 中向 DefaultTableModel 添加 ListS
更新了问题,具体问题是数据没有显示,因为没有列: run: [java] Aug 04, 2014 8:17:00 PM net.bounceme.dur.client.gui.Applic
我一直在尝试将一些数据从 Editable JComboBox 发送到 JXTable。它的代码如下: private void selectTestActionPerformed(java.awt.
我有一个用 Object[][] 数组填充的 DefaultTableModel。 现在我想添加一个带有复选框的列并相应地执行操作。 当我将复选框添加到 Object[][] 数组并查看它时,我会显示
这个类与我的数据库通信检索数据并将它们投影到 JTable。我使用了 DefaultTableModel 但列名不会出现。我在另一个类中实例化这个类,我通过 检索包含数据的表获取表格()。 packa
我正在使用 Java Swingx 框架。我的 DefaultTableModel 对象中有 4 列。我只想显示其中 3 列。但是,我需要全部四个来进行计算。 实际数据模型 S.No. |身份证 |
我在 NetBeans 中使用 DefaultTableModel 来显示 MySQL 数据库中的记录。我的数据能够显示,但我想要的是在表格末尾显示一个复选框列。 我知道它需要被覆盖,但我不知道如何以
List myProducts = getMyProducts();//create an arraylist; Vector dataVector = new Vector(myProducts);
是的,我知道,这听起来很愚蠢。但在此之前,让我先说明一下我的问题。 我有一个带有大量 JTable 的 GUI。我有各种 DefaultTableModel,每个 JTable 一个。所以,1:1。对
我是一名优秀的程序员,十分优秀!