/** * Show error message dialog. The error is also printed on {@link * System#err}. * * The message can contain HTML formatting codes. * * @param owner Parent component (if {@code null}, a default {@link Frame} * is used). * @param title Dialog title. * @param message Content message. */ public static void showErrorDialog( @Nullable final Component owner, @Nullable final String title, @Nullable final String message ) { System.err.println( TextTools.getFixed( "----[ " + title + ']', 80, false, '-' ) ); System.err.println( message ); System.err.println( TextTools.getFixed( 80, '-' ) ); showMessageDialog( owner, title, TextTools.plainTextToHTML( message ), JOptionPane.ERROR_MESSAGE, 0 ); }
/** * Listen to a port and dump incoming data. * * @param portName Name of port to listen to. * * @throws IOException if an I/O error occurs. */ private void listenToPort( final String portName ) throws IOException { final Javacomm jc = Javacomm.getInstance(); System.out.println( "Opening port '" + portName + '\'' ); final SerialPort port = jc.openSerialPort( portName, 9600, DataBits.EIGHT, Parity.NONE, StopBits.ONE ); System.out.println( "Listening" ); final InputStream is = port.getInputStream(); while ( true ) { final int b = is.read(); if ( b < 0 ) { break; } System.out.println( TextTools.toHexString( b, 2, true ) + ' ' + TextTools.getFixed( String.valueOf( b ), 3, true, ' ' ) + " '" + (char)b + '\'' ); } System.out.println( "Port closed" ); }
System.out.println( " (" + TextTools.getFixed( "old definition:", updatePrefix.length() - 2, true, '.' ) + ' ' + oldCreateLine + ')' );