Bienvenidos a un nuevo curso. Ahora estoy en el ciclo de grado superior: Desarrollo de aplicaciones multiplataforma. Y voy a ser parte del experimento de la formación dual. Estaré haciendo practicas durante un año, y a la vez finalizando la formación.

Deseadme suerte.

lunes, 4 de abril de 2016

Editor de texto del profesor

0

Teniendo el siguiente proyecto creado:









Cuyo código es el siguiente:

    private void CopiarActionPerformed(java.awt.event.ActionEvent evt) {                                       
        portapapeles=pantalla.getSelectedText();
    }                                      

    private void TamaLetraActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
         jDialogTamaLetra.setSize(300,250);
         jDialogTamaLetra.setVisible(true);
    }                                         

    private void btnAceptarLetraActionPerformed(java.awt.event.ActionEvent evt) {                                                
        // TODO add your handling code here:
        
        //ya que solo cambiaremos la letra debemos mantener el tamaño y el estilo
        int tama=pantalla.getFont().getSize();
        int estilo=pantalla.getFont().getStyle();
        
        String letra=jList1.getSelectedValue();
       
        pantalla.setFont(new Font(letra,estilo,tama));
        jDialogTipoLetra.dispose();
    }                                               

    private void TipoLetraActionPerformed(java.awt.event.ActionEvent evt) {                                          
            // TODO add your handling code here:
            jDialogTipoLetra.setSize(410,350);
            jDialogTipoLetra.setVisible(true);
           
            jDialogTipoLetra.setModal(true);
            jDialogTipoLetra.requestFocusInWindow();
       

    
    }                                         

    private void NuevoActionPerformed(java.awt.event.ActionEvent evt) {                                      
      
        panelNuevo.setVisible(true);
        pantalla.setText("");
    }                                     

    private void SalirActionPerformed(java.awt.event.ActionEvent evt) {                                      
        // TODO add your handling code here:
        System.exit(0);
    }                                     

    private void CortarActionPerformed(java.awt.event.ActionEvent evt) {                                       
        
        portapapeles=pantalla.getSelectedText();
        pantalla.replaceSelection("");
       
    }                                      

    private void PegarActionPerformed(java.awt.event.ActionEvent evt) {                                      
        pantalla.replaceSelection(portapapeles);
    }                                     

    private void SeleccionarTodoActionPerformed(java.awt.event.ActionEvent evt) {                                                
        pantalla.selectAll();
    }                                               

    private void EstiloActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
        jDialogEstilo.setSize(250,300);
        jDialogEstilo.setVisible(true);
    }                                      

    private void btnAceptarTamanoActionPerformed(java.awt.event.ActionEvent evt) {                                                 
        //obtenemos los valores iniciales
        String letra=pantalla.getFont().getFontName();
        int estilo=pantalla.getFont().getStyle();
        
        int tama=Integer.parseInt(jComboBox1.getSelectedItem().toString());
        Font nueva=new Font (letra,estilo,tama);
        pantalla.setFont(nueva);

        jDialogTamaLetra.dispose();
    }                                                

    private void saveActionPerformed(java.awt.event.ActionEvent evt) {                                     
        try {
            
               // String ruta= "c:/archivo.txt";
  
                Writer salida = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("archivo.txt"),"UTF8"));
                salida.write(pantalla.getText());
                //para finalizar cierro el flujo al disco
                salida.flush();
                JOptionPane.showMessageDialog(this, "Fichero guardado correctamente", "INFORME",JOptionPane.ERROR_MESSAGE);
        
        } catch (IOException ex) {
            Logger.getLogger(Form1.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(this, "Error de E/S", "ERROR",1);
           
        }
        
         
    }                                    

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
         jDialogTipoLetra.dispose();
    }                                        

    private void cutActionPerformed(java.awt.event.ActionEvent evt) {                                    
        // TODO add your handling code here:
        portapapeles=pantalla.getSelectedText();
        pantalla.replaceSelection("");
    }                                   

    private void copyActionPerformed(java.awt.event.ActionEvent evt) {                                     
        // TODO add your handling code here:
        portapapeles=pantalla.getSelectedText();
    }                                    

    private void pasteActionPerformed(java.awt.event.ActionEvent evt) {                                      
        // TODO add your handling code here:
        pantalla.replaceSelection(portapapeles);
    }                                     

    private void btnNewActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
        panelNuevo.setVisible(true);
        pantalla.setText("");
        //habilitamos botones de la barra de herramientas
        save.setEnabled(true);
        cut.setEnabled(true);
        copy.setEnabled(true);
        paste.setEnabled(true);
        selecTodo.setEnabled(true);
        
    }                                      

    private void btnCancelarTamaActionPerformed(java.awt.event.ActionEvent evt) {                                                
        // TODO add your handling code here:
        jDialogTamaLetra.dispose();
    }                                               

    private void btnAceptarEstiloActionPerformed(java.awt.event.ActionEvent evt) {                                                 
        // TODO add your handling code here:
        //obtenemos los valores iniciales
        Font font = pantalla.getFont();
        Map attributes = font.getAttributes();//par clave-valor para los atributos del texto de la textArea
         
        if (jCheckBoxNegrita.isSelected()) {

            attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);//cambiamos el valor del atributo "peso"

        } else {
            attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_REGULAR);
        }

        if (jCheckBoxCursiva.isSelected()) {
            attributes.put(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE);//cambiamos el valor del atributo "postura"

        } else {

            attributes.put(TextAttribute.POSTURE, TextAttribute.POSTURE_REGULAR);

        }

        if (jCheckBoxUnderline.isSelected()) {

            attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);//cambiamos el valor del atributo "subrayado"

        } else {
            attributes.put(TextAttribute.UNDERLINE, -1);//sin subrayar

        }

           
        pantalla.setFont(font.deriveFont(attributes));//cambiamos la fuente
      
        jDialogEstilo.dispose();
        
            
        
    }                                                

    private void GuardarActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        String s = pantalla.getText();
        Archivo a = new Archivo();
        try {
            a.crearArchivo(s,this);
        } catch (IOException ex) {
            Logger.getLogger(Form1.class.getName()).log(Level.SEVERE, null, ex);
        }
    }                                       

    private void CerrarActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
          panelNuevo.setVisible(false);
    }                                      

    private void ColorActionPerformed(java.awt.event.ActionEvent evt) {                                      
        // TODO add your handling code here:
        Color inicial=pantalla.getForeground();
        
        Color newColor=JColorChooser.showDialog(this, "Eliga el color", inicial);
        
        
       if (newColor != null){
        pantalla.setForeground(newColor);
       }
    }                                     

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
        if (!lista.llena()){//si la lista no está llena guardo
           
            lista.guardarFichero( pantalla.getText());
        }
    }                                          

    private void AbrirActionPerformed(java.awt.event.ActionEvent evt) {                                      
        // TODO add your handling code here:
       
        //método para probar. Habría que implementar que me pida el nº de fichero
        
        
        pantalla.setText(lista.abrirFichero(0).toString());
    }                                     

    private void selecTodoActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
        pantalla.selectAll();
    }                                         

Related Posts:

  • Examen de programación I 1.- Calculadora mi ejercicio (4.5 de 5 puntos debido a que no controle errores(no se pude dividir por cero) ni trabaje con decimales). usin… Read More
  • Editor etiquetas A Continuación os pongo el código completo. Como en las imágenes esta todo bien comentado y marcado. … Read More
  • Examen de programación II Resultado profesor (5 pnts. En el ejercicio se sobreescribe. No se modifica o elimina. Tengo mis dudas si eso se practica en las grandes empresas, au… Read More
  • Convertidor en Java Mientras intento sacar tiempo para recuperar todos los apuntes y ejercicios perdidos. Intentare mantenerme esta vez, mas al día con la clase. Ultimo … Read More
  • Calculadora 1 A Continuación os pongo el código completo. Como en las imágenes esta todo bien comentado y ma… Read More

0 comentarios:

Publicar un comentario

Etiquetas actuales

BD (67) DEF (64) PROG (64) SQL (44) Java (29) PRACTICAS (20) php (18) DI (16) PRESTASHOP (16) PROGRAMACIÓN WEB (16) HTML (13) SGE (12) ERP (9) CONSULTAS (8) css (8) Linux (5) XML (5) Android (4) PDM (4) C (3) NetBeans (3) PSP (3) SMARTY (3) comandos (3) HOOK (2) POST (2) XSD (2) cURL (2) JS (1) MEDIA-QUERYS (1) PDO (1) RESPONSIVE (1) TPL (1) TRADUCCIÓN (1) app_inventor (1)

Todas las etiquetas

EJER (78) BD (67) DEF (64) PROG (64) SQL (44) c# (40) Programación (39) Ficheros (36) Java (29) bases de datos (21) PRACTICAS (20) lenguajes de marcas (19) AD (18) Entorno de desarrollo (18) php (18) PROCEDIMIENTOS (17) DI (16) FORM (16) PRESTASHOP (16) PROGRAMACIÓN WEB (16) lenguaje C (16) E/R (14) HTML (13) SGE (12) Sistemas informáticos (10) ERP (9) CONSULTAS (8) TRANSACCIONES (8) TRIGGER (8) VISUAL BASIC (8) css (8) FUNCIONES (7) html5 (6) Ada (5) EXAMEN (5) Linux (5) XML (5) estructuras (5) Android (4) DISEÑO (4) INTERFAZ (4) LOG (4) OpenBravo (4) PDM (4) ACTUALIZAR (3) C (3) DIAGRAMA (3) Directorios (3) NEW (3) NOR (3) NetBeans (3) OLD (3) PSP (3) SMARTY (3) comandos (3) css3 (3) AISLAMIENTOS (2) C++ (2) CONTROLERRORES (2) ELIMINAR (2) HOOK (2) INSERTAR (2) INST (2) MULTITABLA (2) POST (2) RECURSIVIDAD (2) SUBCONSULTAS (2) VISTAS (2) XSD (2) cURL (2) punteros (2) AJENA (1) BLOQUEOS (1) Byte (1) CREACION (1) CRM (1) Configuración (1) Controles (1) Datos (1) GOTFOCUS (1) IMAGENES (1) INDICES (1) JS (1) Lenght (1) MEDIA-QUERYS (1) Mingw (1) MonoDeveloped (1) OPTIMISTA (1) PDO (1) PESIMISTA (1) RESPONSIVE (1) SPEAK (1) Scanner (1) Serializacion (1) Streams (1) System (1) TPL (1) TRADUCCIÓN (1) USUARIOS (1) UseSystemPasswordChar (1) app_inventor (1) char (1) examenes (1) libreoffice (1) make (1) redes (1)