⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rhombus.java

📁 JGraph扩展应用。自定义Renderer,自定义视图View实现自定义工作流控件
💻 JAVA
字号:
/**
 * 
 */
package flow.graph.test;

import java.awt.Dimension; 
import java.awt.Graphics; 
import java.awt.Graphics2D; 
import java.awt.Toolkit; 
import java.awt.geom.Line2D; 

import javax.swing.JFrame; 
import javax.swing.JPanel; 

public class Rhombus { 

public static void main(String[] args) { 
RhombusFrame f = new RhombusFrame(400, 300); 
f.setVisible(true); 
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
} 
} 

class RhombusFrame extends JFrame { 
	private int w; 

	private int h; 

	Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); 

	public RhombusFrame(int w, int h) { 
		this.w = w; 
		this.h = h; 
		this.setSize(w, h); 
		this.setTitle("DrawLine"); 
		this.setLocation((d.width - w) / 2, (d.height - h) / 2); 
		this.getContentPane().add(new RhombusPanel()); 
	} 
} 

class RhombusPanel extends JPanel { 
	public void paintComponent(Graphics g) { 
		super.paintComponent(g); 
		Graphics2D g2 = (Graphics2D) g; 
		double topX = 200; 
		double topY = 50; 
		double leftX = 60; 
		double leftY = 120; 
		g2.draw(new Line2D.Double(topX, topY, leftX, leftY)); 
		g2.draw(new Line2D.Double(topX, leftY + leftY - topY, leftX, leftY)); 
		g2.draw(new Line2D.Double(topX, leftY + leftY - topY, topX + topX - leftX, leftY)); 
		g2.draw(new Line2D.Double(topX, topY, topX + topX - leftX, leftY)); 
	} 
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -