求解答-运行结果说是Exception in thread "main" java.NoClassDeFoundError:Example

问题描述

运行结果说是Exception in thread "main" java.NoClassDeFoundError:Example

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.*;
import java.awt.*;
public class Example2 extends JFrame implements MouseListener,ActionListener
{ private ExamplePanel2[] panel=new ExamplePanel2[100];
private JButton jbStart=new JButton ("开始游戏");
private JButton jbBlack=new JButton ("黑方");
private JButton jbWhite=new JButton ("白方");
private int colorFlag=0;
Example2()
{ Container c=this.getContentPane();
c.setLayout(new BorderLayout());
JPanel pc=new JPanel();
JPanel ps=new JPanel();
c.add(pc,BorderLayout.CENTER);
c.add(ps,BorderLayout.SOUTH);
pc.setLayout(new GridLayout(10,10));
for(int i=0;i<panel.length;i++)
{ panel[i]=new ExamplePanel2();
panel[i].setNumber(i+1);
panel[i].addMouseListener(this);
pc.add(panel[i]);
}
ps.setLayout(new FlowLayout(FlowLayout.CENTER));
ps.add(jbStart);
ps.add(jbBlack);
ps.add(jbWhite);
jbStart.addActionListener(this);
jbBlack.addActionListener(this);
jbWhite.addActionListener(this);
this.setTitle("五子棋游戏");
this.setSize(500,500);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void mouseClicked(MouseEvent arg0) { }
public void mouseEntered(MouseEvent arg0) { }
public void mouseExited(MouseEvent arg0) { }
public void mousePressed(MouseEvent arg0)
{ for(int i=0;i<panel.length;i++)
{ if(arg0.getSource()==panel[i])
{ if(colorFlag==0)
{ panel[i].setColor(0);
panel[i].repaint(); }
else
{ panel[i].setColor(1);
panel[i].repaint(); }
}
}
}
public void mouseReleased(MouseEvent arg0) { }
public void actionPerformed(ActionEvent arg0)

{ if(arg0.getSource()==jbBlack)
{colorFlag=0;}
else if(arg0.getSource()==jbWhite)
{colorFlag=1;}
else if(arg0.getSource()==jbStart)
{
for(int i=0;i<panel.length;i++)
panel[i].setStartFlag(1);
}
}
public static void main(String args[])
{ Example2 ex=new Example2(); }
}

import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.*;
public class ExamplePanel2 extends JPanel
{ private int color=0;
private int number=0;
private int startFlag=0;
private int lock=0;
ExamplePanel2 ()
{ this.setBorder(new LineBorder(Color.black,1));
this.setBackground(new Color(255,205,255));
}
public void paintComponent(Graphics g)
{ super.paintComponent(g);
if(startFlag==1)
{ if(lock==0)
{ if(color==0)
g.setColor(Color.black);
else
g.setColor(Color.white);
g.fillOval(10,10,30,30);
lock=1;
}
}
}
public int getColor()
{ return color; }
public void setColor(int color)
{ this.color=color; }
public int getNumber()
{ return number; }
public void setNumber(int number)
{ this.number=number; }
public int getStartFlag()
{ return startFlag; }
public void setStartFlag(int startFlag)
{ this.startFlag=startFlag;
}
}

时间: 2025-01-04 03:54:54

求解答-运行结果说是Exception in thread &amp;quot;main&amp;quot; java.NoClassDeFoundError:Example的相关文章

求解答-最好运行结果说是Exception in thread &amp;amp;quot;main&amp;amp;quot; java.NoSuchMethordError:main

问题描述 最好运行结果说是Exception in thread "main" java.NoSuchMethordError:main import java.applet.*; import java.awt.*; import javax.swing.*; import java.awt.event.*; //import java.Math.*; public class cal extends Applet { //定义所有需要使用的全局变量 String str="

hashmap-Java中遇到的一个异常Exception in thread &amp;amp;quot;main&amp;amp;quot; java.lang.NullPointerException

问题描述 Java中遇到的一个异常Exception in thread "main" java.lang.NullPointerException import java.util.*; public class NewHashTest{ public static void main(String[] args) { HashMap hash = new HashMap(); Emp emp1 = new Emp(""laoda""111&q

Exception in thread &amp;amp;quot;main&amp;amp;quot; java.lang.NoClassDefFoundError:

问题描述 <?xml version='1.0' encoding='UTF-8'?><!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><!-- Generated by

java sql 错误-Exception in thread &amp;amp;quot;main&amp;amp;quot;

问题描述 Exception in thread "main" 5C Exception in thread ""main"" java.lang.NullPointerException 老是出现这个错误,是为什么呢 解决方案 线程里面出现了空指针异常 解决方案二: AxisFault faultCode: {http://xml.apache.org/axis/}HTTP faultSubcode: faultString: (400)Bad

List操作错误Exception in thread &amp;amp;quot;main&amp;amp;quot; java.lang.IllegalStateException

问题描述 Iterator<Teacher> iter = teacherList.iterator();while(iter.hasNext()){Teacher teacher =iter.next();//①查找老师的最大上限值,如果该老师已经达到上限了,则将该老师从List中拿出,不予安排if(teacher.getMaxnum()<=teacher.getRealnum()){iter.remove();teacherList.remove(teacher);}//②找到该考试

使用EditPlus编译,老是出现奇怪的问题:Exception in thread &amp;amp;quot;main&amp;amp;quot;

问题描述 MyJava.java调用了另一个文件HisJava.java里的一个类我使用EditPlus,编译.运行都正常但是,当我修改了HisJava里的代码后,返回MyJava,重新编译,能通过,但就是不能运行,出现了:Exceptioninthread"main"java.lang.NoClassDefFoundError:MyJava我尝试着在DOS里运行命令:javaMyJava却是正常的!更奇怪的是,在EditPlus里,将MyJava的所有代码复制,然后新建一个文件,把复

jdk-Exception in thread &amp;amp;quot;main&amp;amp;quot; java.lang.

问题描述 Exception in thread "main" java.lang. 从svn上down下来的源码,在搭建本机环境的时候报错 Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apdplat/word/analysis/TextSimilarity : Unsupported major.minor version 52.0 2 at java.lang.Cl

二维数组-java报错thread &amp;amp;quot;main&amp;amp;quot; java.lang.NullPointerException

问题描述 java报错thread "main" java.lang.NullPointerException import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.Scanner; public class exercise { /** * @param args */ public stat

manifest mf-Exception in thread &amp;amp;quot;main&amp;amp;quot; java.io.IOException: invalid manifest format

问题描述 Exception in thread "main" java.io.IOException: invalid manifest format fat打包后执行: @echo off set JAVA_HOME=D:studyworktmsjdk1.6.0_02 %JAVA_HOME%binjava -jar -Xms64m -Xmx512m ezTMS2.0-GpsServer_fat.jar @echo on 出现错误: Ensure that the manifest