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();
|
private final JFileChooser fc_i = new JFileChooser();
|
||||||
{
|
{
|
||||||
fc_i.setAcceptAllFileFilterUsed(false);
|
fc_i.setAcceptAllFileFilterUsed(false);
|
||||||
fc_i.addChoosableFileFilter(new ImageFileFilter(".jpg"));
|
fc_i.addChoosableFileFilter(new ImageFileFilter());
|
||||||
fc_i.addChoosableFileFilter(new ImageFileFilter(".jpeg"));
|
|
||||||
fc_i.addChoosableFileFilter(new ImageFileFilter(".png"));
|
|
||||||
fc_i.addChoosableFileFilter(new ImageFileFilter(".bmp"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ImageFileFilter extends FileFilter{
|
private static class ImageFileFilter extends FileFilter{
|
||||||
String extend;
|
|
||||||
public ImageFileFilter(String extend){
|
|
||||||
this.extend = extend;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File f) {
|
public boolean accept(File f) {
|
||||||
String filename = f.getName();
|
String filename = f.getName();
|
||||||
if(f.isDirectory()) return true;
|
if(f.isDirectory()) return true;
|
||||||
if(filename != null){
|
if(filename != null){
|
||||||
if(filename.endsWith(extend)){
|
if(filename.endsWith(".jpg") || filename.endsWith(".jpeg") ||
|
||||||
|
filename.endsWith(".png") || filename.endsWith(".bmp")){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,15 +174,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
if(extend.equals(".png"))
|
return "*.png|*.bmp|*.jpg|*.jpeg";
|
||||||
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 "";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue