0
JDialog
が小さいサイズにリサイズすると、下から上にカットされます。 しかし、それを最下位にする方法は「優先度が高い」、JDialogは最初に先頭を切り捨て、下端を切り捨てないままにします。リサイズ後JDialogのサイズ変更時にボトムパネルをカットしない
を(上のパネルはOKですが、下のパネルが切断された):リサイズ前
この場合
私はトップパネルをカットしたいです下パネルはOKです
ソース:
南部分はカットすべきではないmainPanel.add(top, BorderLayout.CENTER);
mainPanel.add(bottom, BorderLayout.SOUTH);
:
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
@SuppressWarnings("serial")
public class DlgTest extends JDialog {
/**
* Launch the application.
*/
public static void main(String[] args) {
try {
DlgTest dialog = new DlgTest();
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the dialog.
*/
public DlgTest() {
setBounds(100, 100, 450, 300);
JPanel mainPanel = new JPanel(new BorderLayout());
JPanel top = new JPanel(new FlowLayout());
top.add(new JButton("t1"));
top.add(new JButton("t2"));
JPanel bottom = new JPanel(new FlowLayout());
bottom.add(new JButton("b1"));
bottom.add(new JButton("b2"));
mainPanel.add(top, BorderLayout.PAGE_START);
mainPanel.add(bottom, BorderLayout.PAGE_END);
add(mainPanel);
}
}