K
Kurt Underhay
I've got an app with a GUI that includes a JTable. I'd like for the
table to be scrollable, so I've created a JScrollPane on it. However,
the horizontal scrollbar doesn't have a scroll knob on it, and using the
left/right scroll buttons doesn't cause it to scroll. How can I get the
horizontal scrolling working?
Relevant code fragment below.
-----------------------------------------------
JFrame frame = new JFrame(title);
JDesktopPane JDPane = new JDesktopPane();
frame.getContentPane().add(JDPane);
JInternalFrame JIFrame1 = new JInternalFrame(title + " JIFrame1");
JDPane.add(JIFrame1);
JTable table = new JTable(100,100);
JIFrame1.getContentPane().add(table);
table.setVisible(true);
JScrollPane JSPane = new JScrollPane(table);
JSPane.setPreferredSize(new Dimension(100,100));
JSPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
JSPane.getHorizontalScrollBar().setEnabled(true);
JIFrame1.getContentPane().add(JSPane);
JIFrame1.setClosable(true);
JIFrame1.setResizable(true);
JIFrame1.setSize(200,200);
JIFrame1.setVisible(true);
frame.setSize(800,700);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
table to be scrollable, so I've created a JScrollPane on it. However,
the horizontal scrollbar doesn't have a scroll knob on it, and using the
left/right scroll buttons doesn't cause it to scroll. How can I get the
horizontal scrolling working?
Relevant code fragment below.
-----------------------------------------------
JFrame frame = new JFrame(title);
JDesktopPane JDPane = new JDesktopPane();
frame.getContentPane().add(JDPane);
JInternalFrame JIFrame1 = new JInternalFrame(title + " JIFrame1");
JDPane.add(JIFrame1);
JTable table = new JTable(100,100);
JIFrame1.getContentPane().add(table);
table.setVisible(true);
JScrollPane JSPane = new JScrollPane(table);
JSPane.setPreferredSize(new Dimension(100,100));
JSPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
JSPane.getHorizontalScrollBar().setEnabled(true);
JIFrame1.getContentPane().add(JSPane);
JIFrame1.setClosable(true);
JIFrame1.setResizable(true);
JIFrame1.setSize(200,200);
JIFrame1.setVisible(true);
frame.setSize(800,700);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);