Results 1 to 5 of 5

Thread: RepaintManager class

  1. #1
    Join Date
    Dec 2009
    Posts
    67

    RepaintManager class

    Hi Friend,

    I am beginners if the field of advanced java programming. And because of that I am getting lots of trouble while using the inbuilt classes and interfaces of advanced java. I am unable to understand the use of class 'class RepaintManager ' of java. If you posses the sound knowledge about the RepaintManager class, then please let me know the same. You help would be appreciated.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: RepaintManager class

    RepaintManager class of java is basically extended form package 'java.lang.Object'. The class RepaintManager is very important in advanced java as it use to manage the request of repaint. This process can be done by enabling the minimization of the number of repaints. The best example of this mechanism is: To collapse many request within a one repaint which is for the component tree members. RepaintManager class has only one constructor ans which is used while creation of the new instance of RepaintManager.

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    Re: RepaintManager class

    Hello friend,

    Please refer follwing jav example, which will depict you the use of class RepaintManager:
    Code:
    import javax.swing.JComponent;
    import javax.swing.RepaintManager;
    
    public class Main extends JComponent implements MouseMotionListener {
      static int imageWidth1 = 60, imageHeight1 = 60;
      int imageX1, imageY1;
      Image image1;
    
      public Main(Image i1) {
        image1 = i1;
        addMouseMotionListener(this);  }
      public void mouseDragged(MouseEvent e) {
        imageX1 = e.getX();
        imageY1 = e.getY();
        repaint();  }
    
      public void mouseMoved(MouseEvent e) {
      }
      public void paint(Graphics g) {
        Graphics2D g21 = (Graphics2D) g;
        g21.drawImage(image1, imageX1, imageY1, this);
      }
    
      public static void main(String[] arg) {
        String imageFile1 = "A1.jpg";
        RepaintManager.currentManager(null).setDoubleBufferingEnabled(false);
        Image image1 = Toolkit.getDefaultToolkit().getImage(Main.class.getResource(imageFile));
        image1 = image.getScaledInstance(imageWidth, imageHeight, Image.SCALE_DEFAULT);
        JFrame frame1 = new JFrame("DragImage");
        frame1.getContentPane().add(new Main(image1));
        frame1.setSize(300, 300);
        frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame1.setVisible(true);
      }
    }

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: RepaintManager class

    Following are the most used methods of 'RepaintManager class':
    • setCurrentManager(RepaintManager RepaintManagerName)
    • markCompletelyDirty(JComponent ComponentName)
    • removeInvalidComponent(JComponent componentName)
    • setDoubleBufferMaximumSize(Dimension dm)
    • isCompletelyDirty(JComponent ComponentName)

    If you want to know more about these methods then please visit below link:
    http://java.sun.com/j2se/1.5.0/docs/...ntManager.html

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    Re: RepaintManager class

    Hi,

    The RepaintManager class of java refers to the repaint of the java application windows. Below is the example of 'Class RepaintManager':
    Code:
    public static void main(String args[])
     {
        String imageFileDM = "VN.jpg";
        
        RepaintManager.currentManager(null).setDoubleBufferingEnabled(false);
    
        Image imageX = Toolkit.getDefaultToolkit().getImage(Main.class.getResource(imageFile));
        imageX = imageX.getScaledInstance(imageWidth, imageHeight, Image.SCALE_DEFAULT);
    
        JFrame frameX = new JFrame("DragImage");
        frameX.getContentPane().add(new Main(image));
        frameX.setSize(200, 200);
    
        frameX.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frameX.setVisible(true);
     
     }

Similar Threads

  1. Replies: 8
    Last Post: 08-10-2011, 11:06 PM
  2. Replies: 5
    Last Post: 12-02-2010, 06:23 PM
  3. Difference among concrete class and abstract class
    By Roxy_jacob in forum Software Development
    Replies: 4
    Last Post: 07-12-2009, 01:22 PM
  4. Ultra solid drives:Imation M-Class and S-Class
    By Regina in forum Portable Devices
    Replies: 1
    Last Post: 03-04-2009, 10:34 AM
  5. Good news for CBSE CLASS X & CLASS IX - visit learnnext
    By surya_expert in forum Education Career and Job Discussions
    Replies: 0
    Last Post: 13-12-2008, 12:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,297,365.46093 seconds with 16 queries