Ejemplo n.º 1
0
 /**
  * Tries to insert words into the text area. Displays a dialog if the attempt fails.
  *
  * @param words the words to insert
  */
 public void insertWords(String words) {
   try {
     textArea.append(words + "\n");
   } catch (SecurityException ex) {
     JOptionPane.showMessageDialog(this, "I am sorry, but I cannot do that.");
     ex.printStackTrace();
   }
 }
Ejemplo n.º 2
0
  public PermissionTestFrame() {
    textField = new JTextField(20);
    JPanel panel = new JPanel();
    panel.add(textField);
    JButton openButton = new JButton("Insert");
    panel.add(openButton);
    openButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            insertWords(textField.getText());
          }
        });

    add(panel, BorderLayout.NORTH);

    textArea = new WordCheckTextArea();
    textArea.setRows(TEXT_ROWS);
    textArea.setColumns(TEXT_COLUMNS);
    add(new JScrollPane(textArea), BorderLayout.CENTER);
    pack();
  }