help with mousemove/mousedrag program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • killiesteve
    New Member
    • Feb 2008
    • 2

    #1

    help with mousemove/mousedrag program

    Basically i want to use this idea shown here

    http://javaboutique.in ternet.com/tutorials/Java_by_Example/section6_3.html

    I just wasnt sure what was required in the main method. I want it to bring up the window in which to draw in.

    As an afterthought i was wondering if you could modify the code so that:
    i) You could save what was drawn
    ii) The user could select which colour and thickness to draw in.

    I tried doing a basic main method but it didnt work. I am very much a novice at this so much help would be appreciated.

    i wrote:

    Code:
           public static void main(String[] args) {
    Applet gBuffer=new Project29();
    
     gBuffer.addWindowListener(new WindowAdapter() {
           public void windowClosing(WindowEvent e) {
              System.exit(0);
           }
        });
        gBuffer.setSize(350,200);
        gBuffer.setVisible(true); 
    }
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by killiesteve
    Basically i want to use this idea shown here

    http://javaboutique.in ternet.com/tutorials/Java_by_Example/section6_3.html

    I just wasnt sure what was required in the main method. I want it to bring up the window in which to draw in.

    As an afterthought i was wondering if you could modify the code so that:
    i) You could save what was drawn
    ii) The user could select which colour and thickness to draw in.

    I tried doing a basic main method but it didnt work. I am very much a novice at this so much help would be appreciated.

    i wrote:

    Code:
           public static void main(String[] args) {
    Applet gBuffer=new Project29();
    
     gBuffer.addWindowListener(new WindowAdapter() {
           public void windowClosing(WindowEvent e) {
              System.exit(0);
           }
        });
        gBuffer.setSize(350,200);
        gBuffer.setVisible(true); 
    }
    Is that all you have done so far? Please post all the code you have tried so far. This sounds like a school project to me.

    Comment

    • killiesteve
      New Member
      • Feb 2008
      • 2

      #3
      well its all ive done for the main method. not really sure what is involved as this is a totally new idea for me. the rest of the code is the same as the stuff in the link which compiles fine. just dont know how you actually get the window up to draw in

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by killiesteve
        well its all ive done for the main method. not really sure what is involved as this is a totally new idea for me. the rest of the code is the same as the stuff in the link which compiles fine. just dont know how you actually get the window up to draw in
        Well, I don't trust external links. I know some who don't too.
        You are better off grabbing a tutorial (Sun's Java one is nice) and trying whatever you want to do by yourself. If you get stuck, you can then post your code here and the experts will be willing to help.

        Comment

        • BigDaddyLH
          Recognized Expert Top Contributor
          • Dec 2007
          • 1216

          #5
          Originally posted by killiesteve
          Basically i want to use this idea shown here
          Code:
                 public static void main(String[] args) {
          Applet gBuffer=new Project29();
          
           gBuffer.addWindowListener(new WindowAdapter() {
                 public void windowClosing(WindowEvent e) {
                    System.exit(0);
                 }
              });
              gBuffer.setSize(350,200);
              gBuffer.setVisible(true); 
          }
          I think you are confusing applets with stand-alone GUIs. As suggested, take the Sun Swing tutorial: http://java.sun.com/docs/books/tutor...ing/index.html

          Comment

          Working...