当前位置: 技术问答>java相关
在Applet中如何画“虚线”? 急~!!!
来源: 互联网 发布时间:2015-02-21
本文导语: 在Applet中如何画“虚线”? 我想画一个坐标系,请指教,有代码的请给代码,谁能帮我解决马上给分~! | FWD: Befor drawing, set Stroke first. For example, float[] dash1 = {10.0f}; g.setStroke(new BasicStroke(1.0f,...
在Applet中如何画“虚线”?
我想画一个坐标系,请指教,有代码的请给代码,谁能帮我解决马上给分~!
我想画一个坐标系,请指教,有代码的请给代码,谁能帮我解决马上给分~!
|
FWD:
Befor drawing, set Stroke first. For example,
float[] dash1 = {10.0f};
g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f));
Then, i can draw a broken line.
Befor drawing, set Stroke first. For example,
float[] dash1 = {10.0f};
g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f));
Then, i can draw a broken line.
|
import java.awt.*;
import java.applet.*;
import javax.swing.*;
public class wer extends JApplet
{
public void init()
{
//JButton jb = new JButton("sdaf");
//getContentPane().add(jb);
}
public void paint(Graphics g)
{
float[] dash1 = {10.0f};
Graphics2D gw = (Graphics2D)g;
//gw.setStroke(new BasicStroke(1.0f,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
gw.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f));
gw.drawString("Hello World", 20, 20);
gw.drawLine(10,10,200,300);
}
}
import java.applet.*;
import javax.swing.*;
public class wer extends JApplet
{
public void init()
{
//JButton jb = new JButton("sdaf");
//getContentPane().add(jb);
}
public void paint(Graphics g)
{
float[] dash1 = {10.0f};
Graphics2D gw = (Graphics2D)g;
//gw.setStroke(new BasicStroke(1.0f,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
gw.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f));
gw.drawString("Hello World", 20, 20);
gw.drawLine(10,10,200,300);
}
}
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。