eclipse顯示被隱藏的文件或文件夾?
稷山網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)!從網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、響應(yīng)式網(wǎng)站設(shè)計等網(wǎng)站項目制作,到程序開發(fā),運營維護(hù)。創(chuàng)新互聯(lián)于2013年成立到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗和運維經(jīng)驗,來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)。
點擊左邊導(dǎo)航(Navigator或者PackageExplorer等)右上角的小三角 - Filters?
點擊需要顯示文件,讓復(fù)選框處于非選中狀態(tài)。
淡入淡出Swing組件
/**
* 淡入淡出式顯示內(nèi)容組件的容器
* @author William Chen
*/
public class GlassBox extends JComponent implements ActionListener{
//常數(shù)定義
private static final int ANIMATION_FRAMES=50;
private static final int ANIMATION_INTERVAL=10;
//幀索引
private int frameIndex;
//時鐘
private Timer timer;
/** Creates a new instance of GlassBox */
public GlassBox() {
}
public void paint(Graphics g){
if(isAnimating()){
//根據(jù)當(dāng)前幀顯示當(dāng)前透明度的內(nèi)容組件
float alpha=(float)frameIndex/(float)ANIMATION_FRAMES;
Graphics2D g2d=(Graphics2D)g;
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
//Renderer渲染機(jī)制
super.paint(g2d);
}else{
//如果是第一次,啟動動畫時鐘
frameIndex=0;
timer=new Timer(ANIMATION_INTERVAL, this);
timer.start();
}
}
//判斷當(dāng)前是否正在進(jìn)行動畫
private boolean isAnimating(){
return timer!=null timer.isRunning();
}
//關(guān)閉時鐘,重新初始化
private void closeTimer() {
if(isAnimating()){
timer.stop();
frameIndex=0;
timer=null;
}
}
//動畫時鐘處理事件
public void actionPerformed(ActionEvent e) {
//前進(jìn)一幀
frameIndex++;
if(frameIndex=ANIMATION_FRAMES)
//最后一幀,關(guān)閉動畫
closeTimer();
else//更新當(dāng)前一幀
repaint();
}
}
你在js中獲取這個對象,隱藏就用.hidden(),顯示就用.show(),把這個代碼綁定在你想要的動作里面,比如onclick等事件
我給你寫的示例程序:隱藏數(shù)據(jù)調(diào)用hiddenWords,讀取數(shù)據(jù)用readWords,移除數(shù)據(jù)用removeWords。不管是什么簡單數(shù)據(jù)復(fù)雜數(shù)據(jù),圖片不管什么格式。主要都是轉(zhuǎn)化為流來處理哈。代碼如下:有不明白的可以hi 我
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* @author Think
*
*/
public class HiddenWords
{
/**
*
*/
public HiddenWords()
{
// TODO Auto-generated constructor stub
}
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
try
{
int picbytes = hiddenWords("c:\\Sunset.bmp", "c:\\hidden.bmp", "hidden words");
String s = readWords("c:\\hidden.bmp", picbytes);
removeWords("c:\\hidden.bmp", picbytes, "c:\\old.bmp");
System.out.println("read words is:" + s);
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
static int hiddenWords(String input, String output,String words)
{
try
{
InputStream is = new FileInputStream(new File(input/*"c:\\Sunset.bmp"*/));
int bytes = is.available();
DataOutputStream dos = new DataOutputStream(new FileOutputStream(new File(output/*"c:/s.bmp"*/)));
byte[] b = new byte[bytes];
int n = is.read(b, 0, bytes);
is.close();
dos.write(b, 0, n);
dos.writeUTF(words/*"ooeooeore"*/);
dos.close();
System.out.println("write end!!!");
return bytes;
}
catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return 0;
}
static String readWords(String input/*DataInputStream dis*/, int skipbytes)
{
try
{
DataInputStream dis = new DataInputStream(new FileInputStream(new File(input)));
dis.skip(skipbytes);
String result = dis.readUTF();
dis.close();
return result;
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return "";
}
static void removeWords(String input/*DataInputStream dis*/, int skipbytes,String output)
{
try
{
DataInputStream dis = new DataInputStream(new FileInputStream(new File(input)));
byte[] bs = new byte[skipbytes];
int x = dis.read(bs, 0, skipbytes);
dis.close();
DataOutputStream dos = new DataOutputStream(new FileOutputStream(new File(output)));
dos.write(bs, 0, x);
dos.close();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
就是加個水印吧
package com.jc.ts.services;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.sun.image.codec.jpeg.ImageFormatException;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
/**
*添加圖片水印的服務(wù)類
* */
public class WaterMark {
/**
* @param sizeContext添加水印文字
* @param request 請求流對象
* @param request 響應(yīng)流對象
* */
@SuppressWarnings("deprecation")
public static void createMarkSize(String sizeContext,HttpServletRequest request,HttpServletResponse response) {
try {
String path=request.getRealPath(request.getServletPath());
FileInputStream in=new FileInputStream(path);
Image src=ImageIO.read(in);
int w=src.getWidth(null);
int h=src.getHeight(null);
BufferedImage img=new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);//構(gòu)建畫板
Graphics g=img.getGraphics();//得到畫筆
g.drawImage(src,0,0,w,h,null);//把源圖片寫入畫板
g.setColor(Color.red);
g.drawString(sizeContext,10,5); // 添加文字
g.dispose();//生成圖片
JPEGImageEncoder e=JPEGCodec.createJPEGEncoder(response.getOutputStream());
e.encode(img);
response.getOutputStream().close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ImageFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* @param localPath 添加水印LOGO路徑
* @param request 請求流對象
* @param request 響應(yīng)流對象
**/
@SuppressWarnings("deprecation")
public static void createMarkLogo(String localPath,HttpServletRequest request,HttpServletResponse response) {
try {
FileInputStream file=new FileInputStream(localPath);
Image fimg=ImageIO.read(file);
int fw=fimg.getWidth(null);
int fh=fimg.getHeight(null);
String path=request.getRealPath(request.getServletPath());
FileInputStream in=new FileInputStream(path);
Image src=ImageIO.read(in);
int w=src.getWidth(null);
int h=src.getHeight(null);
BufferedImage img=new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);//構(gòu)建畫板
Graphics g=img.getGraphics();//得到畫筆
g.drawImage(src,0,0,w,h,null);//把原圖片寫入畫板
g.drawImage(fimg,w-20,h-15,fw,fh,null);//把水印圖片寫入畫板
g.dispose();//生成圖片
JPEGImageEncoder e=JPEGCodec.createJPEGEncoder(response.getOutputStream());
e.encode(img);
response.getOutputStream().close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ImageFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/**
* @param localPath 添加水印圖片路徑
* @param request 請求流對象
* @param request 響應(yīng)流對象
* @param width 水印圖片的寬度
* @param height 水印圖片的長度
**/
@SuppressWarnings("deprecation")
public static void createMarkLogo(String localPath,HttpServletRequest request,HttpServletResponse response,int width,int height) {
try {
FileInputStream file=new FileInputStream(localPath);
Image fimg=ImageIO.read(file);
int fw=fimg.getWidth(null);
int fh=fimg.getHeight(null);
String path=request.getRealPath(request.getServletPath());
FileInputStream in=new FileInputStream(path);
Image src=ImageIO.read(in);
int w=src.getWidth(null);//w為你過濾圖片的寬度
int h=src.getHeight(null);//h為你過濾圖片的長度
BufferedImage img=new BufferedImage(w+width,h+height,BufferedImage.TYPE_INT_RGB);//構(gòu)建畫板(畫板的寬度為兩個圖片之和)
Graphics g=img.getGraphics();//得到畫筆
g.drawImage(src,0,0,w,h,null);//把原圖片寫入畫板
g.drawImage(fimg,width,height,fw,fh,null);//把水印圖片寫入畫板
g.dispose();//生成圖片
JPEGImageEncoder e=JPEGCodec.createJPEGEncoder(response.getOutputStream());
e.encode(img);
response.getOutputStream().close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ImageFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
注意第三個方法的注釋地方g.drawImage(fimg,width,height,fw,fh,null);根據(jù)參數(shù)你在調(diào)調(diào)(放原圖下面的)
過濾器調(diào)用
package com.jc.ts.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.jc.ts.services.WaterMark;
public class WaterFilter implements Filter {
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest arg0, ServletResponse arg1,
FilterChain arg2) throws IOException, ServletException {
HttpServletRequest request=(HttpServletRequest)arg0;
HttpServletResponse response=(HttpServletResponse)arg1;
//WaterMark.createMarkSize("南京ts", request, response);
//WaterMark.createMarkLogo("D:\\workspace\\mybook\\WebRoot\\images\\logo\\book.jpg", request, response);
WaterMark.createMarkLogo("D:\\workspace\\mybook\\WebRoot\\images\\logo\\book.jpg", request, response,20,30);
//注意路徑為絕對路徑且三個效果不能同時執(zhí)行
}
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
}
}
web.xml配置(寫在servlet上面)
filter
descriptionThis is the description of my J2EE component/description
display-nameThis is the display name of my J2EE component/display-name
filter-nameWaterFilter/filter-name
filter-classcom.jc.ts.filter.WaterFilter/filter-class
/filter