Ahhh I see what you mean! Ok now that I got this to work I'm pretty sure I can add some basic mouse painting functions without too much issue!
Thanks Norm!
Type: Posts; User: crzybldthrwr
Ahhh I see what you mean! Ok now that I got this to work I'm pretty sure I can add some basic mouse painting functions without too much issue!
Thanks Norm!
Wait a sec, where is the paintComponent method being copied to?
Ah ok i'll do that, be back in a sec!
but where am I copying the drawstring code to?
I'm thinking the issue is because I'm creating that new MyPanel, so it just throws that new 450,450 area in the next available slot
public MouseMotionEventDemo() {
super(new GridLayout(0,1));
blankArea = new BlankArea(Color.YELLOW);
add(blankArea);
textArea = new JTextArea();
...
I got it to work in post 21 :)
But i'd still like the text to be drawn inside the yellow area
1400
so here i'd want it to be in the yellow area
Edit: nevermind I recopied the code from post 12 and it works just like you showed, but Id like the text to be IN the area above the box that shows the coords
in the public void paintComponent I have the drawString try to draw "Custom Panellll" at 100,200
Yup that solved the error! But now that it runs, the text that i have it drawing doesn't show up?
/*
* Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
*
*...
The error is "C:\Users\Chris\Desktop\events-MouseEventDemoProject\events-MouseEventDemoProject\src\events\MouseMotionEventDemo.java:102: error: non-static variable this cannot be referenced from a...
I read that and am working through it, this is what I have so far and I'm getting an error on "frame.add(new MyPanel());"
The error is "non-static variable this cannot be referenced from a static...
I'm pretty sure my paint and drawCoordinates functions are completely wrong, I was just trying things to get it to work
EDIT: heres the BlankArea.Java code, this is needed also
package...
package events;
/*
* MouseMotionEventDemo.java
*
*/
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
void eventOutput(String eventDescription, MouseEvent e) {
textArea.append(eventDescription
+ " (" + e.getX() + "," + e.getY() + ")"
+ " detected on "
...
Should I post the full code of both java files? One just sets the blank area for the applet and the other does all the dirty work
I posted the code in the links, I took out my code because it was basic java stuff, using Graphics G and drawLine using the previous X,Y coords and the current ones
Posting this again since my original post accidentally got removed!
So I'm using these 2 pre-written demo-files:
Java Tutorials Sample Code
Java Tutorials Sample Code
if you go to this...