Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Simple java.awt questions

Reply
Thread Tools

Simple java.awt questions

 
 
morc
Guest
Posts: n/a
 
      02-27-2006
hey.
well im trying ot make graphs wiht this but im gona keep my question
very simple.

well first off im graphicaly retarded. so be easy. =)

anyways i wana start by just drawing a line. I know u do it in method
paint.
I'm using JBuilder and i don't know how to compile an run something so
that it displays the drawing i thought i made. for example i have a
class that extends canvas. It's only methods are the Constructor and
Paint(Graphics g).

How do i actualy paint it ont he canvas and display it?

i know it sounds too simple to be true... but like i said im graphicaly
an idiot.

thanks alot for any help
-morc

 
Reply With Quote
 
 
 
 
Knute Johnson
Guest
Posts: n/a
 
      02-27-2006
morc wrote:
> hey.
> well im trying ot make graphs wiht this but im gona keep my question
> very simple.
>
> well first off im graphicaly retarded. so be easy. =)
>
> anyways i wana start by just drawing a line. I know u do it in method
> paint.
> I'm using JBuilder and i don't know how to compile an run something so
> that it displays the drawing i thought i made. for example i have a
> class that extends canvas. It's only methods are the Constructor and
> Paint(Graphics g).
>
> How do i actualy paint it ont he canvas and display it?
>
> i know it sounds too simple to be true... but like i said im graphicaly
> an idiot.
>
> thanks alot for any help
> -morc
>


Here is how you extend Canvas to draw a line on it. You might be better
served by using a text editor and creating all of your own code at this
stage of your experience.

import java.awt.*;
import java.awt.event.*;

public class Test extends Canvas {
public Test() {
setPreferredSize(new Dimension(400,300));
}

public void paint(Graphics g) {
g.drawLine(0,0,400,300);
}

public static void main(String[] args) {
Frame f = new Frame();
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});
Test t = new Test();
f.add(t,BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
}

--

Knute Johnson
email s/nospam/knute/
 
Reply With Quote
 
 
 
 
morc
Guest
Posts: n/a
 
      02-27-2006
hey

i pasted ur code into a new java file called. Test.java and ran using
defaults in JBuilder and i got this:

java.lang.NoClassDefFoundError: Test

Exception in thread "main"


this is what i meant. i don't know how to compile/view/test anything i
do graphicaly. How do i see the line being drawn?

thanks alot for the help.

 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      02-27-2006

"morc" <> wrote in message
news: oups.com...
> hey
>
> i pasted ur code into a new java file called. Test.java and ran using
> defaults in JBuilder and i got this:
>
> java.lang.NoClassDefFoundError: Test
>
> Exception in thread "main"
>
>
> this is what i meant. i don't know how to compile/view/test anything i
> do graphicaly. How do i see the line being drawn?


See
http://mindprod.com/jgloss/runerrorm...SDEFFOUNDERROR

- Oliver

 
Reply With Quote
 
Knute Johnson
Guest
Posts: n/a
 
      02-28-2006
morc wrote:
> hey
>
> i pasted ur code into a new java file called. Test.java and ran using
> defaults in JBuilder and i got this:
>
> java.lang.NoClassDefFoundError: Test
>
> Exception in thread "main"
>
>
> this is what i meant. i don't know how to compile/view/test anything i
> do graphicaly. How do i see the line being drawn?
>
> thanks alot for the help.
>


Well I can't help you with JBuilder because I don't use those things.
If you have the JDK installed on your computer then compile the program
I gave you with;

javac Test.java

and run it with;

java Test

If you need help installing the compiler post again.



--

Knute Johnson
email s/nospam/knute/
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple VB.Net / webservice requirement (but not simple for me....) Dave E ASP .Net 7 01-11-2006 02:07 PM
Simple Question - Simple Answer? Daniel Frey XML 4 01-12-2005 04:25 PM
Re: Simple Simple question!!! Kevin Spencer ASP .Net 0 06-25-2004 05:25 PM
Re: Simple Simple question!!! ashelley@inlandkwpp.com ASP .Net 0 06-25-2004 04:18 PM
Re: Questions....questions....questions Patrick Michael A+ Certification 0 06-16-2004 04:53 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57