I think everyone understands your frustration.  On the other side, the
frustration is that you appear to be saying "I want to do something I don't
know how to do and when I do it, it doesn't work."

    All components can be drawn on.  I'm including a short application that
draws directly to a Frame.  If you want it to be just like an applet, change
the layout to FlowLayout to replace Frame's default BorderLayout.  Applet
descends from Panel, BTW, so a setSize() or other sizing directly sizes the
panel.

    Most programs don't draw directly to the Frame because the drawing
should be limited to a specific area or component.  However, the override of
Frame's paint() in the program below is the same for every other component.
So, the ( very ) bare essence is that paint() for the component ( like a
Panel or Canvas ) is overridden, the component is added to a container -
like Frame - and  either specifically sized or possibly sized by the layout
manager ( BorderLayout will stretch to size depending on the area,
FlowLayout will always use the component's natural size, which may be zero
if not set. )

    There are tons of books and articles available, as others have
mentioned, and I mentioned the AWT trail archive from the Java Tutorial.
It's true that lots of examples use applets, but there are application
examples too. Start with something very basic and build on it.  In the long
run you will be better off using Swing, but it uses many of the same
concepts.  HTH,


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

public class frameDraw extends    Frame
                       implements WindowListener
{
  public frameDraw()
  {
    super( "frameDraw" );

    addWindowListener( this );
    setSize( 200, 200 );
    show();
  } // end constructor

  public void paint( Graphics g )
  {
    super.paint( g );
    g.drawString( "Hello!", 50, 100 );
  }

// Window Listener Implementation
  public void windowOpened(WindowEvent e) {}
   public void windowClosing(WindowEvent e)
   {
     dispose();
     System.exit(0);
   }
  public void windowClosed(WindowEvent e) {}
  public void windowIconified(WindowEvent e) {}
  public void windowDeiconified(WindowEvent e) {}
  public void windowActivated(WindowEvent e) {}
  public void windowDeactivated(WindowEvent e) {}
// End Window Listener Implementation

  public static void main(String[] args)
  {
    new frameDraw();
  }  // end main

} // end class frameDraw


                                                  Joe Sam

Joe Sam Shirah -        http://www.conceptgo.com
conceptGO         -        Consulting/Development/Outsourcing
Java Filter Forum:       http://www.ibm.com/developerworks/java/
Just the JDBC FAQs: http://www.jguru.com/faq/JDBC
Going International?    http://www.jguru.com/faq/I18N
Que Java400?             http://www.jguru.com/faq/Java400


----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 25, 2004 8:26 PM
Subject: Re: [Juglist] drawing on a canvas


> nothing in my life has ever been as frustrating as squeezing paint out of
> java in an application. I did it once. I have the code around here
someplace. I'm
> sorry I spoke ill of java. I really do love the language. java needs a
> command like "paint the goddamned thing" that overrides all of its
neurotic little
> hesitations. ironically, painting in an applet is a breeze. applications
just
> present me with too many hoops. I can  never remember what or where they
are
> and all the examples I can find are for applets. Just pissed off at a
silly
> quirk in a great language. forgive me.
>


----------------------------------------------------------------------------
----


> _______________________________________________
> Juglist mailing list
> [EMAIL PROTECTED]
> http://trijug.org/mailman/listinfo/juglist_trijug.org
>




_______________________________________________
Juglist mailing list
[EMAIL PROTECTED]
http://trijug.org/mailman/listinfo/juglist_trijug.org

Reply via email to