<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comentarios en: Botones cortar-copiar-pegar en Java</title>
	<atom:link href="http://luauf.com/2008/06/09/botones-cortar-copiar-pegar-en-java/feed/" rel="self" type="application/rss+xml" />
	<link>http://luauf.com/2008/06/09/botones-cortar-copiar-pegar-en-java/</link>
	<description></description>
	<lastBuildDate>Thu, 02 Sep 2010 18:36:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>Por: Elias Leyton</title>
		<link>http://luauf.com/2008/06/09/botones-cortar-copiar-pegar-en-java/comment-page-1/#comment-1188</link>
		<dc:creator>Elias Leyton</dc:creator>
		<pubDate>Thu, 02 Apr 2009 02:06:44 +0000</pubDate>
		<guid isPermaLink="false">http://luauf.com/?p=394#comment-1188</guid>
		<description>Ahi varias lineas que no entiedo... 
podrias explicar el manejo de eventos gracias. yo tambien estoy haciendo un tipo bloc de notas_

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.text.DefaultEditorKit; //copy + paste


public class EditorSimple extends JFrame{
private JButton botonCopiar;
private JButton botonCortar;
private JButton botonPegar;
private JLabel barraEstado;
private JTextArea areaTexto;

//elementos de la barra menu
private  JMenuBar barra;
private JMenu archivo;
private JMenuItem abrir;
private JMenuItem grabar;

public EditorSimple(){
    super(&quot;Super editor TAP&quot;);
    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    this.addWindowListener(new CerrarListener());
    inicializarMenu();
    inicializarComponentes();

}
private void inicializarMenu(){
    barra= new JMenuBar();
    archivo =new JMenu(&quot;Archivo&quot;);
    barra.add(archivo);

    abrir= new JMenuItem(&quot;Abrir&quot;);
    abrir.addActionListener(new AbrirListener());//agregamos el listener
    archivo.add(abrir);

    grabar= new JMenuItem(&quot;Grabar&quot;);
    archivo.add(grabar);

    this.setJMenuBar(barra);
}
private void inicializarComponentes(){
    Container contentPane= this.getContentPane();
    contentPane.setLayout(new BorderLayout());

    barraEstado =new JLabel(&quot;Bienvenido - Listo&quot;);
    contentPane.add(barraEstado);

    areaTexto = new JTextArea();
    JScrollPane scroller = new JScrollPane(areaTexto);
    contentPane.add(scroller, BorderLayout.CENTER);

    JPanel panelNorte =new JPanel();
    panelNorte.setLayout (new FlowLayout(FlowLayout.LEFT));
    botonCopiar = new JButton(new DefaultEditorKit.CopyAction());
    botonCopiar.setText(&quot;Copiar&quot;);
    panelNorte.add(botonCopiar);
    botonCortar = new JButton(new DefaultEditorKit.CutAction());
    botonCortar.setText(&quot;Cortar&quot;);
    panelNorte.add(botonCortar);
    botonPegar = new JButton(new DefaultEditorKit.PasteAction());
    botonPegar.setText(&quot;Pegar&quot;);
    panelNorte.add(botonPegar);
    contentPane.add(panelNorte, BorderLayout.NORTH);

    this.pack();
    this.setSize(350,390);
}
class AbrirListener  implements ActionListener{
    public void actionPerformed(ActionEvent ev){
        abrirClick();
    }
}
private void abrirClick(){
    JFileChooser chooser= new JFileChooser();
    int respuesta = chooser.showOpenDialog(this);
    if(respuesta == JFileChooser.APPROVE_OPTION){
        File archivo = chooser.getSelectedFile();
        abrirArchivo(archivo);

    }
}
private void abrirArchivo(File archivo){
    //este metodo lee un archivo y lo deja en el area de texto para que se le
   //pueda editar

    try{
        BufferedReader br= new BufferedReader(new FileReader(archivo));
        String linea =br.readLine();
        while (linea!=null){
            areaTexto.append(linea + &quot;\n&quot;);
            linea= br.readLine();
        }
        br.close();
    }catch (IOException ex){
        System.err.println(&quot;problemas al leer el archivo&quot;+ ex);
    }
}

//eventos de ventana
//hoy vamos por el mas importante de todos. CERRAR
//asi como existen action listener para los botones, existe Windows Listener
//para las ventanas. el problema es que windndows listener es una interfaz mas
//compleja, que inclute varios metodos. para hacer la vida mas facil, existe
//una clase, windows adapter, de la que podemos heredar pafra modificar el comportamiento
//de la ventana solo en lo que nos combiene

class CerrarListener extends WindowAdapter{
        public void windowsClosing(WindowEvent ev){
            cerrandoVentana();

        }
}
private void cerrandoVentana(){
    int opcion =JOptionPane.showConfirmDialog(this, &quot;¿esta seguro de salir?&quot;,
            &quot;confirma&quot;, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
   if(opcion==JOptionPane.YES_OPTION){
       this.dispose();
       System.exit(0);
   }
}
    public static void main (String []arx){

     JFrame ventana = new EditorSimple();
     ventana.setVisible(true);

 }
}</description>
		<content:encoded><![CDATA[<p>Ahi varias lineas que no entiedo&#8230;<br />
podrias explicar el manejo de eventos gracias. yo tambien estoy haciendo un tipo bloc de notas_</p>
<p>import java.awt.*;<br />
import javax.swing.*;<br />
import java.awt.event.*;<br />
import java.io.*;<br />
import javax.swing.text.DefaultEditorKit; //copy + paste</p>
<p>public class EditorSimple extends JFrame{<br />
private JButton botonCopiar;<br />
private JButton botonCortar;<br />
private JButton botonPegar;<br />
private JLabel barraEstado;<br />
private JTextArea areaTexto;</p>
<p>//elementos de la barra menu<br />
private  JMenuBar barra;<br />
private JMenu archivo;<br />
private JMenuItem abrir;<br />
private JMenuItem grabar;</p>
<p>public EditorSimple(){<br />
    super(&#8220;Super editor TAP&#8221;);<br />
    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);<br />
    this.addWindowListener(new CerrarListener());<br />
    inicializarMenu();<br />
    inicializarComponentes();</p>
<p>}<br />
private void inicializarMenu(){<br />
    barra= new JMenuBar();<br />
    archivo =new JMenu(&#8220;Archivo&#8221;);<br />
    barra.add(archivo);</p>
<p>    abrir= new JMenuItem(&#8220;Abrir&#8221;);<br />
    abrir.addActionListener(new AbrirListener());//agregamos el listener<br />
    archivo.add(abrir);</p>
<p>    grabar= new JMenuItem(&#8220;Grabar&#8221;);<br />
    archivo.add(grabar);</p>
<p>    this.setJMenuBar(barra);<br />
}<br />
private void inicializarComponentes(){<br />
    Container contentPane= this.getContentPane();<br />
    contentPane.setLayout(new BorderLayout());</p>
<p>    barraEstado =new JLabel(&#8220;Bienvenido &#8211; Listo&#8221;);<br />
    contentPane.add(barraEstado);</p>
<p>    areaTexto = new JTextArea();<br />
    JScrollPane scroller = new JScrollPane(areaTexto);<br />
    contentPane.add(scroller, BorderLayout.CENTER);</p>
<p>    JPanel panelNorte =new JPanel();<br />
    panelNorte.setLayout (new FlowLayout(FlowLayout.LEFT));<br />
    botonCopiar = new JButton(new DefaultEditorKit.CopyAction());<br />
    botonCopiar.setText(&#8220;Copiar&#8221;);<br />
    panelNorte.add(botonCopiar);<br />
    botonCortar = new JButton(new DefaultEditorKit.CutAction());<br />
    botonCortar.setText(&#8220;Cortar&#8221;);<br />
    panelNorte.add(botonCortar);<br />
    botonPegar = new JButton(new DefaultEditorKit.PasteAction());<br />
    botonPegar.setText(&#8220;Pegar&#8221;);<br />
    panelNorte.add(botonPegar);<br />
    contentPane.add(panelNorte, BorderLayout.NORTH);</p>
<p>    this.pack();<br />
    this.setSize(350,390);<br />
}<br />
class AbrirListener  implements ActionListener{<br />
    public void actionPerformed(ActionEvent ev){<br />
        abrirClick();<br />
    }<br />
}<br />
private void abrirClick(){<br />
    JFileChooser chooser= new JFileChooser();<br />
    int respuesta = chooser.showOpenDialog(this);<br />
    if(respuesta == JFileChooser.APPROVE_OPTION){<br />
        File archivo = chooser.getSelectedFile();<br />
        abrirArchivo(archivo);</p>
<p>    }<br />
}<br />
private void abrirArchivo(File archivo){<br />
    //este metodo lee un archivo y lo deja en el area de texto para que se le<br />
   //pueda editar</p>
<p>    try{<br />
        BufferedReader br= new BufferedReader(new FileReader(archivo));<br />
        String linea =br.readLine();<br />
        while (linea!=null){<br />
            areaTexto.append(linea + &#8220;\n&#8221;);<br />
            linea= br.readLine();<br />
        }<br />
        br.close();<br />
    }catch (IOException ex){<br />
        System.err.println(&#8220;problemas al leer el archivo&#8221;+ ex);<br />
    }<br />
}</p>
<p>//eventos de ventana<br />
//hoy vamos por el mas importante de todos. CERRAR<br />
//asi como existen action listener para los botones, existe Windows Listener<br />
//para las ventanas. el problema es que windndows listener es una interfaz mas<br />
//compleja, que inclute varios metodos. para hacer la vida mas facil, existe<br />
//una clase, windows adapter, de la que podemos heredar pafra modificar el comportamiento<br />
//de la ventana solo en lo que nos combiene</p>
<p>class CerrarListener extends WindowAdapter{<br />
        public void windowsClosing(WindowEvent ev){<br />
            cerrandoVentana();</p>
<p>        }<br />
}<br />
private void cerrandoVentana(){<br />
    int opcion =JOptionPane.showConfirmDialog(this, &#8220;¿esta seguro de salir?&#8221;,<br />
            &#8220;confirma&#8221;, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);<br />
   if(opcion==JOptionPane.YES_OPTION){<br />
       this.dispose();<br />
       System.exit(0);<br />
   }<br />
}<br />
    public static void main (String []arx){</p>
<p>     JFrame ventana = new EditorSimple();<br />
     ventana.setVisible(true);</p>
<p> }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Marvin</title>
		<link>http://luauf.com/2008/06/09/botones-cortar-copiar-pegar-en-java/comment-page-1/#comment-1001</link>
		<dc:creator>Marvin</dc:creator>
		<pubDate>Mon, 16 Mar 2009 16:50:33 +0000</pubDate>
		<guid isPermaLink="false">http://luauf.com/?p=394#comment-1001</guid>
		<description>Muy bueno, me ayudo bastante. que bueno que java simplifica muchas cosas.</description>
		<content:encoded><![CDATA[<p>Muy bueno, me ayudo bastante. que bueno que java simplifica muchas cosas.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Guillermina</title>
		<link>http://luauf.com/2008/06/09/botones-cortar-copiar-pegar-en-java/comment-page-1/#comment-611</link>
		<dc:creator>Guillermina</dc:creator>
		<pubDate>Wed, 03 Dec 2008 15:26:08 +0000</pubDate>
		<guid isPermaLink="false">http://luauf.com/?p=394#comment-611</guid>
		<description>Hola estoy haciendo un bloc de nota pero no se como configurar los botones cortar, pegar , copiar e imprimir.
Pero el proyecto lo estoy haciendo en Netbeans y ya tengo los botones solo me hace falta configurarlos.
Si pueden ayudarme, le agradeceria mucho</description>
		<content:encoded><![CDATA[<p>Hola estoy haciendo un bloc de nota pero no se como configurar los botones cortar, pegar , copiar e imprimir.<br />
Pero el proyecto lo estoy haciendo en Netbeans y ya tengo los botones solo me hace falta configurarlos.<br />
Si pueden ayudarme, le agradeceria mucho</p>
]]></content:encoded>
	</item>
</channel>
</rss>
