import java.awt.Graphics;public class myLine{
private int x1;
private int x2;
private int y1;
private int y2;
public myLine( int x1, int x2, int y1, int y2 ){
this.x1 = x1;
this.x2 = x2;
this.y1 = y1;
this.y2 = y2;
} public myLine(){
this( 0, 0, 0, 0 );
} public void draw( Graphics g ){
g.drawLine( x1, y1, x2, y2 );
}}
import java.awt.Graphics;
import javax.swing.*;public class myApplet extends JApplet{
myLine line = new myLine( 20, 20, 100, 100 );
public void paint( Graphics g ){
super.paint( g );
line.draw( g );
}
}结果什么都没有 为什么不能输出2条直线呢?
private int x1;
private int x2;
private int y1;
private int y2;
public myLine( int x1, int x2, int y1, int y2 ){
this.x1 = x1;
this.x2 = x2;
this.y1 = y1;
this.y2 = y2;
} public myLine(){
this( 0, 0, 0, 0 );
} public void draw( Graphics g ){
g.drawLine( x1, y1, x2, y2 );
}}
import java.awt.Graphics;
import javax.swing.*;public class myApplet extends JApplet{
myLine line = new myLine( 20, 20, 100, 100 );
public void paint( Graphics g ){
super.paint( g );
line.draw( g );
}
}结果什么都没有 为什么不能输出2条直线呢?
解决方案 »
- 用java截取页面数据
- 优化算法
- C#
- 为什么会出现错误呢
- swing中遇到的问题?
- Swing的jtxtField中的文字发生改变时,应该怎样即时读取到改变后的文字
- 各位大哥前辈的请指点一下小弟!!
- 请教是否在奔四下不能装 JavaWebServer2.0,是否需有一些设置,及请教学jbuilder的较好教材(谢!)
- 关于Borland appserver 4.5的。有意者请进。!
- 我在主窗口上,添加一个菜单栏和jpanel,删除jpanel,然后再添加一个jpanel。结果主窗口上的菜单栏和关闭窗口点击不起作用了。希望大神给指点一下。
- 一道某著名外企的经典算法面试题
- 以点击点为中心视图缩放
改为myLine line = new myLine( 20, 20, 25, 25 ); 也不行, 继续顶