小编Sha*_* KK的帖子

如何在JTable中获得水平滚动

我有2个问题,我需要问,第一个如何获取我的JTable的水平滚动,目前它收缩所有根本不可读的列.我有20列显示在表中.

2,如何将我的桌子高度宽度调整到我的屏幕尺寸.

我目前的代码是

Container cp = getContentPane();

            ConnectionDB con = new ConnectionDB();
            tableModel = con.getRecord(DEFAULT_QUERY);

    table = new JTable(tableModel);
    table.setPreferredScrollableViewportSize(new Dimension(900, 500));

    table.setFont(new Font("Tahoma", Font.PLAIN, 12));
    scrollPane = new JScrollPane(table);

    centerPanel.add(scrollPane, BorderLayout.CENTER);
    centerPanel.setBorder(BorderFactory.createTitledBorder("Books:"));
    cp.add("Center", centerPanel);
Run Code Online (Sandbox Code Playgroud)

请帮助我,谢谢你提前.

java user-interface swing jtable jscrollpane

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

java ×1

jscrollpane ×1

jtable ×1

swing ×1

user-interface ×1