Results 1 to 3 of 3
  1. #1
    vasanthii is offline Member
    Join Date
    Apr 2012
    Posts
    1
    Rep Power
    0

    Default No output with this code

    Quote Originally Posted by Kakuzoo View Post
    Instead of that try this
    /*
    <applet code="WelcomeApplet" height=400 width=400>
    </applet>
    */

    import java.awt.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class WelcomeApplet extends JApplet
    {
    public void init(){}
    public void paint(Graphics g)
    {
    super.paint(g);
    int xPoints[] = {-10,0,10};
    int yPoints[] = {0,-50,0};
    Graphics2D g2d = (Graphics2D) g;
    GeneralPath triangle = new GeneralPath();
    triangle.moveTo(xPoints[0],yPoints[0]);
    for (int k = 1; k<xPoints.length;k++)
    triangle.lineTo(xPoints[k], yPoints[k]);
    triangle.closePath();
    g2d.translate(200,200);
    g2d.setColor(Color.gray);
    g2d.fill(triangle);
    g2d.rotate(Math.PI/4.0);
    g2d.fill(triangle);
    g2d.rotate(Math.PI/4.0);
    }
    }

    And save this as WelcomeApplet.html file.
    Now run this. It will definitely work. Believe it
    I didn't get o/p wid dis code also....I am not getting only applet based programs.......... why i am not getting.
    and i am using ubuntu as os..
    import java.awt.event.*;
    import java.awt.*;
    import java.applet.*;
    public class Mouse extends Applet implements MouseListener
    {
    int x=0,y=0;
    String msg="";
    Graphics g;
    public void init()
    {
    //addMouseMotionListener(this);
    addMouseListener(this);
    }
    public void mouseEntered(MouseEvent me)
    {
    x=0;y=20;
    msg="entered";
    repaint();
    }
    public void mouseExited(MouseEvent me)
    {
    x=0;y=20;
    msg="exited";
    repaint();
    }
    public void mouseClicked(MouseEvent me)
    {
    x=0;y=20;
    msg="clicked";
    repaint();
    }
    public void mousePressed(MouseEvent me)
    {
    x=0;y=20;
    msg="pressed";
    repaint();
    }
    public void mouseReleased(MouseEvent me)
    {
    x=0;y=20;
    msg="released";
    repaint();
    }
    public void paint(Graphics g)
    {
    g.drawString(msg,x,y);
    }
    }
    Is there any problem wid dis code...............?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is online now Moderator
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    10,101
    Rep Power
    17

    Default Re: No output with this code

    1. When you have a question, start a new thread -- they're free. Don't hijack another poster's thread, and don't wake threads that have been dead for four years.
    2. Please maintain the decorum of a technical forum. 'I didn't get output with this code" not "I didn't get o/p wid dis code."
    3. Use code tags when posting code so that the posted code retains its formatting.

    db
    Why do they call it rush hour when nothing moves? - Robin Williams

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    14,795
    Rep Power
    20

    Default Re: No output with this code

    Add some printlns to print out messages so you can see where the code is executing.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 0
    Last Post: 08-07-2011, 08:32 PM
  2. problem with output of code
    By amosexy in forum New To Java
    Replies: 15
    Last Post: 07-05-2010, 06:57 PM
  3. needed code for this output
    By rajivjoshi in forum New To Java
    Replies: 4
    Last Post: 05-31-2010, 05:54 PM
  4. What will be output by the following code? using trim method.
    By racewithferrari in forum New To Java
    Replies: 4
    Last Post: 11-17-2009, 09:40 PM
  5. Need help formatting output and some code
    By A5i19 in forum New To Java
    Replies: 6
    Last Post: 11-09-2009, 04:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •