Thread View: borland.public.jbuilder.java.swing
1 messages
1 total messages
Started by m3w316
Tue, 26 Jul 2005 20:04
JTable
Author: m3w316
Date: Tue, 26 Jul 2005 20:04
Date: Tue, 26 Jul 2005 20:04
53 lines
2701 bytes
2701 bytes
I have created a JTable. However if my table gets too big or if i
resize the application window, the horizontal scrollbar does not appear
at all. The vertical scrollbar works fine. I'm using eclipse. Heres a
copy of the code i'm working with:
import javax.swing.JTable;
import javax.swing.JScrollPane;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.ScrollPaneConstants;
import java.awt.*;
import java.awt.event.*;
public class SimpleTable extends JFrame {
public SimpleTable() {
super("Personnel");
Object[][] data = {
{"Thomas", "Albanese", "Engineer",
"Development", new Integer(10)},
{"Laura", "Bates", "Administrator",
"Benefits", new Integer(4)},
{"Susan", "Carson", "Director",
"Marketing", new Integer(12)},
{"William", "Delancy", "Instructor",
"Support", new Integer (6)}
};
String[] columnNames = {"First Name",
"Last Name",
"Job Title",
"Department",
"Service (yrs)"};
JTable perstab = new JTable(data, columnNames);
perstab.setPreferredScrollableViewportSize(
new Dimension(500, 65));
JScrollPane scrollPane = new JScrollPane(perstab,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
getContentPane().add(scrollPane,BorderLayout.CENTER);
}
public static void main(String[] args) {
SimpleTable frame = new SimpleTable();
frame.pack();
frame.setVisible(true);
}
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads