に実行することはできません私はrunable jarファイルに私のプロジェクトをパックしようとしている、と私はこのエラーを得た:私の実行可能なjarファイルが原因NullPointerExceptionが
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at eBridge.LoginPage.initialize(LoginPage.java:66)
at eBridge.LoginPage.<init>(LoginPage.java:55)
at eBridge.LoginPage.<init>(LoginPage.java:49)
at eBridge.eBridgFrame.<init>(eBridgFrame.java:37)
at eBridge.eBridgFrame$1.run(eBridgFrame.java:24)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
私の主な方法は、クラスのcalssのeBridgFrameでありますタブ...ここにITZランニングベースがeBridgFrameクラスです:
package eBridge;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.WindowEvent;
import javax.swing.WindowConstants;
public class eBridgFrame extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
eBridgFrame thisClass = new eBridgFrame();
thisClass.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
thisClass.setVisible(true);
}
});
}
/**
* This is the default constructor
*/
public eBridgFrame() {
super();
initialize();
JPanel panel = new LoginPage(this);
this.getContentPane().add(panel);
this.setVisible(true);
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(950, 720);
this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.setName("EBRIDG");
this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/eBridge/images/eB.png")));
this.setResizable(false);
this.setMinimumSize(new Dimension(950, 720));
this.setPreferredSize(new Dimension(950, 720));
this.setContentPane(getJContentPane());
this.setTitle("EBRIDG");
}
//Pop up msg to confirm closing by overiding javax.swing.JFrame.processWindowEvent() method
protected void processWindowEvent(WindowEvent e) {
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
int exit = JOptionPane.showConfirmDialog(this, "Are you sure?");
if (exit == JOptionPane.YES_OPTION) {
System.exit(0);
}
}
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
}
return jContentPane;
}
}
誰かが私を保存することができます?どうもありがとう !
すべてのコードでコードタグ(アイコンは{}のように見えます)を使用してください。現在の形式で読むのは本当に難しいです。 –
Java命名規則を学び、それらに固執してください – kleopatra