Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////////////////////// INNE I VIEW /////////////////////////////////////////
- public JTextPane text=new JTextPane();
- public StyledDocument doc = text.getStyledDocument();
- public Style riktig = text.addStyle("rett", null);
- public Style feil = text.addStyle("feil", null);
- //////////////////////////////////// INNE I CONTROLLER ////////////////////////////////////
- else if (arg0.getSource().equals(view.spellcheck)) {
- String alt = view.text.getText();
- String[] arr = alt.split(" ");
- view.text.setText("");
- for (String ss : arr) {
- boolean rett = false;
- for (Object c : model.wordliste) {
- if (ss.equals(c)) {
- rett = true;
- StyleConstants.setForeground(view.riktig, Color.green);
- try {
- view.doc.insertString(view.doc.getLength(), ss + " ", view.riktig);
- } catch (BadLocationException e) {
- e.printStackTrace();
- }
- break;
- }
- }
- if (!rett) {
- try {
- StyleConstants.setForeground(view.feil, Color.red);
- view.doc.insertString(view.doc.getLength(), ss + " ", view.feil);
- } catch (BadLocationException e) {
- e.printStackTrace();
- }
- }
- }
- }
- /////////////////////////////////////////////// INNE I MODEL //////////////////////////////////////////////
- public ArrayList wordliste=new ArrayList();
- public void Oppdater(){
- try {
- File file = new File("ordliste.txt");
- FileReader f = new FileReader(file);
- BufferedReader bf = new BufferedReader(f);
- String linje = bf.readLine();
- while (linje != null) {
- wordliste.add(linje);
- linje = bf.readLine();
- }
- System.out.println(wordliste.size());
- bf.close();
- f.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement