![]()
Sale La primera boludes, es un simple editor de texto como veran, ejecutado directamente del netbeans ya que para ser sinceros al compilar desde la shell daba error pero al compilar del netbeans salia impecable 0 errores y warnings
A continuacion la basura digo codigo xD
import java.io.*;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
/*
* editor.java
*
* Created on 27 de agosto de 2007, 21:22
*/
/**
*
* @author pepe
*/
public class editor extends javax.swing.JFrame {
public editor() {
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e)
{
e.printStackTrace();
}
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate=”collapsed” desc=” Generated Code “>//GEN-BEGIN:initComponents
private void initComponents() {
jFrame1 = new javax.swing.JFrame();
jPanel1 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem5 = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jSeparator1 = new javax.swing.JSeparator();
jMenuItem1 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
jMenuItem4 = new javax.swing.JMenuItem();
org.jdesktop.layout.GroupLayout jFrame1Layout = new org.jdesktop.layout.GroupLayout(jFrame1.getContentPane());
jFrame1.getContentPane().setLayout(jFrame1Layout);
jFrame1Layout.setHorizontalGroup(
jFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 400, Short.MAX_VALUE)
);
jFrame1Layout.setVerticalGroup(
jFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 300, Short.MAX_VALUE)
);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle(“Editor De Texto”);
setResizable(false);
org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 0, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 613, Short.MAX_VALUE)
);
jTextArea1.setColumns(20);
jTextArea1.setRows(8);
jScrollPane1.setViewportView(jTextArea1);
jButton1.setIcon(new javax.swing.ImageIcon(“C:\\Documents and Settings\\pepe\\Escritorio\\g1ar.gif”));
jButton1.setToolTipText(“Guardar como”);
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setIcon(new javax.swing.ImageIcon(“C:\\Documents and Settings\\pepe\\Escritorio\\n1.gif”));
jButton2.setToolTipText(“Abri archivo nuevo”);
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setIcon(new javax.swing.ImageIcon(“C:\\Documents and Settings\\pepe\\Escritorio\\ch1.gif”));
jButton3.setToolTipText(“Salir”);
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton4.setIcon(new javax.swing.ImageIcon(“C:\\Documents and Settings\\pepe\\Escritorio\\abrir.gif”));
jButton4.setToolTipText(“Abrir”);
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jMenu1.setText(“Archivo”);
jMenuItem5.setText(“Nuevo”);
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem5);
jMenuItem3.setText(“Abrir”);
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem3);
jMenuItem2.setText(“Guardar”);
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem2);
jMenu1.add(jSeparator1);
jMenuItem1.setText(“Salir”);
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem1);
jMenuBar1.add(jMenu1);
jMenu2.setText(“Ayuda”);
jMenuItem4.setText(“Acerca De”);
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem4);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(19, 19, 19)
.add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(20, 20, 20)
.add(jButton4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(17, 17, 17)
.add(jButton3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(130, 130, 130))
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 640, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jButton1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE)
.add(jButton4)
.add(jButton3))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 519, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
FileInputStream archivo;
JFileChooser jf = new JFileChooser();
byte linea[]= new byte[2000];
String dato = new String();
int resultado = jf.showOpenDialog(this);
if(resultado == JFileChooser.APPROVE_OPTION)
{
try{
archivo = new FileInputStream(jf.getSelectedFile());
archivo.read(linea);
dato = new String(linea);
dato = dato.trim();
jTextArea1.setText(dato);
archivo.close();
}catch(IOException ex){
JOptionPane.showMessageDialog(new JFrame(),”Se ha producido un error al abrir el fichero!”,”Atencion!!”,JOptionPane.ERROR_MESSAGE);
}
}
}//GEN-LAST:event_jButton4ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
System.exit(0);
}//GEN-LAST:event_jButton3ActionPerformed
private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
int dev=JOptionPane.showConfirmDialog(new JFrame(),”¿Esta Seguro que desea un archivo nuevo?,Se perdera todo su progreso”,”Atencion!”,JOptionPane.YES_NO_OPTION);
if (dev==JOptionPane.YES_OPTION){
jTextArea1.setText(“”);
}
}//GEN-LAST:event_jMenuItem5ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
int dev=JOptionPane.showConfirmDialog(new JFrame(),”¿Esta Seguro que desea un archivo nuevo?,Se perdera todo su progreso”,”Atencion!”,JOptionPane.YES_NO_OPTION);
if (dev==JOptionPane.YES_OPTION){
jTextArea1.setText(“”);
}
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
JFileChooser jf = new JFileChooser();
FileOutputStream miArchivo;
String dato = new String();
int resultado = jf.showSaveDialog(this);
if(resultado == JFileChooser.APPROVE_OPTION)
{
try{
dato = jTextArea1.getText();
miArchivo = new FileOutputStream(jf.getSelectedFile());
miArchivo.write(dato.getBytes());
miArchivo.close();
}catch(IOException ex){
System.out.println(“Error!!!!”);
}
}
}//GEN-LAST:event_jButton1ActionPerformed
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
JOptionPane.showMessageDialog(new JFrame(),”Este programa fue echo por Pepepistola mientras practicaba Java”,”Info”,JOptionPane.INFORMATION_MESSAGE);
}//GEN-LAST:event_jMenuItem4ActionPerformed
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
FileInputStream archivo;
JFileChooser jf = new JFileChooser();
byte linea[]= new byte[2000];
String dato = new String();
int resultado = jf.showOpenDialog(this);
if(resultado == JFileChooser.APPROVE_OPTION)
{
try{
archivo = new FileInputStream(jf.getSelectedFile());
archivo.read(linea);
dato = new String(linea);
jTextArea1.setText(dato);
archivo.close();
}catch(IOException ex){
JOptionPane.showMessageDialog(new JFrame(),”Se ha producido un error al abrir el fichero!”,”Atencion!!”,JOptionPane.ERROR_MESSAGE);
}
}
}//GEN-LAST:event_jMenuItem3ActionPerformed
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
JFileChooser jf = new JFileChooser();
FileOutputStream miArchivo;
String dato = new String();
int resultado = jf.showSaveDialog(this);
if(resultado == JFileChooser.APPROVE_OPTION)
{
try{
dato = jTextArea1.getText();
miArchivo = new FileOutputStream(jf.getSelectedFile());
miArchivo.write(dato.getBytes());
miArchivo.close();
}catch(IOException ex){
JOptionPane.showMessageDialog(new JFrame(),”Se ha producido un error al escribir el fichero!”,”Atencion!!”,JOptionPane.ERROR_MESSAGE);
}
}
}//GEN-LAST:event_jMenuItem2ActionPerformed
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
System.exit(0);
}//GEN-LAST:event_jMenuItem1ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new editor().setVisible(true);
}
});
}
// Variables declaration – do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JFrame jFrame1;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JTextArea jTextArea1;
// End of variables declaration//GEN-END:variables
}
Features:
Abre y guarda archivos xD
Toma el skin de las ventanas del OS haciendolo lindo y rapido
No te dice que le duele la cabeza
Entrega el orto (?)
No te jode…..
Puntos en contra
Tiene menos reutilizacion que una virgen
Lo unico lindo que tiene son los iconos
Subi algo rata u.u
Hay puse algo jorge xD