wie kann ich auf einen Knoten schreiben!

Jamous

Grünschnabel
Hallo zusammen,
ich brauche Hilfe und zwar will auf einen Knoten nach einer Markierung des Knotes schreiben.
wie schaffe es das ?
Code:
package knote;

import java.awt.Color;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class Knoten extends JPanel {

	
	Knoten (){
		super();	
		addMouseListener(new Controller());
		addMouseMotionListener(new Controller());
			
	}
	
	
	
	
	@Override
	public void paintComponent(Graphics g) {
		// TODO Auto-generated method stub
		super.paintComponents(g);
		System.out.println("paint!");
		Graphics2D g2 = (Graphics2D)g;
		g2.drawOval(10, 10, 60, 50);
		g2.drawOval(60, 100, 60, 50);
		g2.drawOval(80, 170, 60, 50);
		g2.drawOval(180, 180, 60, 50);
		
		
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		JFrame f = new JFrame();
		Knoten k = new Knoten();
		f.add(k);
		f.setTitle("Knoten");
		f.setSize(300,300);
		f.setVisible(true);	
		

	}

	
	class Controller implements MouseListener, MouseMotionListener{
		
		Controller(){
		super();	
		}
		
		public void mouseDragged(MouseEvent e) {
			// TODO Auto-generated method stub
			
		}
	
		public void mouseMoved(MouseEvent e) {
			// TODO Auto-generated method stub
			
		}
	
		public void mouseClicked(MouseEvent e) {
			// TODO Auto-generated method stub
			
		}
	
		public void mouseEntered(MouseEvent e) {
			// TODO Auto-generated method stub
			
		}
	
		public void mouseExited(MouseEvent e) {
			// TODO Auto-generated method stub
			
		}
	
		public void mousePressed(MouseEvent e) {
			// TODO Auto-generated method stub	
			System.out.println("pressed!");
			
			
			repaint();
			
		}
	
		public void mouseReleased(MouseEvent e) {
			// TODO Auto-generated method stub
			
		}
		
	}

}
 
Zurück