Вы находитесь на странице: 1из 9

/*

* To change this template, choose Tools | Templates


* and open the template in the editor.
*/

/*
* Interfaz.java
*
* Created on 18-mar-2011, 7:43:30
*/
package analizador;

import javax.swing.*;
import java.io.*;
import java.net.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.sql.*;
import java.util.*;

public class Interfaz extends javax.swing.JFrame {

File temp;

public Interfaz() {
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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-
BEGIN:initComponents
private void initComponents() {

jMenuItem8 = new javax.swing.JMenuItem();


jMenuItem9 = new javax.swing.JMenuItem();
jPanel3 = new javax.swing.JPanel();
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jPanel2 = new javax.swing.JPanel();
jScrollPane2 = new javax.swing.JScrollPane();
jTextArea2 = new javax.swing.JTextArea();
jLabel1 = new javax.swing.JLabel();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jMenuItem6 = new javax.swing.JMenuItem();
jMenuItem7 = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
jMenuItem4 = new javax.swing.JMenuItem();
jMenuItem5 = new javax.swing.JMenuItem();
jMenuItem8.setText("jMenuItem8");

jMenuItem9.setText("jMenuItem9");

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Analizador Lexico");
setBackground(new java.awt.Color(51, 102, 255));

jPanel3.setBackground(new java.awt.Color(51, 153, 255));

jPanel1.setBackground(new java.awt.Color(51, 153, 255));

jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);

javax.swing.GroupLayout jPanel1Layout = new


javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE,
538, Short.MAX_VALUE)
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE,
285, Short.MAX_VALUE)
.addContainerGap())
);

jTabbedPane1.addTab("Entrada", jPanel1);

jTextArea2.setColumns(20);
jTextArea2.setEditable(false);
jTextArea2.setRows(5);
jScrollPane2.setViewportView(jTextArea2);

javax.swing.GroupLayout jPanel2Layout = new


javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE,
538, Short.MAX_VALUE)
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE,
285, Short.MAX_VALUE)
.addContainerGap())
);

jTabbedPane1.addTab("Entrada Analizada", jPanel2);

jLabel1.setFont(new java.awt.Font("Adobe Fan Heiti Std", 0, 24)); // NOI18N


jLabel1.setText("Movimiento de Tarjetas - Banco de Guatemala");

javax.swing.GroupLayout jPanel3Layout = new


javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel3Layout.createSequentialGroup()
.addContainerGap(45, Short.MAX_VALUE)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
571, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(68, 68, 68)
.addComponent(jLabel1)
.addContainerGap())
);
jPanel3Layout.setVerticalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel3Layout.createSequentialGroup()
.addGap(40, 40, 40)
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
343, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(40, Short.MAX_VALUE))
);

jMenuBar1.setBackground(new java.awt.Color(51, 153, 255));


jMenuBar1.setBorder(null);

jMenu1.setBackground(new java.awt.Color(51, 153, 255));


jMenu1.setText("Archivo");

jMenuItem1.setText("Abrir");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem1);

jMenuItem2.setText("Guardar HTML");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed1(evt);
}
});
jMenu1.add(jMenuItem2);

jMenuItem6.setText("Guardar Analisis");
jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem6ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem6);

jMenuItem7.setText("Limpiar Ventana");
jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem7ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem7);

jMenuItem3.setText("Cerrar");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed1(evt);
}
});
jMenu1.add(jMenuItem3);

jMenuBar1.add(jMenu1);

jMenu2.setBackground(new java.awt.Color(51, 153, 255));


jMenu2.setText("Analizador");

jMenuItem4.setText("Lexico");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem4);

jMenuItem5.setText("Comparar");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem5);

jMenuBar1.add(jMenu2);

setJMenuBar(jMenuBar1);

javax.swing.GroupLayout layout = new


javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);

pack();
}// </editor-fold>//GEN-END:initComponents

private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
Abrir();
jTabbedPane1.setSelectedComponent(jPanel1);
}private void jMenuItem3ActionPerformed1(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_jMenuItem3ActionPerformed1
// TODO add your handling code here:
Salir();
}//GEN-LAST:event_jMenuItem3ActionPerformed1
private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_jMenuItem5ActionPerformed
// TODO add your handling code here:
Comparador C = new Comparador();

C.jTextArea1.setText(jTextArea1.getText());
C.jTextArea2.setText(jTextArea2.getText());

C.setVisible(true);
}//GEN-LAST:event_jMenuItem5ActionPerformed

private void jMenuItem2ActionPerformed1(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_jMenuItem2ActionPerformed1
// TODO add your handling code here:
Guardar(jTextArea1.getText());
}//GEN-LAST:event_jMenuItem2ActionPerformed1

private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_jMenuItem6ActionPerformed
// TODO add your handling code here:
Guardar(jTextArea2.getText());
}//GEN-LAST:event_jMenuItem6ActionPerformed

private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_jMenuItem4ActionPerformed

Comparador C = new Comparador();


jTabbedPane1.setSelectedComponent(jPanel2);
jTextArea2.setText("");
C.jTextArea2.setText("");
Temporal();
new Main(temp.getPath());
String strCmd;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:Tarjeta");
Statement stmt = con.createStatement();
strCmd = "SELECT * FROM Tarjeta";
ResultSet rs = stmt.executeQuery(strCmd);
int a = 0;
while (rs.next()) {
a++;
String strNUMTARJ = rs.getString("Numero Tarjeta: ");
String strNOMBRE1 = rs.getString("Nombres ");
String strMES = rs.getString("AutorMes ");
String strANIO = rs.getString("Anio ");
String strCOD_CLI = rs.getString("Codigo Cliente ");
String strNUMEROCASA = rs.getString("Numero de Casa ");
String strAVENIDA = rs.getString("Avenida ");
String strCALLE = rs.getString("Zona ");
String strCIUDAD = rs.getString("Ciudad ");
String strPAIS = rs.getString("Pais");
String strNIT = rs.getString("Nit ");
String strTELEFONO = rs.getString("Telefono ");
}
con.close();
} catch (Exception e) {
System.out.println(e);
}

}//GEN-LAST:event_jMenuItem4ActionPerformed

private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_jMenuItem7ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jMenuItem7ActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {

@Override
public void run() {

new Interfaz().setVisible(true);
}
});
}

public void Abrir() {

JFileChooser fileChooser = new JFileChooser();

JFileChooser jf = new JFileChooser();


FileNameExtensionFilter filter = new FileNameExtensionFilter("txt", "txt");
//FileNameExtensionFilter filter = new FileNameExtensionFilter("html",
"html");
fileChooser.setFileFilter(filter);

int seleccion = fileChooser.showOpenDialog(null);


if (seleccion == JFileChooser.APPROVE_OPTION) {
try {
File fichero = fileChooser.getSelectedFile();
BufferedReader reader;
reader = new BufferedReader(new FileReader(fichero));
jTextArea1.setText(" ");

String linea = reader.readLine();


while (linea != null) {

jTextArea1.append(linea + "\n");
linea = reader.readLine();

reader.close();

} catch (IOException ex) {


}

public void Guardar(String Jtexto) {


String Texto;
JFileChooser guardar = new JFileChooser();

int seleccion = guardar.showSaveDialog(null);


if (seleccion == JFileChooser.APPROVE_OPTION) {
//String dir = "/Users/josiastech/NetBeansProjects/analizador/";
//String dir = guardar.getSelectedFile().getPath();
//String path = "/Users/josiastech/NetBeansProjects/analizador/";
String dir = guardar.getSelectedFile().getPath();

Texto = Jtexto;
String[] arrayText = Texto.split("\n");

try {
FileWriter fichero = null;
PrintWriter pw = null;

//fichero = new FileWriter("salida.html");


fichero = new FileWriter(dir);
pw = new PrintWriter(fichero);

for (int i = 0; i < arrayText.length; i++) {


pw.println(arrayText[i]);
}
fichero.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "No se pudo guardar archivo de
entrada debido a " + e.toString());
}

}
}

public void Salir() {

int op = JOptionPane.showConfirmDialog(null, "Deseas Salir de la


Aplicacion", "CERRAR", JOptionPane.YES_NO_OPTION);

if (op == JOptionPane.YES_OPTION) {
System.exit(0);
}

public void Temporal() {

String uno = new String();


uno = jTextArea1.getText();
try {
// Create temp file.

temp = File.createTempFile("Entrada.txt", "tmp");


// Delete temp file when program exits.
temp.deleteOnExit();

// Write to temp file


BufferedWriter out = new BufferedWriter(new FileWriter(temp));
out.write(uno);
out.close();
} catch (IOException e) {
}

public static void rotular(String name) {


jTextArea2.setText(jTextArea2.getText() + name + "\n");
}

public static void rotular2(String name) {


jTextArea1.setText(jTextArea1.getText() + name + "\n");
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
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.JMenuItem jMenuItem6;
private javax.swing.JMenuItem jMenuItem7;
private javax.swing.JMenuItem jMenuItem8;
private javax.swing.JMenuItem jMenuItem9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTabbedPane jTabbedPane1;
public static javax.swing.JTextArea jTextArea1;
public static javax.swing.JTextArea jTextArea2;
// End of variables declaration//GEN-END:variables
}

Вам также может понравиться