Wrapped components not visible with FlowLayout
Hi all,
I have a JPanel using BorderLayout. On the SOUTH I add another JPanel
containing buttons and a text field using FlowLayout. When I shrink the
JFrame, the components in the latter JPanel wrap around as it should be,
but the components in the second row are not visible. I can only see a
very small part of their top.
What's wrong here?
Here's the code:
--8<---------------cut here---------------start------------->8---
public MapFrame(AnnotatedOsmGraph graph) {
super("jgStreetMap");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setLayout(new BorderLayout());
resultPanel = new ResultPanel();
mapPanel = new MapPanel(graph, resultPanel);
getContentPane().add(mapPanel, BorderLayout.CENTER);
getContentPane().add(resultPanel, BorderLayout.EAST);
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.Y_AXIS));
getContentPane().add(buttonPanel, BorderLayout.WEST);
JPanel detailPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
getContentPane().add(detailPanel, BorderLayout.SOUTH);
detailPanel.add(new JLabel("Visible details:"));
showMapButton = new JCheckBox("Map", mapPanel.isShowingMap());
detailPanel.add(showMapButton);
showMapButton.addChangeListener(new ChangeListener() {
[...]
});
showNatureButton = new JCheckBox("Streets only", mapPanel
.isShowingStreetsOnly());
detailPanel.add(showNatureButton);
showNatureButton.addChangeListener(new ChangeListener() {
[...]
});
searchTextField = new JTextField(20);
searchTextField.setToolTipText("Enter a name of a town and hit return.");
detailPanel.add(searchTextField);
searchTextField.addActionListener(new ActionListener() {
[...]
});
[...]
pack();
setVisible(true);
validate();
}
--8<---------------cut here---------------end--------------->8---
Is there something obvious?
Bye,
Tassilo