/** Install a debugging hotkey. When that key is pressed: a new
* <code>GraphicsWriterDebugger</code> frame will appear that paints
* the argument.
*
* @param component a component to debug. The <code>paint()</code> method
* of this argument will be used.
* @param keyCode a <code>KeyEven.VK_X</code> key code. When this key is
* pressed, the <code>GraphicsWriterDebugger</code> frame will be created.
*/
public static void installDebugHotkey(final Component component,final int keyCode) {
Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
public void eventDispatched(AWTEvent event) {
KeyEvent e = (KeyEvent)event;
if(e.getKeyCode()==keyCode && e.getID()==KeyEvent.KEY_PRESSED) {
GraphicsWriter writer = new GraphicsWriter(true);
component.paint(writer);
GraphicsWriterDebugger d = new GraphicsWriterDebugger(writer);
d.pack();
d.setVisible(true);
}
}
}, AWTEvent.KEY_EVENT_MASK);
}
GraphicsWriterDebugger.java 文件源码
java
阅读 32
收藏 0
点赞 0
评论 0
项目:pumpernickel
作者:
评论列表
文章目录