Re: fighting the BorderLayout
Ian Wilson wrote:
IFAIK BorderLayout likes to give priority to the centre panel. You can
tweak the preferred sizes but I'd try a more appropriate layout manager:
setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS);
add(leftPanel);
add(midPanel);
add(rightPanel);
..
I might not have grasped your tip entirely, but I think the BoxLayout
as you recommend it to me, does not solve my problem. Here is a pice of
complete demo code to show you that the buttons are aligned to the left
anyone one after the other. I meant a component in the FAR left,
another in the middle and another one in the FAR right, not just one
componente next to the other in this order.
..
I think gridbag layouts would be ideal but I might have to do it this
way in a second iteration
..
// __ from:
http://java.sun.com/docs/books/tutorial/uiswing/layout/box.html
import java.awt.*;
import javax.swing.*;
public class BxLO00Test{
public static void addComponentsToPane(Container pane) {
pane.setLayout(new BoxLayout(pane, BoxLayout.X_AXIS));
JButton JBtn00, JBtn02, JBtn04;
// __
JBtn00 = new JButton("JBtn00");
JBtn00.setAlignmentX(Component.LEFT_ALIGNMENT);
// __
JBtn02 = new JButton("JBtn02");
JBtn02.setAlignmentX(Component.CENTER_ALIGNMENT);
// __
JBtn04 = new JButton("JBtn04");
JBtn04.setAlignmentX(Component.RIGHT_ALIGNMENT);
// __
pane.add(JBtn00);
pane.add(JBtn02);
pane.add(JBtn04);
// __
}
// __
private static void createAndShowGUI() {
// __ Create and set up the window.
JFrame JFrm = new JFrame("BxLO00Test");
JFrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JFrm.setSize(800, 25);
// __ Set up the content pane.
addComponentsToPane(JFrm.getContentPane());
// __ Display the window.
// JFrm.pack();
JFrm.setVisible(true);
}
// __
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() { createAndShowGUI(); }
});
}
}