/ Published in: Java
This trick improves repaint rate in Win7+Aero: setting resizable to null, and providing own resize hook. Its aint perfect, but still alot better.. check my example:
Expand |
Embed | Plain Text
/* * resizing swing trick in Win7+Aero demo * @author: s1w_ /pj`s3826 */ import java.awt.event.*; import java.awt.*; import javax.swing.event.*; import javax.swing.*; private final static int width = 580, height = 350; public ResizeHookDemo() { @Override super.paint(g); int w = getWidth(); int h = getHeight(); g.drawLine(w-7, h, w, h-7); g.drawLine(w-11, h, w, h-11); g.drawLine(w-15, h, w, h-15); gp.moveTo(w-17, h); gp.lineTo(w, h-17); gp.lineTo(w, h); gp.closePath(); } }; if (e.getActionCommand().equals("CancelSelection")) { setVisible(false); // action... } else if (e.getActionCommand().equals("ApproveSelection")) { setVisible(false); // action... } } }); if (gp.contains(e.getPoint())) } startPos = null; } if (gp.contains(e.getPoint())) else } if (startPos != null) { int dx = e.getX() + startPos.x; int dy = e.getY() + startPos.y; setSize(dx, dy); repaint(); } } }; fc.addMouseMotionListener(resizeHook); fc.addMouseListener(resizeHook); add(fc); setResizable(false); setDefaultCloseOperation(HIDE_ON_CLOSE); setLocationRelativeTo(null); } @Override public void run() { new ResizeHookDemo().setVisible(true); } }); } }
You need to login to post a comment.
