请教如何加入main函数,能执行这个java小程序(附源代码) 在main里面建个ScribblePanel1 对象 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import javax.swing.*;import java.awt.*;import java.awt.event.*;public class ScribblePanel1 extends JPanel implements MouseListener,MouseMotionListener{ protected int last_x,last_y; public ScribblePanel1(){ this.addMouseListener(this); this.addMouseMotionListener(this); setPreferredSize(new Dimension(450,200)); }public void mousePressed(MouseEvent e){ last_x=e.getX(); last_y=e.getY(); }public void mouseDragged(MouseEvent e){ int x=e.getX(); int y=e.getY(); this.getGraphics().drawLine(last_x,last_y,x,y); last_x=x; last_y=y; } public void mouseReleased(MouseEvent e){} public void mouseClicked(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mouseMoved(MouseEvent e){} public static void main(String[] args) { ScribblePanel1 panel = new ScribblePanel1(); JFrame frame = new JFrame(); frame.getContentPane().add(panel); frame.setSize(new Dimension(450,200)); frame.show(); }} 在定义主类加入主函数public class ScribblePanel1 extends JPanel public static void main [string args()] {...... frame.getContentPane()不就是frame么,这样作是不是多此一举呢 getContentPane返回的是一个Container java整数类型-byte、short、int、long wait()和sleep()的区别 营业税问题 java 中的timer控件问题 String类教材纰漏? Eclipse 动态设置 toolsbar 有关执行存储过程返回值的问题 高分征集<<Java 语言导学(原书第3版)>>电子版!!! 请问为何在别的机器上浏览不了打包的appelt? java高手请进! 我从网站down下一个JDBCProgramExCode文件,例子中有import com.sun.java.swing.*;如何得到这样的包,不然程序根本无法编译,谢谢!! 帮我看看为何数组初始化会出错
import java.awt.*;
import java.awt.event.*;public class ScribblePanel1 extends JPanel
implements MouseListener,MouseMotionListener{
protected int last_x,last_y;
public ScribblePanel1(){
this.addMouseListener(this);
this.addMouseMotionListener(this);
setPreferredSize(new Dimension(450,200));
}
public void mousePressed(MouseEvent e){
last_x=e.getX();
last_y=e.getY(); }
public void mouseDragged(MouseEvent e){
int x=e.getX();
int y=e.getY();
this.getGraphics().drawLine(last_x,last_y,x,y);
last_x=x;
last_y=y;
}
public void mouseReleased(MouseEvent e){}
public void mouseClicked(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mouseMoved(MouseEvent e){} public static void main(String[] args) {
ScribblePanel1 panel = new ScribblePanel1();
JFrame frame = new JFrame();
frame.getContentPane().add(panel);
frame.setSize(new Dimension(450,200));
frame.show();
}
}
public class ScribblePanel1 extends JPanel
public static void main [string args()] {
......