void destroy() Called by the browser or applet viewer to inform this applet that it is being reclaimed and that it should destroy any resources that it has allocated. AccessibleContext getAccessibleContext() Gets the AccessibleContext associated with this Applet. AppletContext getAppletContext() Determines this applet's context, which allows the applet to query and affect the environment in which it runs. String getAppletInfo() Returns information about this applet. AudioClip getAudioClip(URL url) Returns the AudioClip object specified by the URL argument. AudioClip getAudioClip(URL url, String name) Returns the AudioClip object specified by the URL and name arguments. URL getCodeBase() Gets the base URL. URL getDocumentBase() Gets the URL of the document in which this applet is embedded. Image getImage(URL url) Returns an Image object that can then be painted on the screen. Image getImage(URL url, String name) Returns an Image object that can then be painted on the screen. Locale getLocale() Gets the Locale for the applet, if it has been set. String getParameter(String name) Returns the value of the named parameter in the HTML tag. String[][] getParameterInfo() Returns information about the parameters that are understood by this applet. void init() Called by the browser or applet viewer to inform this applet that it has been loaded into the system. boolean isActive() Determines if this applet is active. static AudioClip newAudioClip(URL url) Get an audio clip from the given URL. void play(URL url) Plays the audio clip at the specified absolute URL. void play(URL url, String name) Plays the audio clip given the URL and a specifier that is relative to it. void resize(Dimension d) Requests that this applet be resized. void resize(int width, int height) Requests that this applet be resized. void setStub(AppletStub stub) Sets this applet's stub. void showStatus(String msg) Requests that the argument string be displayed in the "status window". void start() Called by the browser or applet viewer to inform this applet that it should start its execution. void stop() Called by the browser or applet viewer to inform this applet that it should stop its execution. 我在文档里,找遍了。可就是没有找到我要找画图的函数啊? 请问是这个applet吗?谢谢!在Java中有没有画像素点的函数啊?
也可以画在panel等上面
Called by the browser or applet viewer to inform this applet that it is being reclaimed and that it should destroy any resources that it has allocated.
AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this Applet.
AppletContext getAppletContext()
Determines this applet's context, which allows the applet to query and affect the environment in which it runs.
String getAppletInfo()
Returns information about this applet.
AudioClip getAudioClip(URL url)
Returns the AudioClip object specified by the URL argument.
AudioClip getAudioClip(URL url, String name)
Returns the AudioClip object specified by the URL and name arguments.
URL getCodeBase()
Gets the base URL.
URL getDocumentBase()
Gets the URL of the document in which this applet is embedded.
Image getImage(URL url)
Returns an Image object that can then be painted on the screen.
Image getImage(URL url, String name)
Returns an Image object that can then be painted on the screen.
Locale getLocale()
Gets the Locale for the applet, if it has been set.
String getParameter(String name)
Returns the value of the named parameter in the HTML tag.
String[][] getParameterInfo()
Returns information about the parameters that are understood by this applet.
void init()
Called by the browser or applet viewer to inform this applet that it has been loaded into the system.
boolean isActive()
Determines if this applet is active.
static AudioClip newAudioClip(URL url)
Get an audio clip from the given URL.
void play(URL url)
Plays the audio clip at the specified absolute URL.
void play(URL url, String name)
Plays the audio clip given the URL and a specifier that is relative to it.
void resize(Dimension d)
Requests that this applet be resized.
void resize(int width, int height)
Requests that this applet be resized.
void setStub(AppletStub stub)
Sets this applet's stub.
void showStatus(String msg)
Requests that the argument string be displayed in the "status window".
void start()
Called by the browser or applet viewer to inform this applet that it should start its execution.
void stop()
Called by the browser or applet viewer to inform this applet that it should stop its execution. 我在文档里,找遍了。可就是没有找到我要找画图的函数啊?
请问是这个applet吗?谢谢!在Java中有没有画像素点的函数啊?
paint方法
1. 画一条直线,起始点和终结点重合(drawLine(x,y,x,y))
2. 画一个椭圆,椭圆的长轴和短轴长度都为1(drawOval(x,y,1,1))
你可以参考一下.
http://www.javafan.net/jive/thread.jsp?forum=1&thread=2436
好像要定义一个Graphics g对象,然后,用g.draw******()的方法,里面有画各种图形的函数
import java.awt.Graphics;public class draw extends Applet{
public void paint(Graphics g){
g.drawOval(100,200,50,50);
}
}用了这段代码,可这并不能画出一个圆来,因为它这儿缺少一个main方法
然后我自己加了一个main方法的类,可这个Graphics 参数该怎么办啊,它是抽象类,不能创建对象的啊?
可怎么写才能在命令行方式下输入java draw就能画出一个图啊?
谢谢了!!!
import javax.swing.*;
public class ExitableJFrame extends JFrame {
public ExitableJFrame(){
}
public ExitableJFrame(String title){
super(title);
}
protected void frameInit(){
super.frameInit();
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
然后生成一个剪切的子类实现对椭圆的剪切:
import java.awt.*;
import java.util.*;
public class Clip extends ExitableJFrame {
Insets insets;
public void paint(Graphics g){
super.paint(g);
if(insets == null){
insets=getInsets();
}
int x=insets.left;
int y=insets.top;
int width=getWidth()-insets.left-insets.right-1;
int height=getHeight()-insets.top-insets.bottom-1;
g.drawOval(x,y,width,height);
int quarter=height/4;
g.clipRect(x,y+quarter,width,height-quarter*2);
g.fillOval(x,y,width,height);
}
public static void main(String[] args) {
Frame f=new Clip();
f.setTitle("clip");
f.setSize(300,200);
f.show();
}
}
画图的工具主要是java.awt包。