Free draw using Mouse & Save it???

Hi
I have an applet code using which we can free draw using mouse. Say you can sign or draw anything on screen in the space given. Now, How do I store it as an image. IF not as an image, are there any other way to store the image drawn using the mouse.

Are you not drawing to an image anyway? If you don't then all your work will be lost if you minimize and restore the window.
On creating your canvas component obtain an image via JComponent.createImage(). When drawing with the mouse, draw to a Graphics object which is obtained from that image via Image.getGraphics(). Then in your paintComponent() method, paint that image to the on-screen Graphics object.

Similar Messages

  • I bought and downloaded iWork when i bought my macbook pro and i used to save my documents on words. then a few weeks ago, i downloaded a free trial of microsoft office but unregistered and deleted it a week after. now i can't save my documents on word.

    i bought and downloaded iWork when i bought my macbook pro and i used to save my documents on words. then a few weeks ago, i downloaded a free trial of microsoft office but unregistered and deleted it a week after. now i can't save my documents on word. It used to ask me if I want to save my documents on word, now it doesn't. And the W icon keeps on appearing on my dock. Can I return my computer to an earlier date? Please help me. Thanks

    No, I don't have a back-up of TIme Machine... to tell you the truth, I have this computer for a few years now and I still don't know how to work all of the apps that are here. Anything else I can do?

  • Draw a line using mouse

    Hello there:
    I'm trying to draw a line using mouse pointer: My code is:
    public class DrawLine extends JFrame implements MouseListener, MouseMotionListener
        int x0, y0, x1, y1;  
        public DrawLine()
             addMouseListener(this);
             addMouseMotionListener(this);
        public void mouseDragged(MouseEvent e)
             x1 = e.getX();
             y1 = e.getY();
             repaint();
        public void mouseMoved(MouseEvent e) { }
        public void mouseClicked(MouseEvent e){ }
        public void mouseEntered(MouseEvent e) { }
        public void mouseExited (MouseEvent e) { }
        public void mousePressed(MouseEvent e)
              x0 = e.getX();
              y0 = e.getY();           
        public void mouseReleased(MouseEvent e)
              x1 = e.getX();
              y1 = e.getY();
       public void paint(Graphics g)
                 g.setColor(Color.BLACK);
              g.drawLine(x0, y0, x1, y1);
        public static void main(String[] argv)
             DrawLine dr=new DrawLine("Test");
             dr.setVisible(true);
             dr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }when mouse is dragged, multiple lines are being drawn....
    could you else please tell me what should I've to do???
    thanks n regards...
    Dev

    You can implement the listeners on any class, even one that (implicitly) extends Object. What matters is that the listener is added to the component that needs to use it.
    That said, why do you want to extend JFrame? Are you adding functionality to the JFrame to justify extending the JFC class? Note that extending JFrame allows the users of your class to access the functionality of a JFrame, is that really indicated here?
    one class that extends JFrame, and one can draw a line on JLabel, embedded within JFrame!So you still have to override paintComponent of the JLabel, which implies using an anonymous inner class.
    Starting with the example already posted, that would be:
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.SwingUtilities;
    public class DrawLineTest
        implements MouseListener, MouseMotionListener {
      JLabel label;
      int x0, y0, x1, y1;
      private void makeUI() {
        JFrame frame = new JFrame("DrawLineTest");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        label = new JLabel("FFFF") {
          public void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.setColor(Color.BLACK);
            g.drawLine(x0, y0, x1, y1);
        label.setPreferredSize(new Dimension(500, 500));
        label.addMouseListener(this);
        label.addMouseMotionListener(this);
        frame.add(label);
        frame.pack();
        frame.setVisible(true);
      public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            new DrawLineTest().makeUI();
      public void mousePressed(MouseEvent e) {
        x0 = e.getX();
        y0 = e.getY();      
      public void mouseReleased(MouseEvent e) {
        x1 = e.getX();
        y1 = e.getY();
      public void mouseDragged(MouseEvent e) {
        x1 = e.getX();
        y1 = e.getY();
        label.repaint();
      public void mouseMoved(MouseEvent e) { }
      public void mouseClicked(MouseEvent e){ }
      public void mouseEntered(MouseEvent e) { }
      public void mouseExited (MouseEvent e) { }
    }Better spend more time with the tutorials, there's a separate section on writing event listeners.
    db

  • Hi, I am trying to blur the background in Prem Pro CC I have made a mask using the free draw bezier tool but it does not track forward.  What am I doing wrong?

    Hi, I am trying to blur the background in Prem Pro CC I have made a mask using the free draw bezier tool but it does not track forward.  What am I doing wrong?

    Hi Kevin
    I found a YouTube clip explaining how to blur the background with free draw bezier tool and it also said to invert the mask, but it still does not track forward. I really hope there is a solution.
    Steph

  • How to draw with mouse on Html 5 canvas inside browser (using createJs).

    Hi Everyone,
    In Flash AS2/3 we can draw with mouse in browser (of course inside Flash Player). How can we do that in Flash CC Canvas using CreateJs (result must be in canvas not in flash player). Something like this http://www.codicode.com/art/how_to_draw_on_a_html5_canvas_with_a_mouse.aspx
    Thanks in Advance

    This is a bit more of a JavaScript / Canvas question than a Flash question. I realize you're using the Flash product but Flash CC is just giving you an IDE with limited JavaScript automation.
    In this mode you're expected to be familiar with JavaScript and CreateJS. Are you?
    If not, what you might want to do is look at a sister product for HTML5 Canvas automation called EaselJS. It's a JavaScript library that makes using the Canvas very easy. Have a look at the commands here:
    http://www.createjs.com/Docs/EaselJS/modules/EaselJS.html
    You might find you don't need Flash CC to perform what you want. Otherwise this conversation may tip so deeply into JavaScript and CreateJS that it might be more prudent to use the Dreamweaver forum.

  • Draw On Panel/Save as GIF problem

    Hi everyone,
    I am designing an application where the user should be able to free draw on a JPanel(that resides on a JFrame) by licking/dragging/releasing the mouse.
    Then, this drawing needs to be saved as a GIF image.
    OK. I have managed to implement a free-draw algorithm but now I am having problems saving the GIF. I think I kinda know where the the problem is, but I can't find any ways around it.
    I am using a Graphics2D class to draw the lines, and I am using the .setClip method to assossiate my graphics object to the JPanel,i.e.
    g.setClip(jPanel1.getX(), jPanel1.getY(), jPanel1.getWidth(), jPanel1.getHeight());
    I think that this is where the problem is. I believe that eventhough I can actually see the line drawn by the user @ runtime, the line itself is not "added" onto the JPanel, it just draws itself onto the area that the JPanel occupies.
    Hence, when I attempt to save the JPanel as a GIF(using an Acme.JPM.Encoder), the saved image appears monochrome, without any lines on it at all.
    The free-draw algorithm that i am using involes saving all the coordinates of the area where the mouse is being dragged into a Vector of Points which I have to repaint() whenever a new drag is listened.
    Any help would be greatly appreciated,
    thanks
    Yiannis

    Hi Ashwin,
    I have created a class that can take a JPanel and save it into GIF.
    the code is:
    import javax.swing.*;
    import java.io.*;
    import java.awt.image.*;
    import java.awt.Graphics;
    import Acme.JPM.Encoders.*;
    public class saveToGIF {
    private JPanel panel;
    /** Creates a new instance of saveToGIF */
    public saveToGIF(JPanel panel, String file) throws IOException{
    this.panel=panel;
    BufferedImage image = new BufferedImage(this.panel.getWidth(), this.panel.getHeight, BufferedImage.TYPE_INT_RGB);
    Graphics g = image.getGraphics();
    panel.paint(g);
    FileOutputStream fos = new FileOutputStream(file);
    GifEncoder encoder = new GifEncoder(image, fos);
    encoder.encode();
    fos.close();
    OK, this works fine. However, I cannot add my drawings onto the JPanel.
    Sth with overwritting the paintComponent() method is what i do no fully nderstand.
    Thanks,
    Yiannis

  • Writing on the canvas using mouse

    Hi,
    In my application, i use mouse to write some text on a panel or canvas. The code works fine when i write slow on the panel or canvas, but if you started to write fast you miss some of the mouse events , so all i can get is dots, not a continuous line. That is my problem. How can i get around this problem. Any suggestions here
    thanks in advance

    Hi,
    I am developing a touch screen based application,
    where the user will be writing on the screen ( panel,
    canvas ) using mouse or the touch screen pen. I need
    to save what he draws on the panel or canvas to a jpg,
    jpeg, gif file. The image i stored will used later.
    So i need help to convert the drawing on the panel or
    canvas into a image. Any suggestions in this regard
    is appreciated.
    thanks in advanceFirst of all, your app sounds cool! Second, there are literally hundreds of posts, just like this one, that have been answered more times than I can count. Just do 2 searches in the forums:
    1. how to capture a gui component into an image format
    2. how to save an image as a jpg

  • I have downloaded the 30 day free trial using Adobe Download Assistant but I do not know how to open it and start using it.

    I have downloaded the 30 day free trial using Adobe Download Assistant but I do not know how to open it and start using it.

    This was so annoying!! It took me a good couple of hours but i figured it out, you need to do the following: Go to the folder where you saved the download (in my case i saved it in My Downloads) -> click on 'Adobe Photoshop Elements 12' -> click on 'PSE 12' -> click on 'Setup' (select the icon which is a box with a shield) -> follow instructions and....voila! You will need to restart when it suggests so save anything else first, then when it reboots you should see the icon on your desktop....hpe this helps!

  • HT4753 I have a very simple question: how do I view where Lion has autosaved my current version to (without the convoluted route of using finder)? In days gone by i'd simply use the save as function to see where it was being saved.

    I have a very simple question: how do I view where Lion has autosaved my current version to (without the convoluted route of using finder)? In days gone by i'd simply use the save as function to see where it was being saved.

    It's actually even easier than using Save As to see the full path to the currently open document. Just do a "Secondary click" on the document title in its window's title bar.
    Like you, I relied upon Save As my whole life to check a file's location and considered it a must-have capability. Turns out it's even faster to use the single-click method to reveal the full path to the open document. It displays the entire path to the current document starting from the level of your Mac, and works for files stored on drives as well as iCloud.
    If you're not sure how to do a secondary click, go into System Preferences, select Trackpad, Point & Click to find the current preference for secondary click on your Mac. If you happen to have a mouse with more than one button, it's probably the right button. As a trackpad user, I check the box to "Click or tap with two fingers," so a simple two finger tap on the title of an open document reveals its full path. This feature actually has been around for a very long time.
    Note that this is not the same thing as the Autosave and Versions menu, which is exposed using a little drop down triangle to the right of the title. There is no visual clue for the presence of this feature - you just have to know it's there, probably because this feature goes all the way back to pre-OS X days.

  • How can I draw using the Brush tool and a touch screen?

    I need to be able to use the touch screen on my Lenovo Yoga (running Windows 8) to draw using the Brush tool in Photoshop CS6. I'm able to do that in other programs, including Microsoft OneNote and Paint. For some reason, Photoshop will only interpret touching and dragging on the screen as an attempt to pan or scroll, even when the Brush tool is selected. I bought Photoshop - and it isn't cheap - specifically in order to draw using the touch screen, which I need to be able to do for my job. Is there some driver I can download to fix this problem, or some obscure setting I can change?
    I would also like to note that Adobe's technical support line exhibits a degree of infuriating unreachability equalled only by the Massachusetts Registry of Motor Vehicles. When I called to ask for help with this problem, I was told the expected wait time was between 10 and 14 minutes. After waiting for 50 minutes, I gave up in disgust. Adobe's products are powerful, but what passes for customer service is an utter disgrace.

    There's gotta be a way but I just use gimp for touch drawing, save it off as a png, edit in ps or ai. 

  • How to make image resizable using mouse ?

    Hi,
    I want to know about that how to resize image by using mouse in Java Canvas. I created some tools like line, free hand, eraser. And want to know how to make an image resizable in canvas by using mouse. An image is jpeg, png, or gif format. I want to make image stretch and shrink by using mouse.
    Please help me..
    Thnax in advance.
    Manveer

    You make a listener to handle the mouse event that you want to capture, then program the affect you want using the event as the trigger.

  • Captivate 6 - I cannot confirm popup messages using mouse.  Must use keyboard shortcuts.  Why?

    When a confirmation window appears, I cannot use the mouse to click on Ok, Cancel, Yes, No, Save.  I must use the keyboard shortcut key, such as Enter, Y, N, S, C.  This is extremely frustrating.  Is there an update available that corrects this problem?
    Thank you,
    AT&T Captivator

    Hi tjatt,
                  Is your default text size in windows is Larger -150%? Can you make it smaller - 100% or medium -125% and restart machine? Check whether you can use mouse for confimation windows?
    Text size can be found at Windows Start --> Control Panel -->Appearance and Personalization --> Display
    Thanks,
    Sankaram.

  • About Free Drawing Tool

    Hi,
    I want to develope a performance data monitor software using Java, so I need a drawing tool to draw the graph.
    For diffirent performance parameter, I need use diffirent color to draw it, so I need that the drawing tool can draw with COLOR as its inputing parameter.
    Could you tell me which free drawing tool can implement such function and where I can get it?
    Looking forward to your response.
    Thanks a lot
    Regards
    Huyong

    Thanks for giving the information , I am new Java
    ProgrammerAs someone new to Java this person should not be using an IDE until they can install the JDK, setup classpaths, run 'java' and 'javac' from the commandline, navigate the JavaDocs and manage packages manually, i.e. through a command line. Yes, this will result in a higher initial learning curve, but will pay off greatly in the future. If they want to use a simple text editor like JEdit or TextPad for syntax highlighting that's fine, but by using anything more like JBuilder, Eclipse, IntelliJ, NetBeans, etc. they'll be doing themselves a huge disservice.

  • Downloading images used to go automatically to the last folder used to save images, even when reopening Firefox. In just the past few days, possibly coinciding wih the most recent updates, the folder defaults to the 'Downloads' folder. This is most annoyi

    Downloading images used to go automatically to the last folder used to save images, even when reopening Firefox. In just the past few days, possibly coinciding wih the most recent updates, the folder defaults to the 'Downloads' folder. This is most annoying. What happened? Internet Explorer 8.0 did the same thing. This was one of the reasons why I started using Firefox to download all images. I went into Tools>Options and it only lets me set another folder. I dont want to set a specific folder I want it to always go to the last folder used. So what gives?
    == This happened ==
    Every time Firefox opened
    == possibly when the most recent updates were installed, a few days ago

    Thanks jscher 2000. I guess I didn't make it clear. "It restarts with all the addons activated, and resumes with the tabs that were open before closing it." IE, it's running fine now with all the extensions activated. Everything is OK now.
    So something in the Firefox code was causing the bad behavior. It's not essential that I find out what the problem was - I'm just curious. And if anybody else has this same problem, it might be nice to have it corrected at the source.

  • I am trying to use the "save my passords" feature and it never asks me to save them and never saves them on it's own. How do I enable this feature?

    I want to use the save passwords and login information for the websites I use frequently but am unsure how to get the program to prompt me to save them...

    Make sure that you do not run Firefox in permanent Private Browsing mode.
    *https://support.mozilla.org/kb/Private+Browsing
    To see all History and Cookie settings, choose:
    *Tools > Options > Privacy, choose the setting <b>Firefox will: Use custom settings for history</b>
    *Deselect: [ ] "Always use private browsing mode"
    There are other things that need your attention.
    Your above posted system details show outdated plugin(s) with known security and stability risks that you should update.
    *Shockwave Flash 10.0 r32
    Update the Flash plugin to the latest version.
    *https://support.mozilla.org/kb/Managing+the+Flash+plugin
    *http://kb.mozillazine.org/Flash
    *http://www.adobe.com/software/flash/about/

Maybe you are looking for

  • Is there any way to back up imessages

    I've recently experienced the problem of the "other" category in my storage bar taking up 17.04 GB. I'm assuming that this means that there is some corrupted data in there somewhere as I've gone and deleted a bunch of emails, and photos, etc. with no

  • Getting message "The application CIJAutoSetupTool quit unexpectedly"

    I keep getting message "The application CIJAutoSetupTool quit unexpectedly" while trying to get my new Canon PIXMA ip4600 printer to work via my D-Link DI-624S Router (which has 2 USB ports for printers). I have a Brother Laser printer working fine b

  • Librfc32.dll error

    Dear Experts, As per note 1032461 i downloaded and copied the file, But RFC is still showing error. While executed the command "find "LIBRFC" librfc32.dll" and getting the below error. As above said in Note:1447900, i cannot find the below files from

  • App crashes in iPad IOS 5.0.1

    My App is working well in iPad IOS 5.0 simulatore and iPad IOS 5.0.  However, some peoplea re reporting that the app is crashing in iPad with IOS 5.0.1.  I am using Three20 frame work in my app.  Is that a problem.  How can I test the IOS 5.0.1 Simul

  • Puzzled about RMI

    Folks, I'm just playing with RMI now and have followed the tutorial but I am a little puzzled about some behaviour I'm observing. This may be that I am missing a piece of information about RMI or how it works so if anyone can fill in the blanks then