Java画图程序画图工具如何添加文字字功能

如果你想在Java应用中嵌入一个功能强大的文字编辑器,那么XDocBuilder可能是最好的选择1、免费2、格式丰富,可以处理段落、文字、图形、图片、图表、表格等3、文件格式支持丰富:xdoc、docx、pdf、rtf、doc、htm、txt、swf、svg等4、标准格式xdoc是一个简单的xml文本5、包依赖少,只有一个包是必须的6、嵌入简单,它只是一个JComponent7、API功能强大:打开、编辑、打印、格式转换等
主程序库(必须)
图表(可选)
二维码(可选)
读取doc、ppt、xls(可选)
高亮格式化(可选)
import java.awt.BorderL
import java.awt.C
import java.awt.event.ActionE
import java.awt.event.ActionL
import java.awt.event.WindowE
import java.awt.event.WindowL
import java.io.F
import javax.swing.JB
import javax.swing.JF
import javax.swing.JOptionP
import javax.swing.JToolB
import javax.swing.UIM
import com.hg.xdoc.XDocB
import com.hg.xdoc.XDocIO;
* XDocBuilder嵌入测试
* @author xdoc
public class XDocBuilderTest {
private static XDocB
* @param args
public static void main(String[] args) {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//获取XDocBuilder实例
builder = new XDocBuilder();
JFrame frame = new JFrame("XDocBuilder嵌入测试");
//将XDocBuilder放入面板中
frame.getContentPane().add(builder, BorderLayout.CENTER);
JToolBar bar = new JToolBar("工具条");
JButton btn = new JButton("新建");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
builder.create();
btn = new JButton("打开");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
builder.open();
//builder.open("http://www.hgsql.com/down/XDocIntro.xdoc", XDocIO.READ_FORMAT_XDOC);
bar.add(btn);
btn = new JButton("查看XML");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//显示XML内容
JOptionPane.showMessageDialog(null, builder.getXml());
} catch (Exception e1) {
JOptionPane.showMessageDialog(null, e1.getMessage());
bar.add(btn);
btn = new JButton("保存");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//保存当前文件
builder.save();
bar.add(btn);
btn = new JButton("全部保存");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
for (int i = 0; i & builder.getXDocCount(); i++) {
//选择第i个文件
builder.activeXDoc(i);
builder.save();
//builder.save("xdox" + i + ".rtf", XDocIO.WRITE_FORMAT_PDF);
bar.add(btn);
btn = new JButton("关闭");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//关闭当前文件
builder.close();
bar.add(btn);
btn = new JButton("打印");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
builder.print();
bar.add(btn);
btn = new JButton("直接打印");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//打印到指定打印机
builder.print("HG JPD 虚拟打印机");
bar.add(btn);
btn = new JButton("关于");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
builder.about();
bar.add(btn);
Container content = frame.getContentPane();
content.add(bar, BorderLayout.NORTH);
frame.setSize(800, 600);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
frame.addWindowListener(new WindowListener() {
public void windowOpened(WindowEvent e) {}
public void windowClosing(WindowEvent e) {
//frame关闭时做处理
for (int i = 0; i & builder.getXDocCount(); i++) {
XDocIO.write(builder.getXDoc(i), new File("c:/xdoc" + i + ".xdoc"));
} catch (Exception e1) {
JOptionPane.showMessageDialog(null, e1.getMessage());
System.exit(0);
public void windowClosed(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
运行效果:
浏览: 214278 次
来自: 北京
求您写的XDocBuilder的各种jar包,之前的连接我都打 ...
推荐用StratoIO打印控件,支持网页、URL、图片、PD、 ...
不过,官网的文档还可以,有例子
举个简单的例子,http://xdoc.iteye.com/b ...
这个是个好东西,只是在使用过程中,文档太少了,主要是xdoc ...
(window.slotbydup=window.slotbydup || []).push({
id: '4773203',
container: s,
size: '200,200',
display: 'inlay-fix'JAVA&Graphics画图(生成文字水印)
主要使用java中的Graphics2D类。具体代码如下:
import java.awt.C
import java.awt.F
import java.awt.Graphics2D;
import java.awt.RenderingH
import java.awt.font.FontRenderC
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedI
import java.io.F
import java.io.IOE
import javax.imageio.ImageIO;
public class ImgCreate {
&&& public
String create(String str, String filePath, int width, int height)
&&& String
fileName = System.currentTimeMillis() + ".jpg";
&&& String path
= filePath + "/" + fileN
&&& File file =
new File(path);
BufferedImage bi = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
&&& Graphics2D
g2 = (Graphics2D) bi.getGraphics();
g2.setBackground(Color.WHITE);
g2.clearRect(0, 0, width, height);
&&& Font font =
new Font("黑体", Font.BOLD, 25);
g2.setFont(font);
g2.setPaint(Color.RED);
FontRenderContext context = g2.getFontRenderContext();
&&& Rectangle2D
bounds = font.getStringBounds(str, context);
&&& double x =
(width - bounds.getWidth()) / 2;
&&& double y =
(height - bounds.getHeight()) / 2;
&&& double
ascent = -bounds.getY();
&&& double baseY
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.drawString(str, (int) x, (int) baseY);
ImageIO.write(bi, "jpg", file);
&&& } catch
(IOException e) {
e.printStackTrace();
&&& return
file.getPath();
&&& public
static void main(String[] args) {
&&& ImgCreate
create = new ImgCreate();
System.out.println(create.create("中华人民共和国万岁!", "c:/", 500,
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。Java实现简易画图程序_百度文库
您的浏览器Javascript被禁用,需开启后体验完整功能,
赠送免券下载特权
10W篇文档免费专享
部分付费文档8折起
每天抽奖多种福利
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
Java实现简易画图程序
&&用Java实现简易的画图程序
阅读已结束,下载本文需要
想免费下载本文?
定制HR最喜欢的简历
下载文档到电脑,同时保存到云知识,更方便管理
加入VIP
还剩32页未读,
定制HR最喜欢的简历
你可能喜欢书山有路勤为径,学海无涯苦作舟。
一个用JAVA写的画图程序
功能类似WINDOWS的画图程序,代码比较规范。对于刚刚接触图形界面开发的人很有帮助。(对我帮助也很大)import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;public class MiniDrawPad extends JFrame {
private ObjectInputS
private ObjectOutputS
private JButton choices[];
private String names[] = {
"fCircle",
"RoundRect",
private String styleNames[] = {
" 宋体 ", " 隶书 ", " 华文彩云 ", " 仿宋_GB2312 ", " 华文行楷 ",
" 方正舒体 ", " Times New Roman ", " Serif ", " Monospaced ",
" SonsSerif ", " Garamond "
private Icon items[];
private String tipText[] = {
"Draw a new picture",
"Open a saved picture",
"Save current drawing",
"Draw at will",
"Draw a straight line",
"Draw a rectangle",
"Fill a ractangle",
"Draw an oval",
"Fill an oval",
"Draw a circle",
"Fill a circle",
"Draw a round rectangle",
"Fill a round rectangle",
"Erase at will",
"Choose current drawing color",
"Set current drawing stroke",
"Write down what u want"
JToolBar buttonP
private JLabel statusB
private DrawPanel drawingA
private int width = 800,
height = 550;
drawings[] itemList = new drawings[5000];
private int currentChoice = 3;
int index = 0;
private Color color = Color.
int R, G, B;
int f1, f2;
String style1;
private float stroke = 1.0f;
JCheckBox bold,
public MiniDrawPad()
super("Drawing Pad");
JMenuBar bar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
fileMenu.setMnemonic('F');
JMenuItem newItem = new JMenuItem("New");
newItem.setMnemonic('N');
newItem.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
newFile();
fileMenu.add(newItem);
JMenuItem saveItem = new JMenuItem("Save");
saveItem.setMnemonic('S');
saveItem.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
saveFile();
fileMenu.add(saveItem);
JMenuItem loadItem = new JMenuItem("Load");
loadItem.setMnemonic('L');
loadItem.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
loadFile();
fileMenu.add(loadItem);
fileMenu.addSeparator();
JMenuItem exitItem = new JMenuItem("Exit");
exitItem.setMnemonic('X');
exitItem.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
fileMenu.add(exitItem);
bar.add(fileMenu);
JMenu colorMenu = new JMenu("Color");
colorMenu.setMnemonic('C');
JMenuItem colorItem = new JMenuItem("Choose Color");
colorItem.setMnemonic('O');
colorItem.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
chooseColor();
colorMenu.add(colorItem);
bar.add(colorMenu);
JMenu strokeMenu = new JMenu("Stroke");
strokeMenu.setMnemonic('S');
JMenuItem strokeItem = new JMenuItem("Set Stroke");
strokeItem.setMnemonic('K');
strokeItem.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
setStroke();
strokeMenu.add(strokeItem);
bar.add(strokeMenu);
JMenu helpMenu = new JMenu("Help");
helpMenu.setMnemonic('H');
JMenuItem aboutItem = new JMenuItem("About this Drawing Pad!");
aboutItem.setMnemonic('A');
aboutItem.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null,
"This is a mini drawing pad!/nCopyright (c) 2002 Tsinghua University ",
" 画图板程序说明 ",
JOptionPane.INFORMATION_MESSAGE);
helpMenu.add(aboutItem);
bar.add(helpMenu);
items = new ImageIcon[names.length];
drawingArea = new DrawPanel();
choices = new JButton[names.length];
buttonPanel = new JToolBar(JToolBar.VERTICAL);
buttonPanel = new JToolBar(JToolBar.HORIZONTAL);
ButtonHandler handler = new ButtonHandler();
ButtonHandler1 handler1 = new ButtonHandler1();
for (int i = 0; i & choices. i++) {
items[i] = new ImageIcon(names[i] + ".gif");
choices[i] = new JButton("", items[i]);
choices[i].setToolTipText(tipText[i]);
buttonPanel.add(choices[i]);
for (int i = 3; i & choices.length - 3; i++) {
choices[i].addActionListener(handler);
choices[0].addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
newFile();
choices[1].addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
loadFile();
choices[2].addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
saveFile();
choices[choices.length - 3].addActionListener(handler1);
choices[choices.length - 2].addActionListener(handler1);
choices[choices.length - 1].addActionListener(handler1);
styles = new JComboBox(styleNames);
styles.setMaximumRowCount(8);
styles.addItemListener(
new ItemListener() {
public void itemStateChanged(ItemEvent e) {
style1 = styleNames[styles.getSelectedIndex()];
bold = new JCheckBox("BOLD");
italic = new JCheckBox("ITALIC");
checkBoxHandler cHandler = new checkBoxHandler();
bold.addItemListener(cHandler);
italic.addItemListener(cHandler);
JPanel wordPanel = new JPanel();
buttonPanel.add(bold);
buttonPanel.add(italic);
buttonPanel.add(styles);
styles.setMinimumSize(new Dimension(50, 20));
styles.setMaximumSize(new Dimension(100, 20));
Container c = getContentPane();
super.setJMenuBar(bar);
c.add(buttonPanel, BorderLayout.NORTH);
c.add(drawingArea, BorderLayout.CENTER);
statusBar = new JLabel();
c.add(statusBar, BorderLayout.SOUTH);
statusBar.setText("
Welcome To The Little Drawing Pad!!!
createNewItem();
setSize(width, height);
public class ButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent e) {
for (int j = 3; j & choices.length - 3; j++) {
if (e.getSource() == choices[j]) {
currentChoice =
createNewItem();
repaint();
public class ButtonHandler1 implements ActionListener {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == choices[choices.length - 3]) {
chooseColor();
if (e.getSource() == choices[choices.length - 2]) {
setStroke();
if (e.getSource() == choices[choices.length - 1]) {
JOptionPane.showMessageDialog(null,
"Please hit the drawing pad to choose the word input position",
"Hint", JOptionPane.INFORMATION_MESSAGE);
currentChoice = 14;
createNewItem();
repaint();
class mouseA extends MouseAdapter {
public void mousePressed(MouseEvent e) {
statusBar.setText("
Mouse Pressed @:[" + e.getX() +
", " + e.getY() + "]");
itemList[index].x1 = itemList[index].x2 = e.getX();
itemList[index].y1 = itemList[index].y2 = e.getY();
if (currentChoice == 3 || currentChoice == 13) {
itemList[index].x1 = itemList[index].x2 = e.getX();
itemList[index].y1 = itemList[index].y2 = e.getY();
createNewItem();
if (currentChoice == 14) {
itemList[index].x1 = e.getX();
itemList[index].y1 = e.getY();
input = JOptionPane.showInputDialog(
"Please input the text you want!");
itemList[index].s1 =
itemList[index].x2 = f1;
itemList[index].y2 = f2;
itemList[index].s2 = style1;
currentChoice = 14;
createNewItem();
drawingArea.repaint();
public void mouseReleased(MouseEvent e) {
statusBar.setText("
Mouse Released @:[" + e.getX() +
", " + e.getY() + "]");
if (currentChoice == 3 || currentChoice == 13) {
itemList[index].x1 = e.getX();
itemList[index].y1 = e.getY();
itemList[index].x2 = e.getX();
itemList[index].y2 = e.getY();
repaint();
createNewItem();
public void mouseEntered(MouseEvent e) {
statusBar.setText("
Mouse Entered @:[" + e.getX() +
", " + e.getY() + "]");
public void mouseExited(MouseEvent e) {
statusBar.setText("
Mouse Exited @:[" + e.getX() +
", " + e.getY() + "]");
class mouseB extends MouseMotionAdapter {
public void mouseDragged(MouseEvent e) {
statusBar.setText("
Mouse Dragged @:[" + e.getX() +
", " + e.getY() + "]");
if (currentChoice == 3 || currentChoice == 13) {
itemList[index - 1].x1 = itemList[index].x2 = itemList[index].x1 = e.getX();
itemList[index - 1].y1 = itemList[index].y2 = itemList[index].y1 = e.getY();
createNewItem();
itemList[index].x2 = e.getX();
itemList[index].y2 = e.getY();
repaint();
public void mouseMoved(MouseEvent e) {
statusBar.setText("
Mouse Moved @:[" + e.getX() +
", " + e.getY() + "]");
private class checkBoxHandler implements ItemListener {
public void itemStateChanged(ItemEvent e) {
if (e.getSource() == bold) {
if (e.getStateChange() == ItemEvent.SELECTED) {
f1 = Font.BOLD;
f1 = Font.PLAIN;
if (e.getSource() == italic) {
if (e.getStateChange() == ItemEvent.SELECTED) {
f2 = Font.ITALIC;
f2 = Font.PLAIN;
class DrawPanel extends JPanel {
public DrawPanel() {
setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
setBackground(Color.white);
addMouseListener(new mouseA());
addMouseMotionListener(new mouseB());
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D)
int j = 0;
while (j &= index) {
draw(g2d, itemList[j]);
void draw(Graphics2D g2d, drawings i) {
i.draw(g2d);
void createNewItem() {
if (currentChoice == 14)
drawingArea.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
drawingArea.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
switch (currentChoice) {
itemList[index] = new Pencil();
itemList[index] = new Line();
itemList[index] = new Rect();
itemList[index] = new fillRect();
itemList[index] = new Oval();
itemList[index] = new fillOval();
itemList[index] = new Circle();
itemList[index] = new fillCircle();
itemList[index] = new RoundRect();
itemList[index] = new fillRoundRect();
itemList[index] = new Rubber();
itemList[index] = new Word();
itemList[index].type = currentC
itemList[index].R = R;
itemList[index].G = G;
itemList[index].B = B;
itemList[index].stroke =
public void chooseColor() {
color = JColorChooser.showDialog(MiniDrawPad.this,
"Choose a color", color);
R = color.getRed();
G = color.getGreen();
B = color.getBlue();
itemList[index].R = R;
itemList[index].G = G;
itemList[index].B = B;
public void setStroke() {
input = JOptionPane.showInputDialog(
"Please input a float stroke value! ( &0 )");
stroke = Float.parseFloat(input);
itemList[index].stroke =
public void saveFile() {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int result = fileChooser.showSaveDialog(this);
if (result == JFileChooser.CANCEL_OPTION) {
File fileName = fileChooser.getSelectedFile();
fileName.canWrite();
if (fileName == null || fileName.getName().equals("")) {
JOptionPane.showMessageDialog(fileChooser, "Invalid File Name",
"Invalid File Name", JOptionPane.ERROR_MESSAGE);
fileName.delete();
FileOutputStream fos = new FileOutputStream(fileName);
output = new ObjectOutputStream(fos);
output.writeInt(index);
for (int i = 0; i & i++) {
drawings p = itemList[i];
output.writeObject(p);
output.flush();
output.close();
fos.close();
} catch (IOException ioe) {
ioe.printStackTrace();
public void loadFile() {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int result = fileChooser.showOpenDialog(this);
if (result == JFileChooser.CANCEL_OPTION) {
File fileName = fileChooser.getSelectedFile();
fileName.canRead();
if (fileName == null || fileName.getName().equals("")) {
JOptionPane.showMessageDialog(fileChooser, "Invalid File Name",
"Invalid File Name", JOptionPane.ERROR_MESSAGE);
FileInputStream fis = new FileInputStream(fileName);
input = new ObjectInputStream(fis);
drawings inputR
int countNumber = 0;
countNumber = input.readInt();
for (index = 0; index & countN index++) {
inputRecord = (drawings) input.readObject();
itemList[index] = inputR
createNewItem();
input.close();
repaint();
} catch (EOFException endofFileException) {
JOptionPane.showMessageDialog(this, "no more record in file",
"class not found", JOptionPane.ERROR_MESSAGE);
} catch (ClassNotFoundException classNotFoundException) {
JOptionPane.showMessageDialog(this, "Unable to Create Object",
"end of file", JOptionPane.ERROR_MESSAGE);
} catch (IOException ioException) {
JOptionPane.showMessageDialog(this, "error during read from file",
"read Error", JOptionPane.ERROR_MESSAGE);
public void newFile() {
index = 0;
currentChoice = 3;
color = Color.
stroke = 1.0f;
createNewItem();
repaint();
public static void main(String args[]) {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
MiniDrawPad newPad = new MiniDrawPad();
newPad.addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}}class drawings implements Serializable{
int x1, y1, x2, y2;
int R, G, B;
String s1;
String s2;
void draw(Graphics2D g2d) {
}}class Line extends drawings {
void draw(Graphics2D g2d) {
g2d.setPaint(new Color(R, G, B));
g2d.setStroke(new BasicStroke(stroke,
BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
g2d.drawLine(x1, y1, x2, y2);
}}class Rect extends drawings{
void draw(Graphics2D g2d) {
g2d.setPaint(new Color(R, G, B));
g2d.setStroke(new BasicStroke(stroke));
g2d.drawRect(Math.min(x1, x2), Math.min(y1, y2),
Math.abs(x1 - x2), Math.abs(y1 - y2));
}}class fillRect extends drawings{
void draw(Graphics2D g2d) {
g2d.setPaint(new Color(R, G, B));
g2d.setStroke(new BasicStroke(stroke));
g2d.fillRect(Math.min(x1, x2), Math.min(y1, y2),
Math.abs(x1 - x2), Math.abs(y1 - y2));
}}class Oval extends drawings{
void draw(Graphics2D g2d) {
g2d.setPaint(new Color(R, G, B));
g2d.setStroke(new BasicStroke(stroke));
g2d.drawOval(Math.min(x1, x2), Math.min(y1, y2),
Math.abs(x1 - x2), Math.abs(y1 - y2));
}}class fillOval extends drawings{
void draw(Graphics2D g2d) {
g2d.setPaint(new Color(R, G, B));
g2d.setStroke(new BasicStroke(stroke));
g2d.fillOval(Math.min(x1, x2), Math.min(y1, y2),
Math.abs(x1 - x2), Math.abs(y1 - y2));
}}class Circle extends drawings{
void draw(Graphics2D g2d) {
g2d.setPaint(new Color(R, G, B));
g2d.setStroke(new BasicStroke(stroke));
g2d.drawOval(Math.min(x1, x2), Math.min(y1, y2),
Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2)),
Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2)));
}}class fillCircle extends drawings{
void draw(Graphics2D g2d) {
g2d.setPaint(new Color(R, G, B));
g2d.setStroke(new BasicStroke(stroke));
g2d.fillOval(Math.min(x1, x2), Math.min(y1, y2),
Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2)),
Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2)));
}}class RoundRect extends drawings{
void draw(Graphics2D g2d) {
g2d.setPaint(new Color(R, G, B));
g2d.setStroke(new BasicStroke(stroke));
g2d.drawRoundRect(Math.min(x1, x2), Math.min(y1, y2),
Math.abs(x1 - x2), Math.abs(y1 - y2),
}}class fillRoundRect extends drawings{
void draw(Graphics2D g2d) {
g2d.setPaint(new Color(R, G, B));
g2d.setStroke(new BasicStroke(stroke));
g2d.fillRoundRect(Math.min(x1, x2), Math.min(y1, y2),
Math.abs(x1 - x2), Math.abs(y1 - y2),
}}class Pencil extends drawings{
void draw(Graphics2D g2d) {
g2d.setPaint(new Color(R, G, B));
g2d.setStroke(new BasicStroke(stroke,
BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
g2d.drawLine(x1, y1, x2, y2);
}}class Rubber extends drawings{
void draw(Graphics2D g2d) {
g2d.setPaint(new Color(255, 255, 255));
g2d.setStroke(new BasicStroke(stroke + 4,
BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
g2d.drawLine(x1, y1, x2, y2);
}}class Word extends drawings{
void draw(Graphics2D g2d) {
g2d.setPaint(new Color(R, G, B));
g2d.setFont(new Font(s2, x2 + y2, ((int) stroke) * 18));
if (s1 != null) {
g2d.drawString(s1, x1, y1);
没有更多推荐了,
加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!}

我要回帖

更多关于 word画图怎么添加文字 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信