本文整理汇总了Java中javax.swing.JTable.setFillsViewportHeight方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.setFillsViewportHeight方法的具体用法?Java JTable.setFillsViewportHeight怎么用?Java JTable.setFillsViewportHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.setFillsViewportHeight方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TablePrintDemo
import javax.swing.JTable; //导入方法依赖的package包/类
public TablePrintDemo() {
super();
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
table = new JTable(new MyTableModel());
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
table.setFillsViewportHeight(true);
// Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
// Add the scroll pane to this panel.
add(scrollPane);
// Add a print button.
JButton printButton = new JButton("Print");
printButton.setAlignmentX(Component.CENTER_ALIGNMENT);
printButton.addActionListener(this);
add(printButton);
}
示例2: TableFTFEditDemo
import javax.swing.JTable; //导入方法依赖的package包/类
public TableFTFEditDemo() {
super(new GridLayout(1, 0));
JTable table = new JTable(new MyTableModel());
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
table.setFillsViewportHeight(true);
// Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
// Set up stricter input validation for the integer column.
table.setDefaultEditor(Integer.class, new IntegerEditor(0, 100));
// If we didn't want this editor to be used for other
// Integer columns, we'd do this:
// table.getColumnModel().getColumn(3).setCellEditor(
// new IntegerEditor(0, 100));
// Add the scroll pane to this panel.
add(scrollPane);
}
示例3: TableDialogEditDemo
import javax.swing.JTable; //导入方法依赖的package包/类
public TableDialogEditDemo() {
super(new GridLayout(1, 0));
JTable table = new JTable(new MyTableModel());
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
table.setFillsViewportHeight(true);
// Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
// Set up renderer and editor for the Favorite Color column.
table.setDefaultRenderer(Color.class, new ColorRenderer(true));
table.setDefaultEditor(Color.class, new ColorEditor());
// Add the scroll pane to this panel.
add(scrollPane);
}
示例4: TableRenderDemo
import javax.swing.JTable; //导入方法依赖的package包/类
public TableRenderDemo() {
super(new GridLayout(1, 0));
JTable table = new JTable(new MyTableModel());
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
table.setFillsViewportHeight(true);
// Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
// Set up column sizes.
initColumnSizes(table);
// Fiddle with the Sport column's cell editors/renderers.
setUpSportColumn(table, table.getColumnModel().getColumn(2));
// Add the scroll pane to this panel.
add(scrollPane);
}
示例5: init
import javax.swing.JTable; //导入方法依赖的package包/类
private void init() {
this.setLayout(new BorderLayout());
tableListTable = new JTable(this.tableModel);
tableListTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
tableListTable.setFillsViewportHeight(false);
tableListTable.setDragEnabled(false);
tableListTable.setColumnSelectionAllowed(false);
tableListTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
// //
// // Set the column widths
// //
// tableListTable.getColumnModel().getColumn(0).setPreferredWidth(40);
// tableListTable.getColumnModel().getColumn(1).setPreferredWidth(20);
// tableListTable.getColumnModel().getColumn(3).setPreferredWidth(40);
JScrollPane scrollPane = new JScrollPane(tableListTable);
//scrollPane.setPreferredSize(new Dimension(DesignerVisualization.WINDOW_WIDTH, 175));
//scrollPane.setMaximumSize(this.columnSetTable.getPreferredScrollableViewportSize());
this.add(scrollPane, BorderLayout.CENTER);
}
示例6: SimpleTableDemo
import javax.swing.JTable; //导入方法依赖的package包/类
public SimpleTableDemo() {
super(new GridLayout(1, 0));
String[] columnNames = { "First Name", "Last Name", "Sport", "# of Years", "Vegetarian" };
Object[][] data = { { "Kathy", "Smith", "Snowboarding", new Integer(5), new Boolean(false) },
{ "John", "Doe", "Rowing", new Integer(3), new Boolean(true) },
{ "Sue", "Black", "Knitting", new Integer(2), new Boolean(false) },
{ "Jane", "White", "Speed reading", new Integer(20), new Boolean(true) },
{ "Joe", "Brown", "Pool", new Integer(10), new Boolean(false) } };
final JTable table = new JTable(data, columnNames);
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
table.setFillsViewportHeight(true);
if (DEBUG) {
table.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
printDebugData(table);
}
});
}
// Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
// Add the scroll pane to this panel.
add(scrollPane);
}
示例7: TableDemo
import javax.swing.JTable; //导入方法依赖的package包/类
public TableDemo() {
super(new GridLayout(1, 0));
JTable table = new JTable(new MyTableModel());
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
table.setFillsViewportHeight(true);
// Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
// Add the scroll pane to this panel.
add(scrollPane);
}
示例8: TableSortDemo
import javax.swing.JTable; //导入方法依赖的package包/类
public TableSortDemo() {
super(new GridLayout(1, 0));
JTable table = new JTable(new MyTableModel());
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
table.setFillsViewportHeight(true);
table.setAutoCreateRowSorter(true);
// Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
// Add the scroll pane to this panel.
add(scrollPane);
}
示例9: GraphicTable
import javax.swing.JTable; //导入方法依赖的package包/类
public GraphicTable() {
graphicTable = new JTable();
graphicTable.setEnabled(false);
graphicTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
graphicTable.setMinimumSize(graphicTable.getPreferredScrollableViewportSize());
graphicTable.setPreferredScrollableViewportSize(graphicTable.getPreferredSize());
graphicTable.setFillsViewportHeight(true);
graphicTable.getTableHeader().setReorderingAllowed(false);
graphicTable.setColumnSelectionAllowed(true);
graphicTable.setRowSelectionAllowed(true);
graphicTable.setRowSelectionAllowed(true);
//(ListSelectionModel.SINGLE_SELECTION);
}
示例10: createContent
import javax.swing.JTable; //导入方法依赖的package包/类
@Override
protected JPanel createContent() {
JPanel content = new JPanel();
GroupLayout layout = new GroupLayout(content);
content.setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
// parameters panel
hhTable = new JTable();
hhTable.setAutoscrolls(true);
JScrollPane resScrollPane = new JScrollPane(hhTable);
resScrollPane
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
resScrollPane
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
hhTable.setFillsViewportHeight(true);
hhTable.setPreferredScrollableViewportSize(new Dimension(400, 100));
hhTableModel = new MyTableModel();
hhTable.setModel(hhTableModel);
hhTable.setDefaultRenderer(Class.class, new MyClassTableCellRenderer());
hhTable.setDefaultEditor(Double.class, new MyDoubleTableCellEditor());
hhTableModel.addColumn("Select");
hhTableModel.addColumn("Hidden Hop Mapping");
hhTableModel.addColumn("Factor");
JPanel hhPanel = new JPanel();
hhPanel.setBorder(BorderFactory.createTitledBorder("Hidden Hops"));
hhPanel.add(resScrollPane);
// create the content for the hh panel
for (Class<?> hh : getAllHhs()) {
try {
hh.getDeclaredField(new String("factor"));
// add a row to the factor table.
hhTableModel
.addRow(new Object[] { false, hh, new Double(0.0) });
} catch (NoSuchFieldException ex) {
}
}
// add the panels
layout.setHorizontalGroup(layout.createParallelGroup().addComponent(
hhPanel));
layout.setVerticalGroup(layout.createSequentialGroup().addComponent(
hhPanel));
return content;
}
示例11: createTable
import javax.swing.JTable; //导入方法依赖的package包/类
private static JTable createTable() {
DefaultTableModel model = new DefaultTableModel();
JTable table = new JTable(model);
table.setFillsViewportHeight(true);
return table;
}
示例12: createCredentialPanel
import javax.swing.JTable; //导入方法依赖的package包/类
JPanel createCredentialPanel() {
JPanel box = new JPanel(new BorderLayout(5, 5));
box.setOpaque(false);
box.setBorder(new EmptyBorder(10, 0, 0, 10));
model = new CredentialTableModel();
Authenticator.getInstance().addObserver(model);
table = new JTable(model);
if (System.getProperty("xdm.defaulttheme") != null) {
table.getTableHeader().setDefaultRenderer(
new XDMTableHeaderRenderer());
}
table.setFillsViewportHeight(true);
JScrollPane jsp = new JScrollPane(table);
// jsp.setOpaque(false);
// jsp.getViewport().setOpaque(false);
jsp.setPreferredSize(new Dimension(10, 10));
// box.add(table);
box.add(jsp);
Box b = Box.createHorizontalBox();
b.add(Box.createHorizontalGlue());
addAuth = new JButton(getString("LBL_ADD_AUTH"));
addAuth.setName("LBL_ADD_AUTH");
addAuth.addActionListener(this);
removeAuth = new JButton(getString("LBL_DEL_AUTH"));
removeAuth.setName("LBL_DEL_AUTH");
removeAuth.addActionListener(this);
editAuth = new JButton(getString("LBL_EDT_AUTH"));
editAuth.setName("LBL_EDT_AUTH");
editAuth.addActionListener(this);
addAuth.setPreferredSize(removeAuth.getPreferredSize());
editAuth.setPreferredSize(removeAuth.getPreferredSize());
b.add(addAuth);
b.add(Box.createHorizontalStrut(10));
b.add(removeAuth);
b.add(Box.createHorizontalStrut(10));
b.add(editAuth);
box.add(b, BorderLayout.SOUTH);
return box;
}