jar 无法运行,不知道是不是有图片的原因...
我出现这样的问题,当在eclips 中运行的时候都是正常的,也可以找到相对路径,但是一旦打包成JAR,双击运行一点反映都没,只是在系统管理里面多了个进程,不知道是哪里出了问题,各位高手帮忙看下,这个问题困扰我好久了就是解决不了.谢谢
下面是程序:
import java.awt.*;
import java.awt.event.*;
import java.net.URL;
import java.net.URLClassLoader;
import javax.swing.AbstractButton;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.ImageIcon;
public class ButtonDemo extends JPanel
implements ActionListener {
protected JButton b1, b2, b3;
public ButtonDemo() {
ImageIcon leftButtonIcon = new ImageIcon(createImage( "images/right.gif "));
ImageIcon middleButtonIcon = new ImageIcon(createImage( "images/middle.gif "));
ImageIcon rightButtonIcon = new ImageIcon(createImage( "images/left.gif "));
b1 = new JButton( "失效中间按钮(D) ", leftButtonIcon);
b1.setVerticalTextPosition(AbstractButton.CENTER);//水平中间对齐
b1.setHorizontalTextPosition(AbstractButton.LEADING);//相当于LEFT
b1.setMnemonic(KeyEvent.VK_D);//将b1邦定alt+D键
b1.setActionCommand( "disable ");
b2 = new JButton( "M中间按钮 ", middleButtonIcon);
b2.setVerticalTextPosition(AbstractButton.BOTTOM);
b2.setHorizontalTextPosition(AbstractButton.CENTER);
b2.setMnemonic(KeyEvent.VK_M);//将b2邦定alt+M键
b3 = new JButton( "E激活中间按钮 ", rightButtonIcon);
b3.setMnemonic(KeyEvent.VK_E);//将b3邦定alt+E键
b3.setActionCommand( "enable ");
b3.setEnabled(false);
b1.addActionListener(this);
b3.addActionListener(this);
b1.setToolTipText( "点击这个按钮,将使中间的按钮失效! ");
b2.setToolTipText( "点击这个按钮,没有任何的事件发生! ");
b3.setToolTipText( "点击这个按钮,将使中间的按钮有效 ");
add(b1);
add(b2);