Re: Layout suggestions - table layout
Knute Johnson wrote:
sso wrote:
On Apr 29, 6:26 pm, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
wrote:
sso wrote:
Hi,
I need to layout data in a tabular fashion. In html a table layout
would work perfectly. In swing, it does not. Firstly I need
multiline cells - there doesn't seem to be a plain easy way to do this
in swing. Is there a work around? Other suggestions?
What's wrong with a JLabel? That will do multi-line text and even some
simple HTML if you want.
--
Knute Johnson
email s/nospam/knute2009/
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
The problem I have with using html is that I have no means of auto-
sizing the label (or table cell) I just tried this all out and its
not quite doing what I want. Am I missing something?
If you need to duplicate an HTML table with the auto sizing of the cells
then you are going to have write it your self or find a commercial one.
HTML tables are really complicated things.
What exactly are you trying to display?
The other option is to display the whole HTML table in a JLabel.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class test4 extends JPanel {
String HTMLTable = "<html><table width=500 border=1>" +
"<tr><td>Row 1 column 1" +
" <td>Row 1 column 2" +
"<tr><td>Row 2 column 1" +
" <td>Row 2 column 2" +
"<tr><td colspan=2>This is a lot of text that is displayed in " +
" two columns. ;laskj asl;dkj adj as asld a l;aksd aslk;dj" +
" ;las ewl;k2 23 qwer 23 qwef asdl;fkoio asdf;ajs ";
public test4() {
JLabel l = new JLabel(HTMLTable);
add(l);
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
test4 t4 = new test4();
f.add(t4,BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
});
}
}
--
Knute Johnson
email s/nospam/knute2009/
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access