I use swingx and miglayout extensions and I having a problem. I have the following code:
public class App {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new MigLayout());
JXPanel keysPanel = new JXPanel();
JXPanel keysPanelContainer = new JXPanel();
JScrollPane scrollPane = new JScrollPane(keysPanelContainer,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
JButton nextButton = new JButton("Next");
keysPanel.setLayout(new MigLayout());
keysPanelContainer.setLayout(new MigLayout());
scrollPane.setBorder(BorderFactory.createEmptyBorder());
keysPanelContainer.setScrollableHeightHint(ScrollableSizeHint.PREFERRED_STRETCH);
keysPanelContainer.add(keysPanel, "w 100%, h 100%");
frame.add(scrollPane, "w 100%, h 100%");
frame.add(nextButton, "newLine, right");
frame.setSize(600, 320);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
}
}
And when I run this code, height if my keysPanel increases to infinity. What is wrong in my code ? I need keysPanel height 100%.