Question

I have a really weird problem with a JScrollPane and a BorderLayout. For short explaination: i have a JTable which is inside the JScrollPane and this is with a JPanel and the JTableHeader on a JTabbedPane. Very Simple Layout. If i add just the JTable to my JPanel, the buttons are working. If i add the JScrollPane, the Buttons are not working anymore, so i cant click them! The ActionLister is never reached and i cant see the click-animation.

Some Sample code to explain:

d_pane = new JPanel();
d_button = new JPanel();
d_pane.add(table.getTableHeader(), BorderLayout.PAGE_START);
dl_scroll = new JScrollPane(table);
d_pane.add(dl_scroll, BorderLayout.CENTER);
// d_button is ridLayouted with 3 Buttons in there
d_pane.add(d_button, BorderLayout.PAGE_END);
Was it helpful?

Solution

1) The JScrollPane takes care of the table header itself. Don't add it to the pane.

2) the button does not seem to get the mouse events, probably because another component is above it - do you have other components/code in the setup?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top