package com.vci.client.ui.swing.components;
|
|
import java.awt.Color;
|
import java.awt.Graphics;
|
import java.io.File;
|
|
import javax.swing.JFileChooser;
|
import javax.swing.filechooser.FileSystemView;
|
|
import com.vci.client.ui.swing.VCISwingUtil;
|
|
/**
|
*
|
* <p>Title: </p>
|
* <p>Description: </p>
|
* <p>Copyright: Copyright (c) 2012</p>
|
* <p>Company: VCI</p>
|
* @author xchao
|
* @time 2012-5-10
|
* @version 1.0
|
*/
|
public class VCIJFileChooser extends JFileChooser {
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 767915073291456133L;
|
|
public VCIJFileChooser() {
|
this((File) null, (FileSystemView) null);
|
}
|
|
public VCIJFileChooser(String currentDirectoryPath) {
|
this(currentDirectoryPath, (FileSystemView) null);
|
}
|
|
public VCIJFileChooser(File currentDirectory) {
|
this(currentDirectory, (FileSystemView) null);
|
}
|
|
public VCIJFileChooser(FileSystemView fsv) {
|
this((File) null, fsv);
|
}
|
|
public VCIJFileChooser(File currentDirectory, FileSystemView fsv) {
|
super(currentDirectory, fsv);
|
customConstructor();
|
}
|
|
public VCIJFileChooser(String currentDirectoryPath, FileSystemView fsv) {
|
super(currentDirectoryPath, fsv);
|
customConstructor();
|
}
|
|
private void customConstructor(){
|
setFont(VCISwingUtil.FONT_DEFAULT);
|
}
|
@Override
|
public void paint(Graphics g){
|
super.paint(g);
|
if(isRequired()) {
|
drawRequiredFlag(g);
|
}
|
}
|
|
private void drawRequiredFlag(Graphics g){
|
int x = getWidth() - 9;
|
int y = 1;
|
g.setColor(Color.RED);
|
g.fillArc(x, y, 7, 7, 0, 360);
|
// int x = getWidth() - 10;
|
// int y = 10;
|
// g.setColor(Color.RED);
|
// g.drawString("*", x, y);
|
}
|
|
private boolean required = false;
|
|
public boolean isRequired() {
|
return required;
|
}
|
|
public void setRequired(boolean required) {
|
this.required = required;
|
}
|
}
|