【问题标题】:how to make an auto line break in jtable?如何在jtable中进行自动换行?
【发布时间】:2020-06-08 21:22:49
【问题描述】:

嗨,我正在使用 java jtable

 dff[i] = new DefaultTableModel(
                        new Object[][] {
                            {"ID",tab[i].get("id")},
                            {"Titre",tab[i].get("title")},
                            {"Auteur",tab[i].get("authors")},
                            {"Date",tab[i].get("date")},
                            {"Resume","Substitution ciphers are codes in which each letter of the alphabet has one fixed substitute, and the word divisions do not change.."},
                        },
                        new String[] {
                            "New column",""
                        }
                    );

             jj[i]= new JTable(dff[I]); 

但我得到了

如果可能的话,我想在抽象部分添加一个自动换行

【问题讨论】:

  • 我认为这不是正确的图像...
  • @Nosrep,你可能是对的,但它可能是一个带有自定义渲染器的两列表格。
  • @camickr 抱歉,看的不够仔细
  • 没有简单的方法来换行。您可以使用 JTextArea 作为渲染器,但这也会变得复杂,因为您需要开始使用行高。
  • 所以没有Jtextarea就没有办法在Jtable的一个单元格中做一个多行段落?? (对不起我的英语)

标签: java swing jtable line-breaks


【解决方案1】:

非常感谢 camickr ? 我添加了 <HTML> <p> 及其工作

tab[i].get("abstract")="Substitution ciphers are codes in which each letter of the alphabet has one fixed substitute, and the word divisions do not change.";

{"Resume","<html><p>"+tab[i].get("abstract")+"</p></html>"}

【讨论】:

  • 但这不会改变 JTable 中的行高。您还做了什么让您可以看到多行显示的文本?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-11-30
  • 1970-01-01
  • 2019-01-19
  • 2023-03-30
  • 1970-01-01
  • 2011-07-09
  • 2021-12-12
相关资源
最近更新 更多