How to drawing on image.

Hi,
I am developing one paint program. I am drawing over an image but the image is wash out when i am dragging mouse on canvas. But when i am clicking first on canvas before selecting any button. then selecting button after that it is working fine. Please help me
Thanks in advance.
Manveer

The graphics context of your display object will erase when a repaint event is encountered--system generated or by code. If you do not have a persistent object displaying or the paint method does not containt the instruction to reproduce your image, then guess what? That's right you loose the image.
You can paint to a BufferedImage and then do a drawImage in the overridden paint/paintComponent (AWT/SWING) of your display object. Without doing something like this, your image will dissapear mysteriously every time a system generated repaint happens.

Similar Messages

  • How to draw an image at the center of a JscrollPane

    I have an image that I want to be centered in my JScrollPane. When I zoom-in, I want the image to fill the entire jscrollpane. When I zoom out it returns to the original scale. My problem is, when I open the image, it appears at the upper left corner of the JScrollPane. I want it centered. Also, when I zoom-in, it gets larger than the scrollpane. That is it goes beyond the boundaries of the JScrollpane. The function I am using to draw the image is:
    Image img = imp.getImage();
                   if (img!=null)
                        g.drawImage(img,0,0, (int)(srcRect.width*magnification), (int)(srcRect.height*magnification),
                        srcRect.x, srcRect.y, srcRect.x+srcRect.width, srcRect.y+srcRect.height, null);If I change the initial x,y values from (0,0) to any other value, it grays the upper left corner. So forinstance, if I did the following, the upper left corner of the scrollpane would become gray.
    g.drawImage(img,100,200, (int)(srcRect.width*magnification), (int)(srcRect.height*magnification),
                        srcRect.x, srcRect.y, srcRect.x+srcRect.width, srcRect.y+srcRect.height,null);How can I center my image in the scrollpane?

    When I zoom-in, I want the image to fill the entire jscrollpane. When I zoom out it returns to the original scaleSo why are you using a scroll pane? A scroll pane is used when its contents can potentially be larger than the scrollpane.
    Although it wasn't originally designed for this purpose you can probably use my [Background Panel|http://www.camick.com/java/blog.html?name=background-panel]. It supports displaying an image at its actual size as well as scaled to fit the panel. So you should just be able to toggle the style as required.

  • How to draw transparent image?

    i'm developing a java game, i wonder how to draw a transparent image, i'm using Image class, and Graphics class.

    http://search.java.sun.com/search/java/index.jsp?qp=forum%3A20&nh=10&qt=%2Btransparent+%2Bimage&col=javaforums

  • How to draw an image on transparent JPanel?

    I want to draw an image on the transparent JPanel. How to do it?
    I do like this:
    ( In constructor )
    setOpaque(false);
    String imageName = "coral.jpg";
    iimage_Bg = Toolkit.getDefaultToolkit().getImage(imageName);
    ( In paintComponent( Graphics g ) )
    Graphics2D g2D = (Graphics2D) g;
    g2D.drawImage( iimage_Bg, 0, 0, getWidth() , getHeight() , Color.white, null );
    But it doesn't work. Please help me!
    Thank you very much.
    coral9527

    Check the values that are returned from getWidth() and getHeight(). If they either are zero, then paintComponent(Graphics g) never gets called by the components paint(Graphics g) method. I cannot see the how this component has been added or displayed so can give no advice on how you can guarantee getting a valid size. If you have simply added it to a JFrame and called pack(), the size will be zero, as the panel does not contain any components (you would not have this problem if you were adding a JLabel with an ImageIcon for example). Try not packing the frame, and giving it a valid size.

  • How to draw an Image on a JPanel?

    Hi all,
    Can any one give code for drawing an image on a JPanel?
    thanks,
    amar

    That's for the JLabel right? ... For a JPanel on a JFrame, you could do something like this:
    import java.awt.*;
    import java.awt.image.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.io.*;
    import java.net.URL;
    public class TestImagePaint  extends JFrame {
      private BjPanel bjp;
      public TestImagePaint( String imageName )   throws IllegalArgumentException {
        if ( imageName == null  ||  !( new File( imageName ).isFile() ) ) {
          throw new IllegalArgumentException( "\nIn TestImagePaint constuctor"
                                             +"\t IllegalArgumentException:" );
        bjp = new BjPanel( imageName );
        getContentPane().add( bjp );
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        pack();
        setBounds( 100, 100, 400, 300 );
        setVisible( true );
      public static void main( String[] argv ) {
        new TestImagePaint( argv[0] );
      public class BjPanel  extends JPanel {
        private URL   url;
        private Image image;
        public BjPanel( String imageName ) {
          try {
            url   = BjPanel.class.getResource( imageName );
            image = Toolkit.getDefaultToolkit().getImage( url );
            repaint();
          catch( Exception e ) {
            System.out.println( "Can't get Image: "+imageName+"\n\t"+e );
            System.exit( -1 );
        public void paint(Graphics g) {
          g.drawImage( image, 0, 0, this );
    }

  • How to draw an Image on a BufferedImage in a class that is not a Component?

    I have an Image object loaded from a file using Toolkit, I want to draw it on a BufferedImage using g.drawImage( x, y, width, height, ImageObserver );
    later on I want to save the BufferedImage in a jpeg file using the converter.
    Since my class is not a subclass of Component (Panel, Applet, Canvas... ) what do I pass along as ImageObserver, nothing seems to be working, I can draw anything using g.draw... except an Image.
    Thanks...
    Fco. Espaillat

    Try extending ImageObserver. You only have to implement one method, and its hardly an implementation. I ussually have that method return true regardless of what is going on and it works.
    But to discourage bad programming style does anyone there know what that method is suppossed to return and how to find that out?

  • How to draw an image onto a canvas3d?

    hi,
    i managed to draw onto a canvas 3d overwriting postRender() of canvas3d.
      public void postRender()
        J3DGraphics2D g = getGraphics2D();
        //  TEST BEGINN
          Image pic = this.getToolkit().createImage("Graphics" + File.separator + "start2.png");
          MediaTracker helpMT = new MediaTracker(this);
          helpMT.addImage(pic,0);
          try{
            helpMT.waitForAll();
          } catch(InterruptedException e) {}
          g.drawImage(pic,10,10,200,200,this);
          g.setColor(Color.yellow);
          g.drawString("yellow",20,300);
          g.setPaintMode();
          g.setColor(Color.red);
          g.drawString("red",20,320);
          g.setColor(Color.green);
          g.drawString("green",20,340);
          g.setColor(Color.orange);
          g.drawString("orange",20,360);
          g.flush(true);
        //  TEST ENDE
      }However the colors are totally messed up. red is purple, for example, and images are also shown with the wrong colors. What am I doin wrong, and how can I fix it?
    thanx,
    Usul

    Please, Im stuck.
    Here are the only two classes needed:
    Test2d.class:
    import java.awt.*;
    import com.sun.j3d.utils.universe.*;
    import javax.media.j3d.*;
    import javax.swing.*;
    public class Test2d extends JFrame
      public Test2d ()
        getContentPane().setLayout(new BorderLayout());
        Canvas3D c = new Visual_Canvas3D(SimpleUniverse.getPreferredConfiguration());
        getContentPane().add("Center", c);
        SimpleUniverse simpleU = new SimpleUniverse(c);
        BranchGroup scene = new BranchGroup();
        simpleU.getViewingPlatform().setNominalViewingTransform();
        scene.compile();
        simpleU.addBranchGraph(scene);
       public static void main(String[] args)
         Test2d mainApp = new Test2d();
         mainApp.setSize(800,600);
         mainApp.show();
    }Visual_Canvas3D.class:
    import java.awt.*;
    import javax.media.j3d.*;
    public class Visual_Canvas3D
    extends Canvas3D
      public Visual_Canvas3D(GraphicsConfiguration gc)
        super(gc);
      public void postRender()
          J3DGraphics2D g = getGraphics2D();
          g.setColor(Color.red);
          g.drawString("red",20,320);
          g.setColor(Color.green);
          g.drawString("green",20,340);
          g.setColor(Color.orange);
          g.drawString("orange",20,360);
          g.setColor(Color.yellow);
          g.drawString("yellow",20,100);
          g.flush(false);
    }Where could be the problem?

  • Load and draw an image

    frist ... sorry for my english.
    i'm loading an image with this code
              try {
                   String imgStr1 = "img/Os1.jpg";
                   String imgStr2 = "img/Os2.jpg";
                   img1 = ImageIO.read(new File(imgStr1));
                   img2 = ImageIO.read(new File(imgStr2));
              catch (IOException e) {
                   JOptionPane.showMessageDialog(null, "No se pudo cargar las imagenes: " + e, "ALERT!!", JOptionPane.ERROR_MESSAGE);
    but i don't know how to draw the image
    please help me
    thanks

    Use ImageIcon on a JLabel.

  • How to use the Rectangle class to draw an image and center it in a JPanel

    I sent an earlier post on how to center an image in a JPanel using the Rectangle class. I was asked to send an executable code which will show the malfunction. The code below is an executable code and a small part of a very big project. To simplifiy things, it is just a JFrame and a JPanel with an open dialog. Once executed the JFrame and the FileDialog will open. You can then navigate to a .gif or a .jpg picture and open it. What I want is for the picture to be centered in the middle of the JPanel and not the upper left corner. It is also important to stress that, I am usinig the Rectangle class to draw the Image. The region of interest is where the rectangle is created. In the constructor of the CenterRect class, I initialize the Rectangle class. Then I use paintComponent in the CenterRect class to draw the Image. The other classes are just support classes. The MyImage class is an extended image class which also has a draw() method. Any assistance in getting the Rectangle to show at the center of the JPanel without affecting the size and shape of the image will be greatly appreciated.
    I have divided the code into three parts. They are all supposed to be on one file in order to execute.
    import java.awt.*;
    import java.awt.image.*;
    import javax.swing.*;
    public class CenterRect extends JPanel {
        public static Rectangle srcRect;
        Insets insets = null;
        Image image;
        MyImage imp;
        private double magnification;
        private int dstWidth, dstHeight;
        public CenterRect(MyImage imp){
            insets = getInsets();
            this.imp = imp;
            int width = imp.getWidth();
            int height = imp.getHeight();
            ImagePanel.init();
            srcRect = new Rectangle(0,0, width, height);
            srcRect.setLocation(0,0);
            setDrawingSize(width, height);
            magnification = 1.0;
        public void setDrawingSize(int width, int height) {
            dstWidth = width;
            dstHeight = height;
            setSize(dstWidth, dstHeight);
        public void paintComponent(Graphics g) {
            Image img = imp.getImage();
         try {
                if (img!=null)
                    g.drawImage(img,0,0, (int)(srcRect.width*magnification), (int)(srcRect.height*magnification),
              srcRect.x, srcRect.y, srcRect.x+srcRect.width, srcRect.y+srcRect.height, null);
            catch(OutOfMemoryError e) {e.printStackTrace();}
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new Opener().openImage();
    class Opener{
        private String dir;
        private String name;
        private static String defaultDirectory;
        JFrame parent;
        public Opener() {
            initComponents();
         public void initComponents(){
            parent = new JFrame();
            parent.setContentPane(ImagePanel.panel);
            parent.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            parent.setExtendedState(JFrame.MAXIMIZED_BOTH);
            parent.setVisible(true);
        public void openDialog(String title, String path){
            if (path==null || path.equals("")) {
                FileDialog fd = new FileDialog(parent, title);
                defaultDirectory = "dir.image";
                if (defaultDirectory!=null)
                    fd.setDirectory(defaultDirectory);
                fd.setVisible(true);
                name = fd.getFile();
                if (name!=null) {
                    dir = fd.getDirectory();
                    defaultDirectory = dir;
                fd.dispose();
                if (parent==null)
                    return;
            } else {
                int i = path.lastIndexOf('/');
                if (i==-1)
                    i = path.lastIndexOf('\\');
                if (i>0) {
                    dir = path.substring(0, i+1);
                    name = path.substring(i+1);
                } else {
                    dir = "";
                    name = path;
        public MyImage openImage(String directory, String name) {
            MyImage imp = openJpegOrGif(dir, name);
            return imp;
        public void openImage() {
            openDialog("Open...", "");
            String directory = dir;
            String name = this.name;
            if (name==null)
                return;
            MyImage imp = openImage(directory, name);
            if (imp!=null) imp.show();
        MyImage openJpegOrGif(String dir, String name) {
                MyImage imp = null;
                Image img = Toolkit.getDefaultToolkit().getImage(dir+name);
                if (img!=null) {
                    imp = new MyImage(name, img);
                    FileInfo fi = new FileInfo();
                    fi.fileFormat = fi.GIF_OR_JPG;
                    fi.fileName = name;
                    fi.directory = dir;
                    imp.setFileInfo(fi);
                return imp;
    }

    This is the second part. It is a continuation of the first part. They are all supposed to be on one file.
    class MyImage implements ImageObserver{
        private int imageUpdateY, imageUpdateW,width,height;
        private boolean imageLoaded;
        private static int currentID = -1;
        private int ID;
        private static Component comp;
        protected ImageProcessor ip;
        private String title;
        protected Image img;
        private static int xbase = -1;
        private static int ybase,xloc,yloc;
        private static int count = 0;
        private static final int XINC = 8;
        private static final int YINC = 12;
        private int originalScale = 1;
        private FileInfo fileInfo;
        ImagePanel win;
        /** Constructs an ImagePlus from an AWT Image. The first argument
         * will be used as the title of the window that displays the image. */
        public MyImage(String title, Image img) {
            this.title = title;
             ID = --currentID;
            if (img!=null)
                setImage(img);
        public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h) {
             imageUpdateY = y;
             imageUpdateW = w;
             imageLoaded = (flags & (ALLBITS|FRAMEBITS|ABORT)) != 0;
         return !imageLoaded;
        public int getWidth() {
             return width;
        public int getHeight() {
             return height;
        /** Replaces the ImageProcessor, if any, with the one specified.
         * Set 'title' to null to leave the image title unchanged. */
        public void setProcessor(String title, ImageProcessor ip) {
            if (title!=null) this.title = title;
            this.ip = ip;
            img = ip.createImage();
            boolean newSize = width!=ip.getWidth() || height!=ip.getHeight();
         width = ip.getWidth();
         height = ip.getHeight();
         if (win!=null && newSize) {
                win = new ImagePanel(this);
        public void draw(){
            CenterRect ic = null;
            win = new ImagePanel(this);
            if (win!=null){
                win.addIC(this);
                win.getCanvas().repaint();
                ic = win .getCanvas();
                win.panel.add(ic);
                int width = win.imp.getWidth();
                int height = win.imp.getHeight();
                Point ijLoc = new Point(10,32);
                if (xbase==-1) {
                    xbase = 5;
                    ybase = ijLoc.y;
                    xloc = xbase;
                    yloc = ybase;
                if ((xloc+width)>ijLoc.x && yloc<(ybase+20))
                    yloc = ybase+20;
                    int x = xloc;
                    int y = yloc;
                    xloc += XINC;
                    yloc += YINC;
                    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
                    count++;
                    if (count%6==0) {
                        xloc = xbase;
                        yloc = ybase;
                    int scale = 1;
                    while (xbase+XINC*4+width/scale>screen.width || ybase+YINC*4+height/scale>screen.height)
                        if (scale>1) {
                   originalScale = scale;
                   ic.setDrawingSize(width/scale, height/scale);
        /** Returns the current AWT image. */
        public Image getImage() {
            if (img==null && ip!=null)
                img = ip.createImage();
            return img;
        /** Replaces the AWT image, if any, with the one specified. */
        public void setImage(Image img) {
            waitForImage(img);
            this.img = img;
            JPanel panel = ImagePanel.panel;
            width = img.getWidth(panel);
            height = img.getHeight(panel);
            ip = null;
        /** Opens a window to display this image and clears the status bar. */
        public void show() {
            show("");
        /** Opens a window to display this image and displays
         * 'statusMessage' in the status bar. */
        public void show(String statusMessage) {
            if (img==null && ip!=null){
                img = ip.createImage();
            if ((img!=null) && (width>=0) && (height>=0)) {
                win = new ImagePanel(this);
                draw();
        private void waitForImage(Image img) {
        if (comp==null) {
            comp = ImagePanel.panel;
            if (comp==null)
                comp = new JPanel();
        imageLoaded = false;
        if (!comp.prepareImage(img, this)) {
            double progress;
            while (!imageLoaded) {
                if (imageUpdateW>1) {
                    progress = (double)imageUpdateY/imageUpdateW;
                    if (!(progress<1.0)) {
                        progress = 1.0 - (progress-1.0);
                        if (progress<0.0) progress = 0.9;
    public void setFileInfo(FileInfo fi) {
        fi.pixels = null;
        fileInfo = fi;
    }

  • How do I draw an image on a JPanel?

    To be honest I have no idea even where to start. I tried hacking through the tutorials but it just didn't help me (normally they do, I don't what's up).
    Anyway, so what I'm trying to do is build a game. The Graphics2D is great for simple shapes but drawing characters is getting kind of ridiculous (tedious + difficult + looks bad). So, I need to figure out how to display an image on a JPanel.
    To that end I have several questions.
    1 - What image type do I use? Like jpeg, bmp, gif, etc.
    2 - How do I make parts of it transparent?
    3 - How do I make it appear on the screen, given some coordinates on the JPanel?

    To draw an image directly to a JPanel given certain coordinates, you have to create a custom JPanel and override its paintComponent() method. Like this:
    class PaintPanel extends JPanel{
    public void paintComponent(Graphics g){
    super.paintComponent(g);
    //painting code goes here}
    }Java can load in and draw GIF and JPEG images. If you decide to use GIF files, any good image editor like Adobe Photoshop should be able to make them transparent for you before the fact. If you want to set transparency within your java program you will have to create a BufferedImage and make certain colors within it transparent, but I would like to know how to do that as much as you do.

  • How to draw 2D shapes on the image generated by JMF MediaPlayer?

    Hello all:
    IS there any way that we can draw 2D shapes on the image generated by JMF
    MediaPlayer?
    I am currently working on a project which should draw 2D shapes(rectangle, circle etc) to
    mark the interesting part of image generated by JMF MediaPlayer.
    The software is supposed to work as follows:
    1> first use will open a mpg file and use JMF MediaPlayer to play this video
    2> if the user finds some interesting image on the video, he will pause the video
    and draw a circle to mark the interesting part on that image.
    I know how to draw a 2D shapes on JPanel, however, I have no idea how I can
    draw them on the Mediaplayer Screen.
    What technique I should learn to implement this software?
    any comments are welcome.
    thank you
    -Daniel

    If anyone can help?!
    thank you
    -Daniel

  • How can I draw an image in the browser using mouse

    I have to draw an image in the browser and have to store a file in the server and I don't know how can I do it. Is there anybody who konw it.

    Components other than applets cannot be downloaded into client machines
    unleess There is a Java Web Start kind of Mechanism present on client and the server also supports
    this .Hence your application is between Applet ---Xdownloadable ApplicationXX ---- traditinal Application

  • Help!How can i draw an image that do not need to be displayed?

    I want to draw an image and save it as an jpeg file.
    first I have to draw all the elements in an image object.I write a class inherit from Class Component,I want to use the method CreateImage,but I get null everytime.And i cannot use the method getGraphics of this object.Thus i can not draw the image.
    when i use an applet,it runs ok.I use panel and frame,and it fails.
    How can i draw an image without using applet,because my programme will be used on the server.
    Thank you.

    you could try this to create the hidden image
    try
              GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
              GraphicsDevice gs = ge.getDefaultScreenDevice();
              GraphicsConfiguration gc = gs.getDefaultConfiguration();
              offImage = gc.createCompatibleImage(100, 100);
              offG = offImage.getGraphics();
          catch(Exception e)
              System.out.println(e.getMessage());
          }

  • URGENT! : how to draw images?

    new to swing, wanna create an app using jframes but how do i draw my images? added 2 jpanels to my jframe to split the window into 2, 1 side for text, the other is for my images. but how do i draw them on the jpanel? read the java tutorial but it only shows me class xxx extends jpanel. must i do this? if i must, where shld my jframe be? really need some help right away cos i'm doing it for a project n deadline's coming soon...

    i attached the source code as following:(made by jbuilder)
    package untitled3;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Frame1 extends JFrame {
    private JPanel contentPane;
    private BorderLayout borderLayout1 = new BorderLayout();
    private JSplitPane jSplitPane1 = new JSplitPane();
    private JTextArea jTextArea1 = new JTextArea();
    private JPanel jPanel1 = new JPanel();
    //Construct the frame
    public Frame1() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    //Component initialization
    private void jbInit() throws Exception {
    //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(borderLayout1);
    this.setSize(new Dimension(400, 300));
    this.setTitle("Frame Title");
    jTextArea1.setText("jTextArea1");
    contentPane.add(jSplitPane1, BorderLayout.CENTER);
    jSplitPane1.add(jTextArea1, JSplitPane.LEFT);
    jSplitPane1.add(jPanel1, JSplitPane.RIGHT);
    //Overridden so we can exit when window is closed
    protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
    System.exit(0);
    package untitled3;
    import javax.swing.UIManager;
    import java.awt.*;
    public class Application1 {
    private boolean packFrame = false;
    //Construct the application
    public Application1() {
    Frame1 frame = new Frame1();
    //Validate frames that have preset sizes
    //Pack frames that have useful preferred size info, e.g. from their layout
    if (packFrame) {
    frame.pack();
    else {
    frame.validate();
    //Center the window
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = frame.getSize();
    if (frameSize.height > screenSize.height) {
    frameSize.height = screenSize.height;
    if (frameSize.width > screenSize.width) {
    frameSize.width = screenSize.width;
    frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    frame.setVisible(true);
    //Main method
    public static void main(String[] args) {
    try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    catch(Exception e) {
    e.printStackTrace();
    new Application1();
    }

  • How to draw image in different dpi?

    I wonder is there any approach can be used to draw a image in different dpi, such as 144dpi, in a JPanel?
    'cause my image processed from other tools is not good, if I can draw image in a high dpi, then the image will looks much better, though the image becomes smaller.
    Note: no SCALE!

    I have a image which is 152dpi, then, how does the Widows draws this image? It looks much better than scale the 72dpi image to the same size.
    Really puzzled-_-                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for

  • Duplicates and more in my address book

    hi, my address book is creating duplicates and triplicates etc. of each entry on it's own... everyday i "look for duplicates" and merge all the records, then the next day have duplicates and triplicates again. how do i stop this? at one point i was a

  • Can I choose not to broadcast the name of my AirPort Express?

    I would like to know if I can keep the name of my AirPort Express from being broadcast to other computers. On my old Netgear router I could choose to not broadcast the name but, I don't seem to see the option in the AirPort Base Station Utility. Powe

  • How to use ThreadPoolImpl class

    hi, I am trying to create a pool of threads uisng the below code(2 files). Can u explain me, why my code fails to call doWork() method written in the run() method of WorkerThread class. I tried debugging and I found that no more than the minimum thre

  • Converting a Server Back to a Regular Computer

    Greetings! I have an apple desktop that was being used as a server. I'm looking to convert it back to a regular computer but am not sure how to go about doing this. Any suggestions? Thanks so much!

  • JVM Loader Error: Unable to find supported JDK or JRE version

    Hello, I am trying to use Visibroker (Borland version 6.5) with JDK 1.5.2 When I try to run idl2java, it gives me the following message: JVM Loader Error: Unable to find a supported JDK or JRE version. The JVM Version should be either 1.3.1 or 1.4.1