62,621
社区成员
发帖
与我相关
我的任务
分享
Image img = ImageIO.read(getClass().getResourceAsStream(
"/img/mian.png"));
//先将此图放到JPanel中做背景图片
panel = new ImagePanel();
panel .setImg(img);
//至此一切正常,Eclipse运行正常,打包后jar运行正常,exe4j做exe后运行也正常。图片照常显示 ,,
//再将此图放入JButton中
JButton jb = new JButton();
jb.setIcon(new ImageIcon(img));
//Eclipse中运行正常显示,打包后jar运行不显示,exe4j做exe后运行也不显示。

javaw.exe -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:9999 ...省略


//定义选项卡
public void defindTabFolder() {
tabFloder = new JTabbedPane(JTabbedPane.LEFT);
// JScrollPane scrollPane = new JScrollPane(tabFloder); //支持滚动
// scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
tabFloder.setBounds(10, (int) height / 2 - 90, (int) width / 2 - 40,
480);
JPanel jp = new JPanel();
JPanel jp1 = new JPanel();
tabFloder.add("上装", jp);
jp.setName("上装");
tabFloder.add("下装", jp1);
jp1.setName("下装");
//获取商品信息,得到map
XMLTool xml = new XMLTool();
colthing = xml.parserXml("colthing.xml");
polo = xml.parserXml("polo.xml");
//显示map中的商品信息
showData(jp, colthing);
showData(jp1, polo);
add(tabFloder);
}
//显示商品信息
public void showData(JPanel jp, HashMap<String, ColthingBean> data) {
if (data != null) {
Image img;
String path = "";
try {
if (jp.getName().equals("上装")) {
path = "西服.PNG";
} else if (jp.getName().equals("下装")) {
path = "西裤.png";
} else {
path = "毛巾.PNG";
}
//System.out.println(path);
img = ImageIO.read(this.getClass().getResourceAsStream(
"/img/" + path));
Set<String> set = data.keySet();
for (Iterator<String> iterator = set.iterator(); iterator
.hasNext();) {
String key = (String) iterator.next();
JButton jb = new JButton();
jb.setText(key);
jb.setIcon(new ImageIcon(img));
setJButton(jb);
list.add(jb);//将JButton放入集合中 以便添加事件
jp.add(jb);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
没坐过桌面应用....用java做cs,效率不去c#