Results 1 to 9 of 9
Thread: hove i create arrow?
 02082010, 11:57 PM #1Member
 Join Date
 Jan 2010
 Posts
 15
 Rep Power
 0

 02092010, 01:39 AM #3Member
 Join Date
 Jan 2010
 Posts
 15
 Rep Power
 0
i have some shape like fill circle i want when i click on shape one then clicking
on another shape the arrow shape create between two shapes
arrow = >
i want just arrow command not mouse listner , ...
 02102010, 07:01 PM #4
And how do you plan to detect a mouse click without a mouse listener?
db
 02112010, 03:24 AM #5Member
 Join Date
 Jan 2010
 Posts
 15
 Rep Power
 0
 02122010, 05:32 AM #6Java Code:
import java.awt.*; import java.awt.geom.Path2D; import javax.swing.*; public class Test extends JPanel { protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Path2D.Double path = new Path2D.Double(); path.moveTo(100, 125); path.lineTo(300, 125); path.lineTo(300, 100); path.lineTo(350, 155); path.lineTo(300, 210); path.lineTo(300, 185); path.lineTo(100, 185); path.lineTo(100, 125); g2.setPaint(Color.blue); g2.fill(path); } public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new Test()); f.setSize(400,400); f.setLocation(200,200); f.setVisible(true); } }
 02192010, 01:50 AM #7Member
 Join Date
 Jan 2010
 Posts
 15
 Rep Power
 0
very excellent thanks you hardwired
how i narrow it with like a line
 02192010, 10:50 PM #8Java Code:
import java.awt.*; import java.awt.geom.*; import javax.swing.*; public class TrigArrow extends JPanel { Point p1 = new Point(100,100); Point p2 = new Point(300,300); double dia = 25.0; double barb = 15.0; double phi = Math.toRadians(20); protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(Color.red); g2.fill(new Ellipse2D.Double(p1.x1.5, p1.y1.5, 4, 4)); g2.fill(new Ellipse2D.Double(p2.x1.5, p2.y1.5, 4, 4)); g2.setPaint(Color.blue); g2.draw(new Ellipse2D.Double(p1.xdia/2, p1.ydia/2, dia, dia)); g2.draw(new Ellipse2D.Double(p2.xdia/2, p2.ydia/2, dia, dia)); double dy = p2.y  p1.y; double dx = p2.x  p1.x; double theta = Math.atan2(dy, dx); double x1 = p1.x + (dia/2)*Math.cos(theta); double y1 = p1.y + (dia/2)*Math.sin(theta); theta += Math.PI; double x2 = p2.x + (dia/2)*Math.cos(theta); double y2 = p2.y + (dia/2)*Math.sin(theta); g2.setPaint(Color.green.darker()); g2.draw(new Line2D.Double(x1, y1, x2, y2)); double x = x2 + barb*Math.cos(theta+phi); double y = y2 + barb*Math.sin(theta+phi); g2.draw(new Line2D.Double(x2, y2, x, y)); x = x2 + barb*Math.cos(thetaphi); y = y2 + barb*Math.sin(thetaphi); g2.draw(new Line2D.Double(x2, y2, x, y)); } public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new TrigArrow()); f.setSize(400,400); f.setLocation(100,100); f.setVisible(true); } }
 02202010, 01:20 AM #9Member
 Join Date
 Jan 2010
 Posts
 15
 Rep Power
 0
very thank you , it is itself and excellent > best thanks for all > i next add solved
i have another question i want to create tape of turing machine graphically i should use what ?
see here is question :
how i can to create tape of turing machine graphicallyLast edited by sunolinu; 02202010 at 01:22 AM.
Similar Threads

Arrow Button Example
By Java Tip in forum SWT TipsReplies: 0Last Post: 07112008, 04:44 PM 
How to navigate a SWT table cells with arrow keys
By Java Tip in forum SWT TipsReplies: 0Last Post: 07112008, 03:07 PM 
how u rotate the arrow mark as the line moves accordingly
By sandhyau in forum AWT / SwingReplies: 1Last Post: 02162008, 11:22 PM 
how to draw an arrow mark using java swing
By sandhyau in forum AWT / SwingReplies: 5Last Post: 02072008, 11:52 AM 
Draw an arrow
By Albert in forum SWT / JFaceReplies: 3Last Post: 02012008, 08:11 AM
Bookmarks