JFileChooserのリサイズなどを制限
Total: 9078
, Today: 2
, Yesterday: 2
Posted by aterai at
Last-modified:
Summary
JFileChooser
のリサイズや、最小サイズ以下へのサイズ変更を禁止します。
Screenshot

Advertisement
Source Code Examples
JFileChooser fileChooser = new JFileChooser() {
@Override protected JDialog createDialog(Component parent) throws HeadlessException {
JDialog dialog = super.createDialog(parent);
dialog.setResizable(false);
// dialog.setMinimumSize(new Dimension(640, 480)); // JDK 6
// dialog.addComponentListener(new MinimumSizeAdapter());
return dialog;
}
};
View in GitHub: Java, KotlinExplanation
JFileChooser#createDialog()
メソッドをオーバーライドしてマウスでのリサイズ制限と、最小サイズを設定Windows
環境でもJDK 6
以上でオーバーライドしたcreateDialog
メソッド内でJDialog#setMinimumSize(Dimension)
を使用すれば最小サイズの設定が可能