Making an efficient paint program

I'm writing a small paint program atm that has a 'freehand' tool which means a point is drawn at whatever locations the mouse button is held down at.
Currently the code is like this:
public void mouseDragged(MouseEvent me)
            a = new Point();
            a.setLocation(me.getX(),me.getY());
            pt.add(a);
            repaint();
        }Is there a more effcicient way of doing this, if I drag my mouse accross the sccreen there are noticeable gaps between the points.

Don't draw a point at each spot along the drag path, draw a line between every two adjacent points. The mouse won't be at every pixel along the path, you can easily move it fast enough that it skips points, so drawing lines between adjacent points compensates for that.

Similar Messages

  • Small paint program

    hi guys
    I'm having some trouble making a small paint program with swing. It needs the following functions:
    - choose a shape from a combobox(only line, rectangle or circle).
    - set the filled checkbox to on or off
    - choose a color with the JColorChooser when you click on the colorLabel
    Then you can start drawing the shape you selected on the JPanel.
    Could someone help me out ? I would really appreciate that :-)
    Greetz

    noah.w's PaintLike2 program might get you what you want
    http://forum.java.sun.com/thread.jspa?forumID=256&threadID=476969
    there is a PaintLike3 (also from noah.w) in the forums somewhere,
    but I couldn't find it

  • Need help with algorithm for my paint program

    I was making a paint program with using a BufferedImage where the user draws to the BufferedImage and then I draw the BufferedImage onto the class I am extending JPanel with. I want the user to be able to use an undo feature via ctrl+z and I also want them to be able to update what kind of paper they're writing on live: a) blank paper b) graph paper c) lined paper. I cannot see how to do this by using BufferedImages. Is there something I'm missing or must I do it another way? I am trying to avoid the other way because it seems too demanding on the computer but if this is not do-able then I guess I must but I feel I should ask you guys if what I am doing is logical or monstrous.
    What I am planning to do is make a LinkedList that has the following 4 parameters:
    1) previous Point
    2) current Point
    3) current Color
    4) boolean connectPrevious
    which means that the program would basically draw the instantaneous line using the two points and color specified in paintComponent(Graphics g). The boolean value is for ctrl+z (undo) purposes. I am also planning to use a background thread to eliminate repeated entries in the LinkedList except for the last 25 components of the LinkedList (that number might change in practice).
    What do you guys think?
    Any input would be greatly appreciated!
    Thanks in advance!

    Look at the package javax.swing.undo package - UndoableEdit interface and UndoManager class.
    Just implement the interface. Store all necessary data to perform your action (colors, pixels, shapes etc.). Add all your UndoableEdits in an UndoManager instance and call undo() redo() when you need.

  • LodePaint: Painting Program

    LodePaint is an open source painting program similar to (Kolour)Paint but with more advanced features, more filters, soft brushes, alpha channel support, some HDR image support, etc...
    The program is aimed mostly at pixel artists, icons, texture editing, "programmer's art", etc...
    It can be downloaded here: https://sourceforge.net/projects/lodepaint/files/
    Just unzip & run. It requires SDL, and hardware accelerated OpenGL to run.
    Please try it out!
    Last edited by aardwolf (2010-03-06 15:20:01)

    If you try compiling it for 64-bit, it'd be interesting to know if it worked.
    It did not. Using this PKGBUILD
    # Maintainer: Stefan Husmann <[email protected]>
    pkgname=lodepaint-svn
    pkgver=7
    pkgrel=1
    pkgdesc="Painting program with full SDL+OpenGL GUI."
    url="http://sourceforge.net/projects/lodepaint/"
    arch=('i686' 'x86_64')
    license=('GPL3')
    depends=('sdl')
    source=()
    md5sums=()
    _svntrunk=https://lodepaint.svn.sourceforge.net/svnroot/lodepaint
    _svnmod=lodepaint
    build() {
    cd "$srcdir"
    LANG=C
    if [ -d $_svnmod/.svn ]; then
    (cd $_svnmod && svn up -r $pkgver)
    else
    svn co $_svntrunk --config-dir ./ -r $pkgver $_svnmod
    fi
    msg "SVN checkout done or server timeout"
    msg "Starting make..."
    rm -rf "$srcdir/$_svnmod-build"
    cp -r "$srcdir/$_svnmod" "$srcdir/$_svnmod-build"
    cd "$srcdir/$_svnmod-build/trunk"
    # BUILD
    g++ src/*.cpp src/lpi/*.cpp -o lodepaint -lSDL -lGL -W -Wall \
    -Wextra -pedantic -ansi -O2
    install -Dm755 lodepaint $pkgdir/usr/bin/lodepaint
    I get
    ==> Determining latest svn revision...
    -> Version found: 7
    ==> Making package: lodepaint-svn 7-1 x86_64 (So 7. Mär 13:25:31 CET 2010)
    ==> Checking Runtime Dependencies...
    ==> Checking Buildtime Dependencies...
    ==> Retrieving Sources...
    ==> Extracting Sources...
    ==> Removing existing pkg/ directory...
    ==> Entering fakeroot environment...
    ==> Starting build()...
    At revision 7.
    ==> SVN checkout done or server timeout
    ==> Starting make...
    src/paint_filter_plugin.cpp: In constructor 'FilterPlugin::FilterPlugin(const std::string&, GlobalToolSettings&, const lpi::gui::IGUIDrawer&)':
    src/paint_filter_plugin.cpp:52: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:69: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:82: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:83: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:85: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:86: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:87: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:88: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:96: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:97: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:98: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:99: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:100: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:101: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:102: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:103: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:104: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:105: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:106: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:107: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp:108: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_filter_plugin.cpp: In constructor 'FilterPlugin::FilterPlugin(const std::string&, GlobalToolSettings&, const lpi::gui::IGUIDrawer&)':
    src/paint_filter_plugin.cpp:52: warning: dereferencing pointer 'p_getLodePaintPluginType.174' does break strict-aliasing rules
    src/paint_filter_plugin.cpp:52: note: initialized from here
    src/paint_filter_plugin.cpp: In constructor 'FilterPlugin::FilterPlugin(const std::string&, GlobalToolSettings&, const lpi::gui::IGUIDrawer&)':
    src/paint_filter_plugin.cpp:52: warning: dereferencing pointer 'p_getLodePaintPluginType.174' does break strict-aliasing rules
    src/paint_filter_plugin.cpp:52: note: initialized from here
    src/paint_imageformats.cpp: In constructor 'ImageFormatPlugin::ImageFormatPlugin(const std::string&)':
    src/paint_imageformats.cpp:403: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_imageformats.cpp:422: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_imageformats.cpp:435: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_imageformats.cpp:442: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_imageformats.cpp:449: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_imageformats.cpp:456: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_imageformats.cpp:463: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_imageformats.cpp:464: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_imageformats.cpp:465: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_imageformats.cpp:466: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_imageformats.cpp:468: warning: dereferencing type-punned pointer will break strict-aliasing rules
    src/paint_imageformats.cpp: In constructor 'ImageFormatPlugin::ImageFormatPlugin(const std::string&)':
    src/paint_imageformats.cpp:403: warning: dereferencing pointer 'p_getLodePaintPluginType.203' does break strict-aliasing rules
    src/paint_imageformats.cpp:403: note: initialized from here
    src/paint_imageformats.cpp: In constructor 'ImageFormatPlugin::ImageFormatPlugin(const std::string&)':
    src/paint_imageformats.cpp:403: warning: dereferencing pointer 'p_getLodePaintPluginType.203' does break strict-aliasing rules
    src/paint_imageformats.cpp:403: note: initialized from here
    src/lpi/lpi_imageformats.cpp: In function 'bool lpi::decodeImageFile(std::string&, std::vector<unsigned char, std::allocator<unsigned char> >&, int&, int&, const unsigned char*, size_t, lpi::ImageFormat)':
    src/lpi/lpi_imageformats.cpp:795: error: no matching function for call to 'CBitmap::GetBits(unsigned char*, size_t&, int)'
    src/lpi/lpi_imageformats.cpp:593: note: candidates are: bool CBitmap::GetBits(void*, unsigned int&)
    src/lpi/lpi_imageformats.cpp:607: note: void* CBitmap::GetBits()
    src/lpi/lpi_imageformats.cpp:614: note: bool CBitmap::GetBits(void*, unsigned int&, unsigned int)
    src/lpi/stb_image.cpp: In function 'stbi_uc* stbi_tga_load_from_memory(const stbi_uc*, int, int*, int*, int*, int)':
    src/lpi/stb_image.cpp:2866: warning: 'trans_data$3' may be used uninitialized in this function
    src/lpi/stb_image.cpp:2866: note: 'trans_data$3' was declared here
    src/lpi/stb_image.cpp:2866: warning: 'trans_data$2' may be used uninitialized in this function
    src/lpi/stb_image.cpp:2866: note: 'trans_data$2' was declared here
    src/lpi/stb_image.cpp:2866: warning: 'trans_data$1' may be used uninitialized in this function
    src/lpi/stb_image.cpp:2866: note: 'trans_data$1' was declared here
    src/lpi/stb_image.cpp:2866: warning: 'trans_data$0' may be used uninitialized in this function
    src/lpi/stb_image.cpp:2866: note: 'trans_data$0' was declared here
    install: cannot stat `lodepaint': No such file or directory
    ==> ERROR: Build Failed.
    Aborting...
    Process makepkg exited abnormally with code 2
    the relevant error seems to be in
    src/lpi/lpi_imageformats.cpp:795:error: no matching function for call to 'CBitmap::GetBits(unsigned char*, size_t&, int)'
    src/lpi/lpi_imageformats.cpp:593: note: candidates are: bool CBitmap::GetBits(void*, unsigned int&)
    src/lpi/lpi_imageformats.cpp:607: note: void* CBitmap::GetBits()
    src/lpi/lpi_imageformats.cpp:614: note: bool CBitmap::GetBits(void*, unsigned int&, unsigned int)
    Last edited by Stefan Husmann (2010-03-07 12:39:07)

  • Paint program - layers

    Hi i am in the process of making a paint program and have decided to go through the (hopefully not) long process of using layers.
    at the moment all shapes, when drawn, are stored in a vector and then painted onto the graphics of a class extending JPanel.
    what i want to do is store them in separate images, all the size of the JPanel canvas (so they can be positioned at (0, 0)) and anyt area of the image that isnt part of the shape should be transparent.
    i have tried creating a new graphics object for each shape and then painting them onto an ARGB buffered image then storing all the images in a new vector and finally painting them onto the canvas however this isnt working.
    is there an easier way to do this, or does anybody know what has happened?
    thanks

    If they're in a vector, they're basically already in a kind of layered system, of course.
    If what you want is to have all the shapes live in their own coordinate system, and then be able to assign relative positions to draw their system in a larger coordinate system...well, I thought that Java2D already handled that. But if it doesn't, then rather than drawing in images, another thing you can do is create a class that represents a coordinate system. Basically, all it would have to do is have two state elements: a reference to a shape, and a reference to an (x,y) pair where you want to anchor that shape for drawing. Then your vector could hold these objects.
    It wouldn't have to be much more than:
    class Layer {
      private Shape shape;
      private Point location;
      // constructor that sets these; shape could be final, but location probably shouldn't be
      public void paint(Graphics g) {
        // maybe use AffineTransform to move the shape to the given location, then
        // paint it?
    }You should probably check on a forum that does more with GUIs though.
    But, if you want to, you can also make each layer just be an image. You'd gain some of the operations of images (like Graphics knowing how to scale them) but might lose image quality. There are a bunch of tutorials about double buffering that will tell you how to create an intermediate image; you could apply that to make multiple images, if you wanted to.

  • Creating Tcode for report painter program in 4.0B version?

    hi all,
    How to create a tcode for report painter program in 4.0 B?
    I searched the forums. but i couldn't find the same for 4.0 B?
    Please helo me to solve this?
    Thanks,
    Vamshi

    I am closing as no one answered and worked in alaternative way for the requirement.

  • Help with a Paint Program if you'd be kind

    Hi, I am making a simple paint package...like simple Paint in Windows, I am trying to change the colour of the scribble line, so I have a button to click and then it scribbles on my panel in a different colour....i.e changing from Black to Red.
    I'm new to all this, so I'm not getting that far, but I know a little...
    I have the following code......
    (this is in a seperate panel.java file
    public void lineTo2(int x, int y) {
    Graphics2D g2 = currImage.createGraphics();
    line.setLine(lastX, lastY, x, y);
    g2.setPaint(Color.black);
    g2.setStroke(stroke);
    g2.draw(line);
    moveTo(x,y);
    g2.dispose();
    repaint();
    and then in my other .java file I have the following to use the buttons.......
    public void actionPerformed(ActionEvent event) {
    Object source = event.getSource();
    if (source == undoButton)
    myDrawing.undo();
    else if (source == exitButton)
    System.exit(0);
    else if (source == exitItem)
    System.exit(0);
    else if (source == redButton)
    repaint();
    ....so I don't quite know what method to use with the Red Button so that it only changes to red when I click that button?
    Any help would be great, and I'm sorry if my terminology is not that of an experienced programmer!
    Many Thanks
    Jon(UK)

    Have a member variable containing the current drawing colour. You then just need to change that when the button is pressed:
    private Color paintColor = Color.black; // Initial colour
    public void lineTo2(...)
      g2.setPaint(paintColor);
    public void actionPerformed(...)
      else if(source == redButton)
        paintColor = Color.red;
      else if(source == blackButton)
        paintColor = Color.black;
    }Hope this helps.

  • I need ready code for a simple paint program today

    hi all I need ready code for a simple paint program today for me ics projct
    plz give me a halp on this give me what you have with you and it is so good if it look like this :
    Design a GUI based drawing Java application that works like a simple paint program
    1-There should be a number of buttons for choosing different shapes to draw. For example, there should be a button for rectangle. If user presses the rectangle button, then he can draw a rectangle using mouse. Similarly, there should be a button for each shape(rectangle, circle, ellipse, and line etc.
    2-The shapes can be filled with different colors.
    3-There should be option of moving .
    4- There should also be three menus including File, Shape, and Color menu.
    i. File menu can have menu items New and Exit. If user selects New, the drawing area will be cleared and all shapes will be erased.
    ii. Shape menu will serve the same purpose as of feature 2 described above. It will have menu items for drawing all the different shapes. For example, there will be menu item for rectangle; so user can draw a rectangle by selecting the menu item for rectangle.
    iii. Color menu will serve the same purpose as of feature 3 described above. It will have menu items for all the colors which are shown in color buttons. The user can select a color from this menu and then click inside a shape to fill it with the selected color.

    Read the Swing tutorial. There are sections on how to use menus and painting and all other kinds of stuff you need to do this homework assignment. Nobody here is going to write the code for you:
    http://java.sun.com/docs/books/tutorial/uiswing/TOC.html

  • Help with Paint program.

    Hello. I am somewhat new to Java and I was recently assigned to do a simple paint program. I have had no trouble up until my class started getting into the graphical functions of Java. I need help with my program. I am supposed to start off with a program that draws lines and changes a minimum of 5 colors. I have the line function done but my color change boxes do not work and I am able to draw inside the box that is supposed to be reserved for color buttons. Here is my code so far:
    // Lab13110.java
    // The Lab13 program assignment is open ended.
    // There is no provided student version for starting, nor are there
    // any files with solutions for the different point versions.
    // Check the Lab assignment document for additional details.
    import java.applet.Applet;
    import java.awt.*;
    public class Lab13110 extends Applet
         int[] startX,startY,endX,endY;
         int currentStartX,currentStartY,currentEndX,currentEndY;
         int lineCount;
         Rectangle red, green, blue, yellow, black;
         int numColor;
         Image virtualMem;
         Graphics gBuffer;
         int rectheight,rectwidth;
         public void init()
              startX = new int[100];
              startY = new int[100];
              endX = new int[100];
              endY = new int[100];
              lineCount = 0;
              red = new Rectangle(50,100,25,25);
              green = new Rectangle(50,125,25,25);
              blue = new Rectangle(50,150,25,25);
              yellow = new Rectangle(25,112,25,25);
              black = new Rectangle(25,137,25,25);
              numColor = 0;
              virtualMem = createImage(100,600);
              gBuffer = virtualMem.getGraphics();
              gBuffer.drawRect(0,0,100,600);
         public void paint(Graphics g)
              for (int k = 0; k < lineCount; k++)
                   g.drawLine(startX[k],startY[k],endX[k],endY[k]);
              g.drawLine(currentStartX,currentStartY,currentEndX,currentEndY);
              g.setColor(Color.red);
              g.fillRect(50,100,25,25);
              g.setColor(Color.green);
              g.fillRect(50,125,25,25);
              g.setColor(Color.blue);
              g.fillRect(50,150,25,25);
              g.setColor(Color.yellow);
              g.fillRect(25,112,25,25);
              g.setColor(Color.black);
              g.fillRect(25,137,25,25);
              switch (numColor)
                   case 1:
                        g.setColor(Color.red);
                        break;
                   case 2:
                        g.setColor(Color.green);
                        break;
                   case 3:
                        g.setColor(Color.blue);
                        break;
                   case 4:
                        g.setColor(Color.yellow);
                        break;
                   case 5:
                        g.setColor(Color.black);
                        break;
                   case 6:
                        g.setColor(Color.black);
                        break;
              g.setColor(Color.black);
              g.drawRect(0,0,100,575);
         public boolean mouseDown(Event e, int x, int y)
              currentStartX = x;
              currentStartY = y;
              if(red.inside(x,y))
                   numColor = 1;
              else if(green.inside(x,y))
                   numColor = 2;
              else if(blue.inside(x,y))
                   numColor = 3;
              else if(yellow.inside(x,y))
                   numColor = 4;
              else if(black.inside(x,y))
                   numColor = 5;
              else
                   numColor = 6;
              repaint();
              return true;
         public boolean mouseDrag(Event e, int x, int y)
              int Rectheight = 500;
              int Rectwidth = 900;
              currentEndX = x;
              currentEndY = y;
              Rectangle window = new Rectangle(0,0,900,500);
              //if (window.inside(Rectheight,Rectwidth))
                   repaint();
              return true;
         public boolean mouseUp(Event e, int x, int y)
              int Rectheight = 500;
              int Rectwidth = 900;
              startX[lineCount] = currentStartX;
              startY[lineCount] = currentStartY;
              endX[lineCount] = x;
              endY[lineCount] = y;
              lineCount++;
              Rectangle window = new Rectangle(0,0,900,500);
              if (window.inside(Rectheight,Rectwidth))
                   repaint();
              return true;
         public void Rectangle(Graphics g, int x, int y)
              g.setColor(Color.white);
              Rectangle screen = new Rectangle(100,0,900,600);
    }If anyone could point me in the right direction of how to go about getting my buttons to work and fixing the button box, I would be greatly appreciative. I just need to get a little bit of advice and I think I should be good after I get this going.
    Thanks.

    This isn't in any way a complete solution, but I'm posting code for a mouse drag outliner. This may be preferable to how you are doing rectangles right now
    you are welcome to use and modify this code but please do not change the package and make sure that you tell your teacher where you got it from
    MouseDragOutliner.java
    package tjacobs.ui;
    import java.awt.BasicStroke;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Point;
    import java.awt.Stroke;
    import java.awt.event.*;
    import java.util.ArrayList;
    import java.util.Iterator;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    * See the public static method addAMouseDragOutliner
    public class MouseDragOutliner extends MouseAdapter implements MouseMotionListener {
         public static final BasicStroke DASH_STROKE = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL, 10.0f, new float[] {8, 8}, 0);
         private boolean mUseMove = false;
         private Point mStart;
         private Point mEnd;
         private Component mComponent;
         private MyRunnable mRunner= new MyRunnable();
         private ArrayList mListeners = new ArrayList(1);
         public MouseDragOutliner() {
              super();
         public MouseDragOutliner(boolean useMove) {
              this();
              mUseMove = useMove;
         public void mouseDragged(MouseEvent me) {
              doMouseDragged(me);
         public void mousePressed(MouseEvent me) {
              mStart = me.getPoint();
         public void mouseEntered(MouseEvent me) {
              mStart = me.getPoint();
         public void mouseReleased(MouseEvent me) {
              Iterator i = mListeners.iterator();
              Point end = me.getPoint();
              while (i.hasNext()) {
                   ((OutlineListener)i.next()).mouseDragEnded(mStart, end);
              //mStart = null;
         public void mouseMoved(MouseEvent me) {
              if (mUseMove) {
                   doMouseDragged(me);
         public     void addOutlineListener(OutlineListener ol) {
              mListeners.add(ol);
         public void removeOutlineListener(OutlineListener ol) {
              mListeners.remove(ol);
         private class MyRunnable implements Runnable {
              public void run() {
                   Graphics g = mComponent.getGraphics();
                   if (g == null) {
                        return;
                   Graphics2D g2 = (Graphics2D) g;
                   Stroke s = g2.getStroke();
                   g2.setStroke(DASH_STROKE);
                   int x = Math.min(mStart.x, mEnd.x);
                   int y = Math.min(mStart.y, mEnd.y);
                   int w = Math.abs(mEnd.x - mStart.x);
                   int h = Math.abs(mEnd.y - mStart.y);
                   g2.setXORMode(Color.WHITE);
                   g2.drawRect(x, y, w, h);
                   g2.setStroke(s);
         public void doMouseDragged(MouseEvent me) {
              mEnd = me.getPoint();
              if (mStart != null) {
                   mComponent = me.getComponent();
                   mComponent.repaint();
                   SwingUtilities.invokeLater(mRunner);
         public static MouseDragOutliner addAMouseDragOutliner(Component c) {
              MouseDragOutliner mdo = new MouseDragOutliner();
              c.addMouseListener(mdo);
              c.addMouseMotionListener(mdo);
              return mdo;
         public static interface OutlineListener {
              public void mouseDragEnded(Point start, Point finish);
         public static void main(String[] args) {
              JFrame f = new JFrame("MouseDragOutliner Test");
              Container c = f.getContentPane();
              JPanel p = new JPanel();
              //p.setBackground(Color.BLACK);
              c.add(p);
              addAMouseDragOutliner(p);
              f.setBounds(200, 200, 400, 400);
              f.addWindowListener(new WindowClosingActions.Exit());
              f.setVisible(true);
    }

  • Cant open PC Paint files with Appleworks paint program

    I have been using the very simple Paint program that comes with windows. I have finally made the move and ditched the PC for something more stable.
    When I try to import my .bmp pictures I used to work on into Appleworks it insists on opeing the Drawing program that has no "fill" etc. Even when I open the Paint program and then "force" it to open a .bmp only part of the picture is shown. I thought that a .bmp is pretty basic and common file type.
    Does anyone know if Appleworks can handle .bmp files and if not what are other options. I didn't really feel the need to have a $170 paint program for what I am doing.
    Hope you can help.
    Michael

    Dale,
    Thanks for your reply.
    The problem is that I need to use the "fill" in the paint program.
    I have actually just been able to get the file to load into Appleworks paint after reading about using the .pict save. All looked good untill I tried to fill. What happens now is that the fill is very chunky and does not bleed thru at all. This makes it pretty useless at the moment.
    Same problem, with a twist now.
    Looking forward to any further ideas.
    Michael

  • I am making a Conference/Event program book.  Are there mac programs or apps that could help me design this?

    I am making a Conference/Event program book.  Are there mac programs or apps that could help me design this?

        I can see that this issue has been quite extensive, and frustrating, and I am so sorry for all that has happened societygirl! I would like to help you work this issue out. Please follow & send me a Direct Message, so I can get your account specifics and help finally bring this to a resolution.
    Thank you,
    MichelleH_VZW
    Follow us on Twitter @VZWSupport

  • Paint program : exporting image data ?

    i have a simple paint program that allows me to draw by freehand.
    If i have 2 canvas, and i draw on one, how would i update the other one in real time ?
    i want to create a multiplayer game based on Pictionary (guess the drawing, like charades). So I i need to know the best way to extract the screen information of the drawing from one canvas and import it into another one.
    My paint program consists of JPanel MouseListener to draw.
    Thanks

    also im using code similar to the paint program used here
    http://forum.java.sun.com/thread.jspa?threadID=571193&messageID=2827280
    but one problem... if i resize, minimize or load a window on top of it, the painted image disappears, what do i need to modify to redraw it ?
    thanks

  • Program to work like PC Paint program

    I need to enlarge a stain glass pattern.
    On my old PC I could "open an image" into the Paint program and do "Scale" to 200% and it would break up the image into 4 pages that I tape to make one large pattern.
    On my old G4 computer there is a program that does the same thing (painter I think).
    On my new Tiger OS when you use the "scale" function and say 200% it only prints a small portion on 1 page. In print >preview it only has 1 page where the old program previews the sections on all 4 pages.
    Does anyone know how to do it on the tiger computers?
    I'm sure it's something easy I'm missing.
    Thanks!

    Another possibility:
    http://www.luxordevelopment.ch/posterprint/?lang=en

  • Paint program saving

    My paint program has the ability to draw rectangles, ovals, and lines. I want to be able to save my picture which is drawn on a DrawingPanel. Everything that I add to the picture is stored in private ArrayList<Shape> shapes = new ArrayList<Shape>(); This saves something because a file is created with the file name I specified, but when I open the file, my drawing panel remains blank. What do I do so that I am able to save the art I have created on my Drawing Panel?
    /** Open file */
           private void open()
             if (jFileChooser1.showOpenDialog(this) ==
               JFileChooser.APPROVE_OPTION)
                    open(jFileChooser1.getSelectedFile());
           /** Open file with the specified File instance */
           private void open(File file)
             try
                    BufferedInputStream in = new BufferedInputStream(
                 new FileInputStream(file));
                    in.close();
                    JOptionPane.showMessageDialog(null, file.getName() + " Opened");
             catch (IOException ex)
                    JOptionPane.showMessageDialog(null, "Error opening " + file.getName());
           /** Save file */
           private void save()
             if (jFileChooser1.showSaveDialog(this) ==
               JFileChooser.APPROVE_OPTION)
                 save(jFileChooser1.getSelectedFile());
           /** Save file with specified File instance */
           private void save(File file)
             try
                  BufferedOutputStream out = new BufferedOutputStream(
                     new FileOutputStream(file));
                    out.close();
                    JOptionPane.showMessageDialog(null, file.getName()  + " Saved ");
             catch (IOException ex)
                  JOptionPane.showMessageDialog(null, "Error saving " + file.getName());
           }

    On save, you are creating the file and imediately closing it (which will create an empty file).
    On load, you are opening that file and imediately closing it (which will not read anything).
    I think, you are missing something here. Probably to do with serialization, ObjectOutputStream and ObjectInputStream.
    Google for a serialisation tutorial if you don't know how to do that.

  • Paint program

    please anyone help me in this:-
    i want when i press button(line)
    appear sign like (+) and draw line in any direction
    please how can i do this ..
    please anyone help me.
    thanks in advance

    first :- thanks my friend for your answer.
    but i can't do anything in paint program .. i'm very annoying
    this my code :
    i hope anyone show to me how can draw line in texarea in my code .
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.ObjectInputStream;
    import java.util.Vector;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    public class Paint extends JFrame {
        private JMenuBar bar;
        private JMenu fileMenue;
        private JMenuItem openItem,  saveItem,  aboutItem,  exitItem;
        private ObjectInputStream ois;
        private Vector vFile;
       // private CanvasPanel canvaspanel;
        public Paint() {
            super("Paint program");
            bar = new JMenuBar();
            fileMenue = new JMenu("File");
            openItem = new JMenuItem("open");
            fileMenue.add(openItem);
       //     openItem.addActionListener(new HandlerListener());
            saveItem = new JMenuItem("save");
            fileMenue.add(saveItem);
            aboutItem = new JMenuItem("About");
            fileMenue.add(aboutItem);
            setJMenuBar(bar);
            bar.add(fileMenue);
            add(new Component());
        public static void main(String[] args) {
            Paint paint = new Paint();
            paint.setVisible(true);
            paint.setLocationRelativeTo(null);
            paint.pack();
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    import javax.swing.JToolBar;
    import javax.swing.border.TitledBorder;
    class Component extends JPanel {
        private ButtonTest buttontest;
        private JToolBar toolBar;
        private JButton lineButton,RectButton,ovalButton,polyButton,colorButton,rubberButton;
        private JTextArea area;
        private JPanel titlePanel;
        public Component() {
            setLayout(new BorderLayout());
            toolBar=new JToolBar();
            lineButton=new JButton("line");
            lineButton.setToolTipText("Drawing line");
            lineButton.addActionListener(this);           
             RectButton=new JButton("Rectangle");
            RectButton.setToolTipText("Drawing Rectangle");
            ovalButton=new JButton("Oval");
            ovalButton.setToolTipText("Drawing Oval");
            polyButton=new JButton("polygan");
            polyButton.setToolTipText("Drawing polygan");
            toolBar.add(lineButton,BorderLayout.PAGE_START);
            toolBar.add(RectButton);
            toolBar.add(ovalButton);
            toolBar.add(polyButton);
            add(toolBar,BorderLayout.NORTH);
            area=new JTextArea(20,30);
            area.setBackground(Color.LIGHT_GRAY);
            add(area);
           // setLayout(new GridLayout(0,2));
             titlePanel=new JPanel();
             TitledBorder titleColor;
             titleColor=BorderFactory.createTitledBorder("Component list");
             titlePanel.setBorder(titleColor);
             colorButton=new JButton("   Colors   ");
             rubberButton=new JButton("Rubber");
             titlePanel.setLayout(new GridLayout(0,1));
             titlePanel.add(colorButton,BorderLayout.NORTH);
             titlePanel.add(rubberButton,BorderLayout.SOUTH);
             add(titlePanel,BorderLayout.WEST);
        public void actionPerformed(ActionEvent e){
            if(e.getSource()==lineButton)
                ButtonTest
    public Dimension getPrefereSize(){
            return new Dimension(600,500);
    import java.awt.Graphics;
    import java.awt.Point;
    import org.w3c.dom.events.MouseEvent;
    class ButtonTest implements MouseListener, MouseMotionListener {
        String[] Shape={"LINE","Oval","Rectangle","polygan"};
       Point p;
        int x1,y1,x2,y2,width,height;
        public ButtonTest()
        public void DrawingLine(Graphics g){
            g.drawLine(x1, y1, x2, y1);
            mousePressed(MouseEvent e);
            mouseDragged(MouseEvent e);
        public void mousePressed(MouseEvent e) {
          p=e.getPoint();
        public void mouseDragged(MouseEvent e){
            rePaint();
            getGraphics().drawLine(p.x1, p.y1, e.getX(),  e.getY());//draw line from start point to current mouse position
        private Object getGraphics() {
            throw new UnsupportedOperationException("Not yet implemented");
        private void rePaint() {
            throw new UnsupportedOperationException("Not yet implemented");
    i know there is a lot of error in my code but i can't to correct it so please any one help me
    to correct my error and to draw only line in any direction in textarea
    thanks my friends

Maybe you are looking for