-
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.
-
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.
-
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);
}
}
-
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
-
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);
}
Page generated in 1,751,311,916.35428 seconds with 10 queries