• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to create a node like a basic shape in visio diagram?  RSS feed

 
maomao chen
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I need to develop a java application to create flow model.
The basic frame just like the viso, you can design a flow diagram.My question is How to make the shape editable, in visio, you can type text on the shape, if the text is too lage, it will out of the shape, and when you resize the shape,the text will resize too,out or in the shape.How can I use java to realize it?
if you have some sourcecode like it,it will be great.
thank you.
regards.
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd suggest you become very familiar with Swing, especially the graphics portion. Once you've figured out how to create a custom Swing component (extend JComponent, override paint() or paintComponent()), how to make it editable (have a mouse listener or a pop-up menu change the state of the component to an editable one), then it will be a simple task to take the text entered, find out it's size using the font settings and FontMetrics.stringWidth() and adjust the component's size accordingly.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!