Computer Science Canada calin out to da masters:worked wif java for 2 hrs.Need Help! |
Author: | Homer_simpson [ Sun Feb 08, 2004 11:51 pm ] |
Post subject: | calin out to da masters:worked wif java for 2 hrs.Need Help! |
i've worked with java around 2 hours now... so i know the basics... i tried graphics but appearantly u can only use graphics on a gui window... can somebody show me a sample code that draw a simple line somewhere... |
Author: | Paul [ Mon Feb 09, 2004 2:19 pm ] | ||
Post subject: | |||
I only know how to draw stuff in an applet, where you have to see it with appletviewer. This is how I do it in an applet:
Don't know if this helps you... |
Author: | rizzix [ Mon Feb 09, 2004 3:59 pm ] | ||||||||
Post subject: | |||||||||
extending the example in the swing tutorial I wrote.. In the most simplest possible way I can demonstrate drawing in swing would be this: The Application Class
The DrawView Class (the component on which we will be drawing)
basically your extending a component class (Canvas to be more specific) and overload its public void paint(Graphics g); method. for more information on what methods you can call from the Graphics2D object look up the documentation here and also look up it's super class's (Graphics) documentation here Integrating the DrawView into an applet..
Displaying the applet...
|
Author: | Tony [ Mon Feb 09, 2004 9:31 pm ] |
Post subject: | |
stuff like that just makes you appreciate the simplicity of turing's graphics, doesn't it? ![]() |
Author: | rizzix [ Mon Feb 09, 2004 10:42 pm ] |
Post subject: | |
well the application class and the applet class will mostly be like that example above (with exception to the size of the window) almost all the time. all u need to do is change stuff in ur DrawView class. (which is basically a Jcomponent) and that too usually in the paint() method. |
Author: | Prince [ Mon Feb 09, 2004 10:53 pm ] |
Post subject: | |
tony wrote: stuff like that just makes you appreciate the simplicity of turing's graphics, doesn't it?
![]() im startin to miss turing already lol ![]() |