mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
simplify image file filter for background
This commit is contained in:
parent
7b71f12f5d
commit
7a6f42556e
1 changed files with 5 additions and 18 deletions
|
@ -154,24 +154,18 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
private final JFileChooser fc_i = new JFileChooser();
|
||||
{
|
||||
fc_i.setAcceptAllFileFilterUsed(false);
|
||||
fc_i.addChoosableFileFilter(new ImageFileFilter(".jpg"));
|
||||
fc_i.addChoosableFileFilter(new ImageFileFilter(".jpeg"));
|
||||
fc_i.addChoosableFileFilter(new ImageFileFilter(".png"));
|
||||
fc_i.addChoosableFileFilter(new ImageFileFilter(".bmp"));
|
||||
fc_i.addChoosableFileFilter(new ImageFileFilter());
|
||||
}
|
||||
|
||||
private static class ImageFileFilter extends FileFilter{
|
||||
String extend;
|
||||
public ImageFileFilter(String extend){
|
||||
this.extend = extend;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
String filename = f.getName();
|
||||
if(f.isDirectory()) return true;
|
||||
if(filename != null){
|
||||
if(filename.endsWith(extend)){
|
||||
if(filename.endsWith(".jpg") || filename.endsWith(".jpeg") ||
|
||||
filename.endsWith(".png") || filename.endsWith(".bmp")){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -180,15 +174,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
if(extend.equals(".png"))
|
||||
return "Image File(*.png)";
|
||||
if(extend.equals(".bmp"))
|
||||
return "Image File(*.bmp)";
|
||||
if(extend.equals(".jpg") || extend.equals(".jpg"))
|
||||
return "JEGP file(*.jpg,*.jepg)";
|
||||
return "";
|
||||
}
|
||||
|
||||
return "*.png|*.bmp|*.jpg|*.jpeg";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue