public final void systemRequest(char sr) {  if (sr == ' ') { JPanel srp = new JPanel(); srp.setLayout(new BorderLayout()); JLabel jl = new JLabel("Enter alternate job"); final JTextField sro = new JTextField(); srp.add(jl,BorderLayout.NORTH); srp.add(sro,BorderLayout.CENTER); Object[]      message = new Object[1]; message[0] = srp; String[] options = {"SysReq","Cancel"};  final JOptionPane pane = new JOptionPane(  message, JOptionPane.QUESTION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, options, options[0]);    final JDialog dialog = pane.createDialog(null, "System Request" );    dialog.addWindowListener( new WindowAdapter() { public void windowOpened( WindowEvent e) { super.windowOpened( e );         sro.requestFocus(); } }); dialog.show();   String value = (String)pane.getValue();  if (value.equals(options[0])) {              if (sro.getText().length() > 0) { for (int x = 0; x < sro.getText().length(); x++) {  if (sro.getText().charAt(0) == '2') {  dsq.clear(); } baosp.write(getEBCDIC(sro.getText().charAt(x))); }  try { writeGDS(4, 0, baosp.toByteArray()); } catch (IOException ioe) {  System.out.println(ioe.getMessage()); } baosp.reset(); } else {  try { writeGDS(4, 0, null); } catch (IOException ioe) {  System.out.println(ioe.getMessage()); } } } controller.requestFocus(); } else {  baosp.write(getEBCDIC(sr));  try { writeGDS(4, 0, baosp.toByteArray()); } catch (IOException ioe) { baosp.reset(); System.out.println(ioe.getMessage()); } baosp.reset(); }
public final void systemRequest() { systemRequest(' ');
   public final void systemRequest(char sr) {      if (sr == ' ') {         JPanel srp = new JPanel();         srp.setLayout(new BorderLayout());         JLabel jl = new JLabel("Enter alternate job");         final JTextField sro = new JTextField();         srp.add(jl,BorderLayout.NORTH);         srp.add(sro,BorderLayout.CENTER);         Object[]      message = new Object[1];         message[0] = srp;         String[] options = {"SysReq","Cancel"};         final JOptionPane pane = new JOptionPane(                message,                           // the dialog message array                JOptionPane.QUESTION_MESSAGE,      // message type                JOptionPane.DEFAULT_OPTION,        // option type                null,                              // optional icon, use null to use the default icon                options,                           // options string array, will be made into buttons//                options[0]);                       // option that should be made into a default button         // create a dialog wrapping the pane         final JDialog dialog = pane.createDialog(null, // parent frame                           "System Request"  // dialog title                           );         // add the listener that will set the focus to         // the desired option         dialog.addWindowListener( new WindowAdapter() {            public void windowOpened( WindowEvent e) {               super.windowOpened( e );               // now we're setting the focus to the desired component               // it's not the best solution as it depends on internals               // of the OptionPane class, but you can use it temporarily               // until the bug gets fixed               // also you might want to iterate here thru the set of               // the buttons and pick one to call requestFocus() for it               sro.requestFocus();            }         });         dialog.show();         // now we can process the value selected         String value = (String)pane.getValue();         if (value.equals(options[0])) {            // from rfc1205 section 4.3            // Client sends header with the           000A12A0000004040000FFEF            // System Request bit set.            //            // if we wanted to send an option with it we would need to send            //    it at the end such as the following            //            // byte abyte0[] = new byte[1];    or number of bytes in option            // abyte0[0] = getEBCDIC(option);//                  System.out.println("SYSRQS sent");            // send option along with system request            if (sro.getText().length() > 0) {               for (int x = 0; x < sro.getText().length(); x++) {            //                     System.out.println(sro.getText().charAt(x));                  if (sro.getText().charAt(0) == '2') {            //                           System.out.println("dataq cleared");                     dsq.clear();                  }                  baosp.write(getEBCDIC(sro.getText().charAt(x)));               }               try {                 writeGDS(4, 0, baosp.toByteArray());               }               catch (IOException ioe) {                 System.out.println(ioe.getMessage());               }               baosp.reset();            }            else {    // no option sent with system request               try {                 writeGDS(4, 0, null);               }               catch (IOException ioe) {                 System.out.println(ioe.getMessage());               }            }         }         controller.requestFocus();      }      else {         baosp.write(getEBCDIC(sr));         try {            writeGDS(4, 0, baosp.toByteArray());         }         catch (IOException ioe) {            baosp.reset();            System.out.println(ioe.getMessage());         }         baosp.reset();      }   }