/**
* I'd like to achive following layout:
* +----------+----------+
* | Button 1 | |
* +----------| Button 2 |
* | Button 3 | |
* +----------+----------+
* with following code:
*/
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
JButton button;
button = new JButton("Button 1");
c.weightx = 0.5;
c.weighty = 0.5;
c.fill = GridBagConstraints.BOTH;
panel.add(button, c);
button = new JButton("Button 2");
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridheight = 2;
panel.add(button, c);
button = new JButton("Button 3");
c.gridwidth = 1;
panel.add(button, c);
/**
* but what I achive is:
* +----------+----------+
* | Button 1 | Button 2 |
* +----------+----------+|
* | Button 3 |
* +----------+
*/
/**
* However layout:
* +----------+----------+
* | | Button 2 |
* + Button 1 +----------+
* | | Button 3 |
* +----------+----------+
* is easily achieved as:
*/
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
JButton button;
button = new JButton("Button 1");
c.weightx = 0.5;
c.weighty = 0.5;
c.fill = GridBagConstraints.BOTH;
c.gridheight = 2;
panel.add(button, c);
button = new JButton("Button 2");
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridheight = 1;
panel.add(button, c);
button = new JButton("Button 3");
panel.add(button, c);
手がかりはありますか?GridBagLayoutを必要に応じて動作させることはできません
について、Francesc
私の場合と同じ結果、試してみましたか? – francesc