Esempio n. 1
0
  // Remove a test case from testBox and tests array.
  private void removeTest() {

    // Make sure they want to remove the checked tests.
    String message = "Are you sure you would like to remove the selected tests?";
    int decision =
        JOptionPane.showConfirmDialog(null, message, "Remove", JOptionPane.OK_CANCEL_OPTION);

    // If they definitely do want to remove.
    if (decision == JOptionPane.OK_OPTION) {

      // Make array list copy, so as to avoid index errors.
      ArrayList<JCheckBox> newTests = (ArrayList<JCheckBox>) tests.clone();
      int removed = 0;

      for (int i = 0; i < tests.size(); i++) {
        if (tests.get(i).isSelected()) {
          // Remove from the tests copy.
          newTests.remove(i - removed);
          // Remove from the GUI box.
          testBox.setEditable(true);
          testBox.remove(tests.get(i));
          testBox.repaint();
          testBox.setEditable(false);
        }
      }

      // Update the tests with the newly made list.
      tests = newTests;
    }
  }
Esempio n. 2
0
 private void appendText(String s, Color c) {
   // System.out.println(s);
   StyledDocument doc = console.getStyledDocument();
   SimpleAttributeSet col = new SimpleAttributeSet();
   StyleConstants.setForeground(col, c);
   synchronized (doc) {
     try {
       doc.removeDocumentListener(dl);
       doc.insertString(doc.getLength(), s, col);
       doc.addDocumentListener(dl);
     } catch (BadLocationException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
   console.setCaretPosition(doc.getLength());
   console.repaint();
 }
 @Override
 public void repaint(long tm, int x, int y, int width, int height) {
   // This forces repaint to repaint the entire TextPane.
   super.repaint(tm, 0, 0, getWidth(), getHeight());
 }