Adding a Table to a Container
Here is typical code for creating a scroll pane that serves as a container for a table:JScrollPane scrollPane = new JScrollPane(table); table.setFillsViewportHeight(true);
// ScrollPane에 테이블을 넣는 방법
- The
JScrollPane
constructor is invoked with an argument that refers to the table object. This creates a scroll pane as a container for the table; the table is automatically added to the container. JTable.setFillsViewportHeight
is invoked to set thefillsViewportHeight
property. When this property istrue
the table uses the entire height of the container, even if the table doesn't have enough rows to use the whole vertical space. This makes it easier to use the table as a drag-and-drop target.
If you are using a table without a scroll pane, then you must get the table header component and place it yourself. For example:
container.setLayout(new BorderLayout()); container.add(table.getTableHeader(), BorderLayout.PAGE_START); container.add(table, BorderLayout.CENTER);
//Container에 직접 table을 삽입하는 방법
출처: http://download.oracle.com/javase/tutorial/uiswing/components/table.html#data
댓글 없음:
댓글 쓰기