Results 1 to 1 of 1
Thread: minmum spaning tree
- 04-29-2011, 03:16 PM #1
Member
- Join Date
- Apr 2011
- Posts
- 8
- Rep Power
- 0
minmum spaning tree
Hello
If you allow I want to help in this program
Required of him is when the user presses the mouse is draw a circle
After the completion of the drawing of circles
The user also using the mouse draw the lines between these circles
Similar to what is in this video to clarify
YouTube - applet kruskal blog (applet en internet).wmv
When I worked the program featured the first problem is that he does not paint when you press on the mouse
This is the code that you typed
XML Code:import java.util.ArrayList; import java.awt.*; import java.awt.geom.*; import javax.swing.*; import javax.swing.border.TitledBorder; import java.awt.event.*; import java.awt.geom.*; import java.util.ArrayList; public class TestPanelDrawing2 extends JPanel implements MouseListener,MouseMotionListener { static int x;static int y; static ArrayList<Ellipse2D.Double> vert = new ArrayList<Ellipse2D.Double>(); public void mouseDragged(MouseEvent e) { } public void mouseMoved (MouseEvent e) {} public void mouseClicked(MouseEvent e){ x=e.getX(); y=e.getY(); add(new drowcycle()); } public void mouseEntered(MouseEvent e) {} public void mousePressed(MouseEvent e){} public void mouseReleased(MouseEvent e) {} public void mouseExited(MouseEvent e) {} public TestPanelDrawing2() { addMouseListener(this); addMouseMotionListener(this); } public static void main(String[] args) { TestPanelDrawing2 p = new TestPanelDrawing2(); JFrame frame=new JFrame(); frame.add(p); frame.setTitle("TestPanelDrawing"); frame.setLocationRelativeTo(null); // Center the frame frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(600, 400); frame.setVisible(true); } } class drowcycle extends JPanel { public void paint(Graphics g) { Font r = new Font("SansSerif", Font.BOLD, 16); g.setFont(r); draw(g); } public void draw(Graphics g) { Graphics2D g2 = (Graphics2D) g; super.paint(g); int x1=TestPanelDrawing2.x; int y1=TestPanelDrawing2.y; Ellipse2D.Double a = new Ellipse2D.Double(x1 + 5, y1, 15, 15); TestPanelDrawing2.vert.add(a); g.drawString(" A", x1 + 5, y1); g2.fill(new Ellipse2D.Double(x1, y1, 15, 15)); } } class drowline extends JPanel { public void paint(Graphics g) { Font r = new Font("SansSerif", Font.BOLD, 16); g.setFont(r); draw(g); } public void draw(Graphics g) { Graphics2D g2 = (Graphics2D) g; super.paint(g); int x1=TestPanelDrawing2.x; int y1=TestPanelDrawing2.y; g.drawString(" A", x1 + 5, y1); g2.fill(new Ellipse2D.Double(x1, y1, 15, 15)); } }
Similar Threads
-
KD tree
By izac01 in forum Java AppletsReplies: 2Last Post: 04-07-2011, 06:07 AM -
Data Structures(Binary Search Tree to AVL Tree)ASAP pls
By jfAdik in forum Forum LobbyReplies: 0Last Post: 04-04-2010, 07:40 AM -
2-4 tree
By number22 in forum New To JavaReplies: 3Last Post: 12-09-2009, 03:52 PM -
Creating a Tree and then saving the Tree
By jackmatt2 in forum New To JavaReplies: 0Last Post: 08-22-2009, 12:51 PM -
Need Help With Tree Adt
By avi in forum New To JavaReplies: 0Last Post: 03-20-2008, 03:11 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks