Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. ///////////////////////////////////// INNE I VIEW /////////////////////////////////////////
  2.  
  3. public JTextPane text=new JTextPane();
  4. public StyledDocument doc = text.getStyledDocument();
  5. public Style riktig = text.addStyle("rett", null);
  6. public Style feil = text.addStyle("feil", null);
  7.  
  8. //////////////////////////////////// INNE I CONTROLLER ////////////////////////////////////
  9.  
  10. else if (arg0.getSource().equals(view.spellcheck)) {
  11. String alt = view.text.getText();
  12. String[] arr = alt.split(" ");
  13. view.text.setText("");
  14. for (String ss : arr) {
  15. boolean rett = false;
  16. for (Object c : model.wordliste) {
  17. if (ss.equals(c)) {
  18. rett = true;
  19.  
  20. StyleConstants.setForeground(view.riktig, Color.green);
  21. try {
  22. view.doc.insertString(view.doc.getLength(), ss + " ", view.riktig);
  23. } catch (BadLocationException e) {
  24. e.printStackTrace();
  25. }
  26. break;
  27. }
  28. }
  29. if (!rett) {
  30. try {
  31. StyleConstants.setForeground(view.feil, Color.red);
  32. view.doc.insertString(view.doc.getLength(), ss + " ", view.feil);
  33. } catch (BadLocationException e) {
  34. e.printStackTrace();
  35. }
  36.  
  37. }
  38.  
  39. }
  40. }
  41.  
  42. /////////////////////////////////////////////// INNE I MODEL //////////////////////////////////////////////
  43.  
  44. public ArrayList wordliste=new ArrayList();
  45.  
  46.  
  47. public void Oppdater(){
  48. try {
  49. File file = new File("ordliste.txt");
  50. FileReader f = new FileReader(file);
  51. BufferedReader bf = new BufferedReader(f);
  52. String linje = bf.readLine();
  53. while (linje != null) {
  54. wordliste.add(linje);
  55. linje = bf.readLine();
  56. }
  57. System.out.println(wordliste.size());
  58. bf.close();
  59. f.close();
  60. } catch (FileNotFoundException e) {
  61. e.printStackTrace();
  62. } catch (IOException e) {
  63. e.printStackTrace();
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement