public static void renderDOT ( Reader r , boolean modal ) { final DOTComponent cmp = createDOTComponent ( r ) ; if ( cmp == null ) { return ; } final JDialog frame = new JDialog ( ( Dialog ) null , modal ) ; JScrollPane scrollPane = new JScrollPane ( cmp ) ; frame . setContentPane ( scrollPane ) ; frame . setMaximumSize ( new Dimension ( MAX_WIDTH , MAX_HEIGHT ) ) ; frame . pack ( ) ; JMenu menu = new JMenu ( "File" ) ; menu . add ( cmp . getSavePngAction ( ) ) ; menu . add ( cmp . getSaveDotAction ( ) ) ; menu . addSeparator ( ) ; menu . add ( new AbstractAction ( "Close" ) { private static final long serialVersionUID = - 1L ; @ Override public void actionPerformed ( ActionEvent e ) { frame . dispatchEvent ( new WindowEvent ( frame , WindowEvent . WINDOW_CLOSING ) ) ; } } ) ; JMenuBar menuBar = new JMenuBar ( ) ; menuBar . add ( menu ) ; frame . setJMenuBar ( menuBar ) ; frame . setDefaultCloseOperation ( JFrame . DISPOSE_ON_CLOSE ) ; frame . setVisible ( true ) ; frame . addKeyListener ( new KeyAdapter ( ) { @ Override public void keyTyped ( KeyEvent e ) { if ( e . getKeyChar ( ) == KeyEvent . VK_ESCAPE ) { frame . dispatchEvent ( new WindowEvent ( frame , WindowEvent . WINDOW_CLOSING ) ) ; } } } ) ; }
Renders a GraphVIZ description and displays it in a Swing window .