java代码修改图片名称 java代码修改图片名称怎么改

求助高手!!java连连看数字改图片问题

//将 public void randomBuild() 之前的代码替换成如下代码:

特克斯网站建设公司成都创新互联公司,特克斯网站设计制作,有大型网站制作公司丰富经验。已为特克斯千余家提供企业网站建设服务。企业网站搭建\外贸营销网站建设要多少钱,请找那个售后服务好的特克斯做网站的公司定做!

//注意要替换成自己的图片目录

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import java.io.File;

import java.io.FilenameFilter;

public class lianliankan implements ActionListener {

JFrame mainFrame; // 主面板

Container thisContainer;

JPanel centerPanel, southPanel, northPanel; // 子面板

JButton diamondsButton[][] = new JButton[6][5];// 游戏按钮数组

JButton exitButton, resetButton, newlyButton; // 退出,重列,重新开始按钮

JLabel fractionLable = new JLabel("0"); // 分数标签

JButton firstButton, secondButton; // 分别记录两次被选中的按钮

int grid[][] = new int[8][7];// 储存游戏按钮位置

static boolean pressInformation = false; // 判断是否有按钮被选中

int x0 = 0, y0 = 0, x = 0, y = 0, fristMsg = 0, secondMsg = 0, validateLV; // 游戏按钮的位置坐标

int i, j, k, n;// 消除方法控制

//=====================================//

//=============调用图片================//

private static Icon[] icons = new ImageIcon[6*5];

private static final String imgDir="f:/img";//这里填上图片目录全名就行了

static{

try{

File dir = new File(imgDir);

File[] imgFiles = dir.listFiles(new FilenameFilter(){

public boolean accept(File dir, String name) {

return name.toLowerCase().endsWith(".jpg");

}

});

for(int i=0; i5*6; i++){

icons[i]=new ImageIcon(imgFiles[i].getAbsolutePath());

}

}catch(Exception e){e.printStackTrace();}

}

public void init() {

mainFrame = new JFrame("JKJ连连看");

mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

thisContainer = mainFrame.getContentPane();

thisContainer.setLayout(new BorderLayout());

centerPanel = new JPanel();

southPanel = new JPanel();

northPanel = new JPanel();

thisContainer.add(centerPanel, "Center");

thisContainer.add(southPanel, "South");

thisContainer.add(northPanel, "North");

centerPanel.setLayout(new GridLayout(6, 5));

for (int cols = 0; cols 6; cols++) {

for (int rows = 0; rows 5; rows++) {

// diamondsButton[cols][rows] = new JButton(String

// .valueOf(grid[cols + 1][rows + 1]));

//===============================设置图片==================================//

diamondsButton[cols][rows] = new JButton(icons[grid[cols + 1][rows + 1]-1]);

diamondsButton[cols][rows].addActionListener(this);

centerPanel.add(diamondsButton[cols][rows]);

}

}

exitButton = new JButton("退出");

exitButton.addActionListener(this);

resetButton = new JButton("重列");

resetButton.addActionListener(this);

newlyButton = new JButton("再来一局");

newlyButton.addActionListener(this);

southPanel.add(exitButton);

southPanel.add(resetButton);

southPanel.add(newlyButton);

fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable

.getText())));

northPanel.add(fractionLable);

mainFrame.setBounds(280, 100, 500, 450);

mainFrame.setVisible(true);

}

java怎么修改文件名称

一般的操作:

File file=new File("word.txt");

String filename=new String("word1.txt");//更改后的文件名

file.renameTo(filename);//更改文件名操作

判断是否已经更改文件名:

File file=new File("word.txt");

String filename=new String("word1.txt);

if(file.renameTo(filename)){

System.out.println("修改文件名成功");

}else{

System.out.println("修改文件名失败");

}

file是更改文件名之前的文件,可以为绝对路径或相对路径:

绝对路径可表示为:File file=new File("D:/word.txt");

相对路径的根文件夹与src文件夹同级,如File file=new File("worddir/word.txt");中的worddir文件夹与src同级

filename是更改文件名之后的文件的文件名(包含后缀)

用java如何编辑图片的主题,标题,作者,创建日期等信息?

有的信息,是保存在文件里面的,要使用exif的格式去修改 ,,,,,,,,,,,apache有这样的lib


网页标题:java代码修改图片名称 java代码修改图片名称怎么改
网址分享:http://lszwz.com/article/ddcpici.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款