Java 画线
importjavax.swing.*;importjava.awt.*;classJframeextendsJFrame{publicJframe(){//setBou...
import javax.swing.*;
import java.awt.*;
class Jframe extends JFrame{
public Jframe(){
//setBounds(100,100,200,300);
this.setSize(400,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
@Override
public void paint(Graphics g) {
super.paint(g);
g.drawLine(40,40,40,250);
g.drawLine(40,250,300,250);
}
}
public class myDraw {
public static void main (String args[]) {
try{
new Jframe();
}catch(Exception e){
e.printStackTrace();
}
}
}
错误提示
java.lang.NoSuchMethodError: main
Exception in thread "main"
Process completed.
为什么有时能通过有时就报这错呢? 展开
import java.awt.*;
class Jframe extends JFrame{
public Jframe(){
//setBounds(100,100,200,300);
this.setSize(400,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
@Override
public void paint(Graphics g) {
super.paint(g);
g.drawLine(40,40,40,250);
g.drawLine(40,250,300,250);
}
}
public class myDraw {
public static void main (String args[]) {
try{
new Jframe();
}catch(Exception e){
e.printStackTrace();
}
}
}
错误提示
java.lang.NoSuchMethodError: main
Exception in thread "main"
Process completed.
为什么有时能通过有时就报这错呢? 展开
1个回答
展开全部
import javax.swing.*;
import java.awt.*;
class Jframe extends JFrame{
public Jframe(){
//setBounds(100,100,200,300);
this.setSize(400,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
@Override
public void paint(Graphics g) {
super.paint(g);
g.drawLine(40,40,40,250);
g.drawLine(40,250,300,250);
}
}
public class myDraw {
public static void main (String args[]) {
//try{
new Jframe();
//}catch(Exception e){
//e.printStackTrace();
//}
}
}
import java.awt.*;
class Jframe extends JFrame{
public Jframe(){
//setBounds(100,100,200,300);
this.setSize(400,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
@Override
public void paint(Graphics g) {
super.paint(g);
g.drawLine(40,40,40,250);
g.drawLine(40,250,300,250);
}
}
public class myDraw {
public static void main (String args[]) {
//try{
new Jframe();
//}catch(Exception e){
//e.printStackTrace();
//}
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询