K
Kevin Munro
Hello, I'm writing an app for a pda and I want a horizontal scrollbar on my
JTable.
I can get a vertical scrollbar by default in the following code but can't
see how to get a horizontal one.
Alternatively I was thinking of setting the RowHeight higher for those lines
that need it but can't see how to get the text to wrap.
Any ideas?
Any help much appreciated.
Kevin
import java.awt.*;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
public class testTable extends JFrame {
String[] colNames = {"Work Order", "Customer"};
Object[][] data = {
{"290001", "Bean Pole Services Ltd"},
{"290002", "Ben Brown and his Band of Brothers"},
{"290003", "North Pole Inc"},
{"290004", "Ally's Tilers"},
{"290005", "Cakes are them"}
};
JTable table = new JTable(new DefaultTableModel(data, colNames));
public testTable() {
Container c = getContentPane();
c.add(new JScrollPane(table));
this.setSize(200,100);
this.setVisible(true);
// how to get a horizontal scrollbar?
// or, alternatively to wrap text?
table.setRowHeight(1,32);
}
public static void main(String[] args) {
testTable testTable1 = new testTable();
}
JTable.
I can get a vertical scrollbar by default in the following code but can't
see how to get a horizontal one.
Alternatively I was thinking of setting the RowHeight higher for those lines
that need it but can't see how to get the text to wrap.
Any ideas?
Any help much appreciated.
Kevin
import java.awt.*;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
public class testTable extends JFrame {
String[] colNames = {"Work Order", "Customer"};
Object[][] data = {
{"290001", "Bean Pole Services Ltd"},
{"290002", "Ben Brown and his Band of Brothers"},
{"290003", "North Pole Inc"},
{"290004", "Ally's Tilers"},
{"290005", "Cakes are them"}
};
JTable table = new JTable(new DefaultTableModel(data, colNames));
public testTable() {
Container c = getContentPane();
c.add(new JScrollPane(table));
this.setSize(200,100);
this.setVisible(true);
// how to get a horizontal scrollbar?
// or, alternatively to wrap text?
table.setRowHeight(1,32);
}
public static void main(String[] args) {
testTable testTable1 = new testTable();
}