私の答えは...ではありませんが、BorderLayout
たぶん使うGridBagLayout
(非常に複雑LayoutManager
)
使いやすいですMigLayout
編集
I am unable to add JList to EAST or WEST since the frame is not getting
extended more than the JFileChooser.
Q: できない、または何らかの要件や制限がありますか?
A: 私の最初のアイデアのどこが悪いのですか
コードから
import java.awt.*;
import javax.swing.*;
public class BorderLayoutWithJComponents {
public BorderLayoutWithJComponents() {
String[] subItems1 = {"Red", "Blue", "Green", "Circle", "Square",
"Triangle", "Apple", "Orange", "Banana"};
JList list = new JList(subItems1);
JFileChooser myFileChooser= new JFileChooser();
JButton one = new JButton("One");
JButton two = new JButton("Two");
JButton three = new JButton("Three");
JPanel panel = new JPanel();
panel.add(one);
panel.add( two);
panel.add(three);
JFrame f = new JFrame("LayoutTest");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(list, BorderLayout.WEST);
f.add(myFileChooser, BorderLayout.CENTER);
f.add(panel, BorderLayout.SOUTH);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new BorderLayoutWithJComponents();
}
});
}
}