开发者

Netbeans jar file icon problems

开发者 https://www.devze.com 2023-02-03 02:41 出处:网络
I finally found how to make an exe project in Netbeans, so a jar file and execute it from the DESKTOP.

I finally found how to make an exe project in Netbeans, so a jar file and execute it from the DESKTOP.

The only problem I have ocurred is that after I open the jar file and login with my username and password the button icons are not shown, if I put a string it appears but if I put the image it doesn't appear.

So,I had to restore this code:

    JButton btnNew = new JButton(new ImageIcon("new.gif"));
JButton btnUpdate = new JButton(new ImageIcon("NotePad.gif"));
JButton btnDelete = new JButton(new ImageIcon("delete.gif"));
JButton btnSearch = new JButton(new ImageIcon("find.gif"));

and put this one:

  JButton btnNew = new JButton("ADD");
JButton btnUpdate = new JButton("Update");
JButton btnDelete = new JButton("Delete");
JButton btnSearch = new JButton("Sea开发者_StackOverflow中文版rch");

It now works but I would like to have the icons please.

Any idea?


replace

JButton btnNew = new JButton(new ImageIcon("new.gif"));

by

JButton btnNew = new JButton(new ImageIcon(getClass().getResource("new.gif")));

Note: Assuming all the images are located in default packages , otherwise try /your/path/to/imagenew.gif

0

精彩评论

暂无评论...
验证码 换一张
取 消