wt AWTUtilities setWindowOpaque(reflection false) } } }) this addWindowListener(new WindowAdapter() { @Override public void windowActivated(WindowEvent e) { // force showing the reflection window reflection setAlwaysOnTop(true) reflection setAlwaysOnTop(false) } }) 重畫管理器相當簡單 它強制主楨的整個根窗格重畫 然后更新反射窗口 這樣可以最優化更新區域反射的同步 對于示例應用程序要達到的目的 這點就足夠了
private class ReflectionRepaintManager extends RepaintManager { @Override public void addDirtyRegion(JComponent c int x int y int w int h) { Window win = SwingUtilities getWindowAncestor(c) if (win instanceof JReflectionFrame) { // mark the entire root pane to be repainted JRootPane rp = ((JReflectionFrame) win) getRootPane() super addDirtyRegion(rp rp getWidth() rp getHeight()) // workaround bug should call reflection repaint() // but that will not repaint the panel reflectionPanel repaint() } else { super addDirtyRegion(c x y w h) } } }主楨 (脫屏緩沖區) 和反射窗口的繪圖代碼在 Romain 的 反射教程 中進行了詳細描述
lishixin/Article/program/Java/hx/201311/25650
2024-07-18 12:37
2024-07-18 12:37
2024-07-18 12:03
2024-07-18 11:57
2024-07-18 11:54
2024-07-18 11:28