Results 1 to 19 of 19
  1. #1
    Arn00p is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default my program is running bit slow!!

    Use pipe tool in the program
    save file as mylord.java

    The program runs too slow some time..

    program can be downloaded at..
    Java | //save the file as mylord.java - Snippet(pencil,pipe tool) - RFB1RhvQ - Pastebin.com

  2. #2
    iluxa is offline Senior Member
    Join Date
    Mar 2010
    Posts
    266
    Rep Power
    5

    Default

    - you should only draw in paint() method. move the content of drawSomething() into paint().
    - in mouseDragged(), instead of drawSomething(), call repaint()

  3. #3
    Arn00p is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default

    i would love to do tat... but drawing in paint method wont save anything on screen(remember repaint redraws the screen with the instructions given in paint)..... therefore i m initializing graphic object(data member of class) once from paint method ....... and then using it in my drawSomething() method .


    My application is running f9 when 1 more application is running alongwith it like firefox,taskmanager etc. Either this is a bug or there is some problem in my PC.

    please try d above and give reply ...(Problem is only with Pipe tool)

    Thanx anyways for replying..

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default

    Recommended reading: How To Ask Questions The Smart Way

    db

  5. #5
    Riaz Ali is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default

    Quote Originally Posted by Arn00p View Post
    Use pipe tool in the program
    save file as mylord.java

    The program runs too slow some time..

    program can be downloaded at..
    Java | //save the file as mylord.java - Snippet(pencil,pipe tool) - RFB1RhvQ - Pastebin.com
    There may be viruses in your PC. OR You may have created a lot of variables and/or objects in your program.

  6. #6
    Arn00p is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default

    is pipe tool running f9 in ur PCs? ( Plz compile the code, test it ,then reply ... dont reply like nabs)

    dont know abt viruses but program is made in very systematic way ... Only required objects are created ...

    and it runs f9 when taskmanager etc like application is opened in background..

  7. #7
    Arn00p is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default

    Quote Originally Posted by Darryl.Burke View Post
    Recommended reading: How To Ask Questions The Smart Way

    db

    dude dont spam useless links in thread... if u arent interested get lost.. :)

  8. #8
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Post full English words.
    Do some debugging on your own to find out which sections of the code are running slowly.
    Post the relevant code here.
    That is how you ask questions the smart way.

  9. #9
    Arn00p is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default

    You can download code from http://pastebin.com/download.php?i=RFB1RhvQ

    Just compile,test and reply if it is running f9 .... i have done enough debugging on my own..
    Last edited by Arn00p; 05-05-2010 at 01:13 PM.

  10. #10
    Arn00p is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default

    the code is:

    //save the file as mylord.java
    //save the file as mylord.java
    //save the file as mylord.java
    //save the file as mylord.java
    import java.awt.Button;
    import java.awt.Checkbox;
    import java.awt.CheckboxGroup;
    import java.awt.Color;
    import java.awt.FlowLayout;
    import java.awt.Frame;
    import java.awt.Graphics;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ItemEvent;
    import java.awt.event.ItemListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    class hangyo extends Frame implements MouseMotionListener,MouseListener,ItemListener,Act ionListener
    {
    Graphics h;
    int x,y,X,Y,c;
    CheckboxGroup figure,colour;
    Checkbox pencil,pipe,cRed,cBlue,cYellow,cCyan,cBlack;
    ItemEvent ie,save_source;
    Button clear;
    hangyo()
    {
    h=null;
    setTitle("Just Drag and See");
    setLayout(new FlowLayout());
    setSize(1000,1000);
    setVisible(true);
    setBackground(Color.WHITE);
    addMouseMotionListener(this);
    addMouseListener(this);
    figure = new CheckboxGroup();
    colour = new CheckboxGroup();
    pencil = new Checkbox("Pencil",figure,false);
    pipe = new Checkbox("Pipe",figure,false);
    cRed = new Checkbox("Red",colour,false);
    cBlue = new Checkbox("BLue",colour,false);
    cYellow = new Checkbox("Yellow",colour,false);
    cCyan = new Checkbox("Cyan",colour,false);
    cBlack = new Checkbox("Black",colour,false);

    clear = new Button("Clear");

    add(pencil);
    add(pipe);
    add(clear);
    add(cRed);
    add(cBlue);
    add(cYellow);
    add(cCyan);
    add(cBlack);

    pencil.addItemListener(this);
    pipe.addItemListener(this);
    clear.addActionListener(this);
    cCyan.addItemListener(this);
    cRed.addItemListener(this);
    cYellow.addItemListener(this);
    cBlue.addItemListener(this);
    cBlack.addItemListener(this);

    addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent w)
    {
    System.exit(0);
    }
    });

    }
    public void paint(Graphics g)
    {
    h=g.create();
    }
    public void drawSomething()
    {
    if(ie.getSource()==pipe)
    h.drawOval(x-50,y-50, 100, 100);
    if(ie.getSource()==pencil)
    {
    h.drawLine(x, y, X, Y);
    X=x;Y=y;
    }
    }
    @Override
    public void mouseDragged(MouseEvent arg0) {
    // TODO Auto-generated method stub
    if(c==0)
    {
    X=x=arg0.getX();
    Y=y=arg0.getY();
    c=1;
    }
    x=arg0.getX();
    y=arg0.getY();
    drawSomething();
    }
    @Override
    public void mouseMoved(MouseEvent arg0) {
    // TODO Auto-generated method stub

    }
    @Override
    public void mouseClicked(MouseEvent arg0) {
    // TODO Auto-generated method stub

    }
    @Override
    public void mouseEntered(MouseEvent arg0) {
    // TODO Auto-generated method stub

    }
    @Override
    public void mouseExited(MouseEvent arg0) {
    // TODO Auto-generated method stub

    }
    @Override
    public void mousePressed(MouseEvent arg0) {
    // TODO Auto-generated method stub

    }
    @Override
    public void mouseReleased(MouseEvent arg0) {
    // TODO Auto-generated method stub
    c=0;
    }
    @Override
    public void itemStateChanged(ItemEvent arg0) {
    // TODO Auto-generated method stub
    ie=arg0;
    if(arg0.getSource()==pencil || arg0.getSource()==pipe)
    save_source = arg0;
    if(arg0.getSource()==cCyan)
    h.setColor(Color.CYAN);
    if(arg0.getSource()==cRed)
    h.setColor(Color.red);
    if(arg0.getSource()==cYellow)
    h.setColor(Color.YELLOW);
    if(arg0.getSource()==cBlue)
    h.setColor(Color.BLUE);
    if(arg0.getSource()==cBlack)
    h.setColor(Color.BLACK);

    ie.setSource(save_source.getSource());
    }
    @Override
    public void actionPerformed(ActionEvent arg0) {
    // TODO Auto-generated method stub
    repaint();
    }
    }
    class mylord
    {
    public static void main(String args[])
    {
    new hangyo();
    }
    }

  11. #11
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Arn00p View Post
    is pipe tool running f9 in ur PCs? ( Plz compile the code, test it ,then reply ... dont reply like nabs)
    Who's nabs?

    kind regards,

    Jos

    ps. you'd better adjust your attitude a bit because I'm not even going to try to answer you, the way you are behaving now.

  12. #12
    Arn00p is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default

    Quote Originally Posted by JosAH View Post
    Who's nabs?

    kind regards,

    Jos

    ps. you'd better adjust your attitude a bit because I'm not even going to try to answer you, the way you are behaving now.

    those ppl who r replying without compiling and testing the code (coz u can only understand the problem after u compile it) are nabs.

    and i can smell bit of noobness from u too. :)

  13. #13
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default

    ignoreList++

    Jos

  14. #14
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    ignoreList++ ;

  15. #15
    Arn00p is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default

    new DontGiveAShitOnYourList();

  16. #16
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    Oh dear.

    Look, those people who just stuck you on ignore are Java professionals.

    We come here to see if we can help...you know, voluntary stuff. It helps if, as in the article linked to by Jos, you actually ask questions in a Smart Way, because it then helps us help you. TXT speak is not smart. Being rude is not smart. And asking us to run your code for you is not smart.

    You explaining in real words your problem, along with stack traces, compilation errors, whatever, and a minimal amount of relevant formatted code (in code tags) is smart.

    ETA: Oops. Should have said "linked to by Darryl", not Jos...

  17. #17
    Arn00p is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default

    in d end www.java-forums.org sucks ..... worst forum here
    its tag line shld be

    where learning and development ends...

    good bye to u all

  18. #18
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    Bye bye!

    Missing you already...

  19. #19
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Tolls View Post
    Bye bye!

    Missing you already...
    ... like a bad headache; let the kid go; it was just a kid with too much self esteem, not willing to act and behave socially and imho not willing to learn anything at all. Maybe we'll meet it again when we go out for a hamburger ;-)

    kind regards,

    Jos

Similar Threads

  1. Program running indefinitely
    By bayan in forum New To Java
    Replies: 2
    Last Post: 04-27-2010, 10:22 AM
  2. Replies: 1
    Last Post: 03-30-2010, 10:23 PM
  3. Running a Java Program
    By Valkyrie in forum New To Java
    Replies: 13
    Last Post: 11-05-2009, 04:43 AM
  4. error running java program
    By bdasilva in forum New To Java
    Replies: 1
    Last Post: 06-29-2009, 02:46 AM
  5. Improve the slow running time
    By coolFrenzi in forum Advanced Java
    Replies: 1
    Last Post: 04-12-2009, 01:15 PM

Posting Permissions

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