Java : how to draw a line in thickness
来源:互联网 发布:淘宝怎么看同行转化率 编辑:程序博客网 时间:2024/05/16 02:01
package EXP;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
public class TestLine extends JFrame{
private MyPanel panel;
public TestLine() {
setSize(200, 200);
panel = new MyPanel();
getContentPane().add( panel, "Center" );
}
public static void main( String [] args ){
TestLine tl = new TestLine();
tl.setVisible( true );
}
}
class MyPanel extends JPanel {
final static BasicStroke stroke = new BasicStroke(2.0f);
final static BasicStroke wideStroke = new BasicStroke(8.0f);
public MyPanel(){}
public void paintComponent( Graphics g ){
//Using JDK1.3
Graphics2D g2 = (Graphics2D)g;
//g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //set the border
g2.setStroke( stroke );
g2.draw(new Line2D.Double(10.0, 10.0, 100.0, 10.0));
g2.setStroke( wideStroke );
g2.draw(new Line2D.Double(10.0, 50.0, 100.0, 50.0));
//Using JDK1.2
Graphics2D g2d = (Graphics2D)g;
int width = 10;
g.setColor(Color.BLUE);
g2d.setStroke(new BasicStroke(width));
g2d.drawLine(10, 70, 100, 70);
}
}
- Java : how to draw a line in thickness
- How to remove a line from a file in java?
- How to draw on a canvas in rap applications
- Review:how to draw a mesh in xna
- How to draw a rubber band rectangle or a focus rectangle in Visual C#
- How to Draw a Binary Tree ?
- How to Draw a Balanced Binary Tree ?
- How to run java and junit in command line
- How To Loop A Map In Java
- How to write a diagup line over a mathematical formula in LaTex
- XNA How To: Draw a Model with a Custom Effect
- How to show line number in eclipse
- How to convert a Map to List in Java?
- How To Import A Sales Order With One Line In Booked Status
- How to zone a Brocade SAN switch in command line base?
- How to read a file line by line?
- C# 画线 Draw a Line
- How to Iterate Over a Map in Java
- exec函数族
- 测试文章-二进制和ASCII码转换代码
- mariage
- 新生
- UILoader URLLoader Loader 类的区别
- Java : how to draw a line in thickness
- UML详述
- Java : how to convert text to image
- 我的博客,欢迎光临!
- 数据库同步又未成功
- 四种操作xml的方式: SAX, DOM, JDOM , DOM4J的比较
- Server Application Unavailable 错误
- Java语言基础之String及StringBuffer之一(区别)
- 社交开发平台淘金失败根源:不能透彻把握模式