Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-09-2010, 12:57 AM
Member
 
Join Date: Jan 2010
Posts: 15
Rep Power: 0
sunolinu is on a distinguished road
Default hove i create arrow?
what is command of creating arrow?
thaks
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 02-09-2010, 01:00 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,408
Rep Power: 8
Fubarable is on a distinguished road
Default
Originally Posted by sunolinu View Post
what is command of creating arrow?
thaks
Please provide us with enough relevant information so that your question is in fact answerable. Much luck.
__________________
When posting code, please use code tags so that your code is readable. To do this, place the tag [code] before your block of code and [/code] after your block of code.
How to use Code Tags
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 02-09-2010, 02:39 AM
Member
 
Join Date: Jan 2010
Posts: 15
Rep Power: 0
sunolinu is on a distinguished road
Default
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 , ...
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 02-10-2010, 08:01 PM
Darryl.Burke's Avatar
Senior Member
 
Join Date: Sep 2008
Location: Madgaon, Goa, India
Posts: 722
Rep Power: 2
Darryl.Burke is on a distinguished road
Default
And how do you plan to detect a mouse click without a mouse listener?

db
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 02-11-2010, 04:24 AM
Member
 
Join Date: Jan 2010
Posts: 15
Rep Power: 0
sunolinu is on a distinguished road
Default
Originally Posted by Darryl.Burke View Post
And how do you plan to detect a mouse click without a mouse listener?

db
my means that i know how create mouse listener and ...
but what cammand of arrow for example for fill rectangle
the command is g.fillRect(200,200,10,10)
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 02-12-2010, 06:32 AM
hardwired's Avatar
Senior Member
 
Join Date: Jul 2007
Posts: 1,577
Rep Power: 4
hardwired is on a distinguished road
Default
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);
    }
}
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 02-19-2010, 02:50 AM
Member
 
Join Date: Jan 2010
Posts: 15
Rep Power: 0
sunolinu is on a distinguished road
Default
very excellent thanks you hardwired
how i narrow it with like a line
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 02-19-2010, 11:50 PM
hardwired's Avatar
Senior Member
 
Join Date: Jul 2007
Posts: 1,577
Rep Power: 4
hardwired is on a distinguished road
Default
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.x-1.5, p1.y-1.5, 4, 4));
        g2.fill(new Ellipse2D.Double(p2.x-1.5, p2.y-1.5, 4, 4));
        g2.setPaint(Color.blue);
        g2.draw(new Ellipse2D.Double(p1.x-dia/2, p1.y-dia/2, dia, dia));
        g2.draw(new Ellipse2D.Double(p2.x-dia/2, p2.y-dia/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(theta-phi);
        y = y2 + barb*Math.sin(theta-phi);
        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);
    }
}
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 02-20-2010, 02:20 AM
Member
 
Join Date: Jan 2010
Posts: 15
Rep Power: 0
sunolinu is on a distinguished road
Default
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 graphically

Last edited by sunolinu; 02-20-2010 at 02:22 AM.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Arrow Button Example Java Tip SWT 0 07-11-2008 05:44 PM
How to navigate a SWT table cells with arrow keys Java Tip SWT 0 07-11-2008 04:07 PM
how u rotate the arrow mark as the line moves accordingly sandhyau AWT / Swing 1 02-17-2008 12:22 AM
how to draw an arrow mark using java swing sandhyau AWT / Swing 5 02-07-2008 12:52 PM
Draw an arrow Albert SWT / JFace 3 02-01-2008 09:11 AM


All times are GMT +2. The time now is 01:46 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org