实现换肤的功能 ,怎么不行啊 import java.awt.*; import java.io.*; import java.awt.event.*; import jav 5
importjava.awt.*;importjava.io.*;importjava.awt.event.*;importjavax.swing.*;classSkin...
import java.awt.*;
import java.io.*;
import java.awt.event.*;
import javax.swing.*;
class Skin extends Frame{
FileDialog fileDialog;
JFrame frame;
JLabel label;
public Skin(String Tilte)
{
frame=new JFrame("Title");
Button btnOpen=new Button("Open");
btnOpen.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
fileDialog=new FileDialog(frame,"open",FileDialog.LOAD);
fileDialog.setVisible(true);
String file=fileDialog.getFile();
if(file.endsWith(".jpg")&& file.endsWith(".bmp")){
ImageIcon image=new ImageIcon(file);
label=new JLabel(image);
frame.add(label);
frame.setSize(400,100);
frame.setVisible(true);
}
}
});
frame.add(btnOpen);
}
public static void main(String []args){
new Skin("皮肤");
}
} 展开
import java.io.*;
import java.awt.event.*;
import javax.swing.*;
class Skin extends Frame{
FileDialog fileDialog;
JFrame frame;
JLabel label;
public Skin(String Tilte)
{
frame=new JFrame("Title");
Button btnOpen=new Button("Open");
btnOpen.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
fileDialog=new FileDialog(frame,"open",FileDialog.LOAD);
fileDialog.setVisible(true);
String file=fileDialog.getFile();
if(file.endsWith(".jpg")&& file.endsWith(".bmp")){
ImageIcon image=new ImageIcon(file);
label=new JLabel(image);
frame.add(label);
frame.setSize(400,100);
frame.setVisible(true);
}
}
});
frame.add(btnOpen);
}
public static void main(String []args){
new Skin("皮肤");
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询