All pastes #9433 Raw Edit

Mine!

public java v1 · immutable
#9433 ·published 2005-04-12 18:43 UTC
rendered paste body
/* * Main.java * * Created on April 9, 2005, 7:18 AM */package genpath_trying;/** * * @author http://www.apl.jhu.edu/~hall/java/Java2D-Tutorial.html#Java2D-Tutorial-Fonts etc. */import java.awt.*;import java.awt.event.*;import java.awt.geom.*;import javax.swing.*;public class GenPathTrying  extends JFrame {float dashes[] = { 10, 2 }; //for the yellow line   // set window's title bar String and background color   public GenPathTrying ()   {      super( "Drawing a GeneralPath over other stuff." );      getContentPane().setBackground( Color.gray );         }    // draw general paths   public void paint( Graphics g )   {          drawLiners( g );//      drawTheText( g );   }            /**   Trying for TEXT */   /***************************************this is the problem area, and/or METHOD */      //** the APP flickers constantly, when this is enabled */      //Graphics2D g2d = ( Graphics2D ) g;    /////////////////////////////////////////////COMMENT the below line ?!?! and you will see that the APP functions (without TXT) // ?!?!     drawTheText(graphics2D);     /**   Trying for TEXT */            // end method paint       public void drawLiners(Graphics g) {        /////////////////////////////////////////////////////////////////////////////////////////////////////////////              // call superclass' paint method      super.paint( g );      Graphics2D graphics2D = ( Graphics2D ) g;            //these are the x/y variables for the points on the "angleLine"      int xPoints[] =          { 350,220,180,200,250 };      int yPoints[] =          { 60,100,90,80,85};               //////////////////////////////////////////////////////////////////      GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();//    env.getAvailableFontFamilyNames();    graphics2D.setFont(new Font("Goudy Handtooled BT", Font.PLAIN, 100));        graphics2D.setPaint(Color.orange);    graphics2D.drawString("Java 2D", 25, 115);      ////////////////////////////////////////////////////////////////                        //graphics2D.translate( 400, 400 );                  // draw 2D lines in green and yellow      graphics2D.setPaint( Color.green );      graphics2D.draw( new Line2D.Double( 295, 30, 220, 150 ) );            //the yellow line      graphics2D.setPaint( Color.yellow );          graphics2D.setStroke( new BasicStroke(          8, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND,          10, dashes, 0 ) );       graphics2D.draw( new Line2D.Double( 220, 30, 295, 150 ) );                  //set color for the changing line       graphics2D.setPaint( Color.black );      // create a star from a series of points      GeneralPath angleLine = new GeneralPath();                  // set the initial coordinate of the General Path      angleLine.moveTo( xPoints[ 0 ], yPoints[ 0 ] );       //!?!?! the 0 is not COORDS idiot!!! it's the ARRAY value 0!!!!! ?!?!? dammit lol     // create the star--this does not draw the star      for ( int count = 1; count < xPoints.length; count++ )         angleLine.lineTo( xPoints[ count ], yPoints[ count ] );	// close the shape      angleLine.closePath();            // translate the origin to (200, 200)      //graphics2D.translate( 400, 400 );	      graphics2D.fill( angleLine );             /////////////////////////////////////////////////////////////////////////////////////////////////////////////    }    //  protected void drawTheText(Graphics2D graphics2D) {           public void drawTheText(Graphics g) {        Graphics2D graphics2D = ( Graphics2D ) g;             GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();    env.getAvailableFontFamilyNames();    setFont(new Font("Goudy Handtooled BT", Font.PLAIN, 100));        graphics2D.setPaint(Color.orange);    graphics2D.drawString("Java 2D", 25, 215);//     g.setPaint(Color.orange);//    g.drawString("Java 2D", 25, 215);}                // execute application   public static void main( String args[] )   {      GenPathTrying  application = new GenPathTrying ();      application.setDefaultCloseOperation(         JFrame.EXIT_ON_CLOSE );      application.setSize( 425, 170 );      application.setVisible( true );      }}