package Proyecto; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.io.File; import java.io.FileWriter; import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.DefaultStyledDocument; import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; import org.jdesktop.swingx.JXCollapsiblePane; public class Principal extends javax.swing.JFrame { public Principal() { initComponents(); this.setLocationRelativeTo(null); setTitle("Code Editor"); jXCollapsiblePane1.setLayout(new BorderLayout()); jXCollapsiblePane1.add(jPanel2, BorderLayout.CENTER); btnControl.addActionListener(jXCollapsiblePane1.getActionMap().get(JXCollapsiblePane.TOGGLE_ACTION)); //txtEditor.setText("public class Hola {}"); dirArchivo.setEnabled(false); } String titulo = " - Editor 0.1"; final StyleContext cont = StyleContext.getDefaultStyleContext(); final AttributeSet attr = cont.addAttribute(cont.getEmptySet(), StyleConstants.Foreground, Color.BLUE); final AttributeSet attrBlack = cont.addAttribute(cont.getEmptySet(), StyleConstants.Foreground, Color.BLACK); final AttributeSet attrComent = cont.addAttribute(cont.getEmptySet(), StyleConstants.Foreground, Color.RED); DefaultStyledDocument doc = new DefaultStyledDocument() { @Override public void insertString(int offset, String str, AttributeSet a) throws BadLocationException { super.insertString(offset, str, a); String text = getText(0, getLength()); int before = findLastNonWordChar(text, offset); if (before < 0) { before = 0; } int after = findFirstNonWordChar(text, offset + str.length()); int wordL = before; int wordR = before; while (wordR <= after) { if (wordR == after || String.valueOf(text.charAt(wordR)).matches("\\W")) { if (text.substring(wordL, wordR).matches("(\\W)*(abstract|continue|for|new|switch|default|if|package|synchronized|boolean|do|goto|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|return|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|volatile|const|float|native|super|while)")) { setCharacterAttributes(wordL, wordR - wordL, attr, false); } else { setCharacterAttributes(wordL, wordR - wordL, attrBlack, false); } wordL = wordR; } wordR++; } } public void remove(int offs, int len) throws BadLocationException { super.remove(offs, len); String text = getText(0, getLength()); int before = findLastNonWordChar(text, offs); if (before < 0) { before = 0; } int after = findFirstNonWordChar(text, offs); if (text.substring(before, after).matches("(\\W)*(abstract|continue|for|new|switch|default|if|package|synchronized|boolean|do|goto|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|return|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|volatile|const|float|native|super|while)")) . . .Descargar:
https://www.dropbox.com/s/8f9bxbls19xdxa0/Compilers.rar?dl=0
https://www.youtube.com/user/delfirosales