nit*_*n22 9 swing jtable jlabel tablecellrenderer
每当JLabel在标记中包含文本时,它会自动应用换行(似乎).我的要求是对于标签应始终禁用换行,无论它包含什么文本.由于遗留原因,我无法在渲染器中使用JTextArea.
Mik*_*rin 15
<nobr></nobr>
在不想包装的HTML内容周围使用标记这是一个例子:
public static void main ( String[] args )
{
JFrame frame = new JFrame ();
frame.setLayout ( new BorderLayout () );
final String html = "<html><body><nobr>CMV Antigenemia Stat X 2.0 dose(s)</nobr></body></html>";
final String simple = "<html><body>CMV Antigenemia Stat X 2.0 dose(s)</body></html>";
JTable table1 = new JTable ( new String[][]{ { html, html, html, html, html } }, new String[]{ html, html, html, html, html } );
table1.setRowHeight ( 50 );
frame.add ( table1, BorderLayout.NORTH );
JTable table2 = new JTable ( new String[][]{ { simple, simple, simple, simple, simple } },
new String[]{ simple, simple, simple, simple, simple } );
table2.setRowHeight ( 50 );
frame.add ( table2, BorderLayout.CENTER );
frame.pack ();
frame.setLocationRelativeTo ( null );
frame.setVisible ( true );
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的 - 在第1个表格中,HTML内容未被包装.
归档时间: |
|
查看次数: |
1969 次 |
最近记录: |