Foro de elhacker.net

Programación => Java => Mensaje iniciado por: wilmer.rondon en 6 Junio 2007, 22:57 pm



Título: como usar Process.getOutputStream()
Publicado por: wilmer.rondon en 6 Junio 2007, 22:57 pm
hola:

alguien me puede decir como usar Process.getOutputStream() para responder a comando ejecutado desde CMD de windows como por ejemplo el comando DATE que despues de ejecutado muestra la fecha actual y espera a que se ingrese la fecha nueva.

este es parte del codigo que llevo hecho... puedo leer mas no escribir

Código:
	class ejecutar implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
String texto = texto1.getText();
                        Runtime rt = Runtime.getRuntime();
//String[] texto = {"date"};
try
{
// Se lanza el ejecutable.
                                Process p = rt.exec("cmd /c " + texto);
p.waitFor();           
// Se obtiene el stream de salida del programa
InputStream is = p.getInputStream();
InputStream er = p.getErrorStream();
                                OutputStream sal = p.getOutputStream();
//                              int wait = p.waitFor();
           
// Se prepara un bufferedReader para poder leer la salida más
// comodamente.
BufferedReader br = new BufferedReader (new InputStreamReader (is));
BufferedReader br2 = new BufferedReader (new InputStreamReader (er));
           
// Se lee la primera linea
String aux = br.readLine();
String aux2 = br2.readLine();                 
                               
// Mientras se haya leido alguna linea
while (aux!=null)
{
// Se escribe la linea en pantalla
areaTexto1.append(aux + newline);
areaTexto1.setCaretPosition(areaTexto1.getDocument().getLength());
texto1.setText("");
               
// y se lee la siguiente.
aux = br.readLine();
}
while (aux2!=null)
{
areaTexto1.append(aux2 + newline);
areaTexto1.setCaretPosition(areaTexto1.getDocument().getLength());
texto1.setText("");
aux2 = br2.readLine();
}
}
catch (Exception e)
{
// Excepciones si hay algún problema al arrancar el ejecutable o al
// leer su salida.
e.printStackTrace();
}
}
}


Título: Re: como usar Process.getOutputStream()
Publicado por: Ragnarok en 6 Junio 2007, 23:13 pm
Pues es lo mismo, solo que en lugar de ser un Stream de entrada es de salida, puedes usar un BufferedWriter o lo que sea. No veo el problema.

PD: por cierto, no conocía la clase Process, parece muy interesante.


Título: Re: como usar Process.getOutputStream()
Publicado por: wilmer.rondon en 6 Junio 2007, 23:36 pm
gracias por tu respuesta... la verdad no tengo mucho programando y lo que llevo hecho ha sido guiandome por codigos de ejemplo que he visto en la red... voy a tratar de hacer algo con los tips que me diste.. gracias


Título: Re: como usar Process.getOutputStream()
Publicado por: wilmer.rondon en 7 Junio 2007, 15:28 pm
hola... este es mi codigo... puedo ejecutar comandos como dir, cd, ipconfig, ping y me muestra la salida... pero con el comando date se queda pegado el programa...

como hago para enviarle la fecha al comando date desde la ventana grafica??? gracias

Código:
// Sistema de Gestión MTSO San Cristóbal
// Realizado por: Wilmer Rondón

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.Color;
import javax.swing.JTabbedPane;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.io.*;
import java.lang.ProcessBuilder;

//********************************************************************************************************************************
// CLASE PRINCIPAL DEL PROGRAMA "VENTANA"
public class Main extends JPanel
{
protected Boolean bd1 = false, bd2 = false, bd3 = false, bd4 = false;
        protected JTextField texto1, texto2, texto3, texto4;
protected JTextArea areaTexto1, areaTexto2, areaTexto3, areaTexto4;
protected JPanel p1A, p1B, p1C, p1D, p2A, p2B, p2C, p2D, p3A, p3B, p3C, p3D, p4A, p4B, p4C, p4D;
protected JButton btOK1, btQuitar1, btSalir1, btOK2, btQuitar2, btSalir2, btOK3, btQuitar3, btSalir3, btOK4, btQuitar4, btSalir4;
protected String texto1Inicio, texto2Inicio, texto3Inicio, texto4Inicio;
protected Color B, F1, F2, F3;
protected int orden;
protected final static String newline = "\n";

//********************************************************************************************************************************
// CONSTRUCTOR DE LA CLASE VENTANA
public Main()
{
ImageIcon icon1 = new ImageIcon("images/ic_ringroad.jpg");
ImageIcon icon2 = new ImageIcon("images/ib_celtic.jpg");
ImageIcon icon3 = new ImageIcon("images/ic_patio.jpg");
ImageIcon icon4 = new ImageIcon("images/mante.jpg");

JTabbedPane pestanas = new JTabbedPane();

Component panel_pestana1 = pestana1("Pestana Uno");
pestanas.addTab("Troncales", icon1, panel_pestana1);
Component panel_pestana2 = pestana2("Pestana Dos");
pestanas.addTab("Packet Pipes", icon2, panel_pestana2);
Component panel_pestana3 = pestana3("Pestana Tres");
pestanas.addTab("Celdas", icon3, panel_pestana3);
Component panel_pestana4 = pestana4("Pestana Cuatro");
pestanas.addTab("Mantenimiento", icon4, panel_pestana4);

setLayout(new GridLayout(1, 1));
add(pestanas);
}

//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA PESTAÑA "TRONCALES"
protected Component pestana1(String text)
{
p1A = new JPanel(new GridLayout(2,1)); // panel Principal
p1B = new JPanel(new BorderLayout());  //
p1C = new JPanel(new BorderLayout());  //
p1D = new JPanel(new GridLayout(1,3)); // panel para 3 botones en BorderLayout.SOUTH
p1A.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));

JTabbedPane subpestanas1 = new JTabbedPane();
Component panel_subpestana11 = subpestana11("Crear");
subpestanas1.addTab("Crear", panel_subpestana11);
Component panel_subpestana12 = subpestana12("Crecer");
subpestanas1.addTab("Crecer", panel_subpestana12);
Component panel_subpestana13 = subpestana13("Dedrecer");
subpestanas1.addTab("Dedrecer", panel_subpestana13);
Component panel_subpestana14 = subpestana14("Eliminar");
subpestanas1.addTab("Eliminar", panel_subpestana14);
Component panel_subpestana15 = subpestana15("Inclusión en Reporte TGCOM");
subpestanas1.addTab("Inclusión en Reporte TGCOMP", panel_subpestana15);
Component panel_subpestana16 = subpestana16("Mudanza");
subpestanas1.addTab("Mudanza", panel_subpestana16);

texto1 = new JTextField(40);
texto1.setFont(new java.awt.Font("Arial", Font.PLAIN, 12));
texto1Inicio = "Escriba aquí un comando y haga click sobre el botón \"OK\"";
texto1.setText(texto1Inicio);

areaTexto1 = new JTextArea(10,40);
areaTexto1.setEditable(false);
areaTexto1.setFont(new java.awt.Font("Arial", Font.PLAIN, 12));
B = new Color(200,200,200);
areaTexto1.setBackground(B);
F1 = new Color(0,0,0);
areaTexto1.setForeground(F1);
JScrollPane pScroll = new JScrollPane(areaTexto1, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

btOK1 = new JButton("OK");
btQuitar1 = new JButton("Limpiar pantalla");
btSalir1 = new JButton("Salir");

texto1.addActionListener(new ejecutar());
btOK1.addActionListener(new ejecutar());
                btOK1.addActionListener(new bdTroncales());
btQuitar1.addActionListener(new limpiarPantalla());
btSalir1.addActionListener(new cerrarVentana());

p1A.add(p1B);
p1A.add(p1C);
p1B.add(subpestanas1);//agregar sub pestanas
p1D.add(btOK1);
p1D.add(btQuitar1);
p1D.add(btSalir1);
p1C.add(texto1,BorderLayout.NORTH);
p1C.add(pScroll, BorderLayout.CENTER);
p1C.add(p1D, BorderLayout.SOUTH);

btOK1.setToolTipText("Ingresar Comando");
btQuitar1.setToolTipText("Limpiar la Pantalla");
btSalir1.setToolTipText("Salir de la aplicación");

return p1A;

}

//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA PESTAÑA "PACKET PIPES"
protected Component pestana2(String text)
{
p2A = new JPanel(new GridLayout(2,1)); // panel Principal
                p2B = new JPanel(new BorderLayout());  //
p2C = new JPanel(new BorderLayout());  //
p2D = new JPanel(new GridLayout(1,3)); // panel para 3 botones en BorderLayout.SOUTH
p2A.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));

JTabbedPane subpestanas2 = new JTabbedPane();
Component panel_subpestana21 = subpestana21("Mudar");
subpestanas2.addTab("Mudar", panel_subpestana21);
Component panel_subpestana22 = subpestana22("Crecer");
subpestanas2.addTab("Crecer", panel_subpestana22);
Component panel_subpestana23 = subpestana23("Dedrecer");
subpestanas2.addTab("Dedrecer", panel_subpestana23);
Component panel_subpestana24 = subpestana24("Equipar");
subpestanas2.addTab("Equipar", panel_subpestana24);
Component panel_subpestana25 = subpestana25("Desequipar");
subpestanas2.addTab("Desequipar", panel_subpestana25);

texto2 = new JTextField(40);
texto2.setFont(new java.awt.Font("Arial", Font.PLAIN, 12));
texto2Inicio = "Escriba aquí un comando y haga click sobre el botón \"OK\"";
texto2.setText(texto2Inicio);

areaTexto2 = new JTextArea(10,40);
areaTexto2.setEditable(false);
areaTexto2.setFont(new java.awt.Font("Arial", Font.PLAIN, 12));
B = new Color(200,200,200);
areaTexto2.setBackground(B);
F1 = new Color(0,0,0);
areaTexto2.setForeground(F1);
JScrollPane pScroll2 = new JScrollPane(areaTexto2, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

btOK2 = new JButton("OK");
btQuitar2 = new JButton("Limpiar pantalla");
btSalir2 = new JButton("Salir");

texto2.addActionListener(new ejecutar());
btOK2.addActionListener(new ejecutar());
btQuitar2.addActionListener(new limpiarPantalla());
btSalir2.addActionListener(new cerrarVentana());

p2A.add(p2B);
p2A.add(p2C);
p2B.add(subpestanas2);//agregar sub pestanas
p2D.add(btOK2);
p2D.add(btQuitar2);
p2D.add(btSalir2);
p2C.add(texto2,BorderLayout.NORTH);
p2C.add(pScroll2, BorderLayout.CENTER);
p2C.add(p2D, BorderLayout.SOUTH);

btOK2.setToolTipText("Ingresar Comando");
btQuitar2.setToolTipText("Limpiar la Pantalla");
btSalir2.setToolTipText("Salir de la aplicación");

return p2A;
}

//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA PESTAÑA "CELDAS"
protected Component pestana3(String text)
{
p3A = new JPanel(new GridLayout(2,1)); // panel Principal
                p3B = new JPanel(new BorderLayout());  //
p3C = new JPanel(new BorderLayout());  //
p3D = new JPanel(new GridLayout(1,3)); // panel para 3 botones en BorderLayout.SOUTH
p3A.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));

JTabbedPane subpestanas3 = new JTabbedPane();
Component panel_subpestana31 = subpestana31("Mudanza de RCS");
subpestanas3.addTab("Mudanza de RCS", panel_subpestana31);
Component panel_subpestana32 = subpestana32("Crear Celda");
subpestanas3.addTab("Crear Celda", panel_subpestana32);
Component panel_subpestana33 = subpestana33("Borrar Celda");
subpestanas3.addTab("Borrar Celda", panel_subpestana33);
Component panel_subpestana34 = subpestana34("---");
subpestanas3.addTab("---", panel_subpestana34);
Component panel_subpestana35 = subpestana35("---");
subpestanas3.addTab("---", panel_subpestana35);

texto3 = new JTextField(40);
texto3.setFont(new java.awt.Font("Arial", Font.PLAIN, 12));
texto3Inicio = "Escriba aquí un comando y haga click sobre el botón \"OK\"";
texto3.setText(texto3Inicio);

areaTexto3 = new JTextArea(10,40);
areaTexto3.setEditable(false);
areaTexto3.setFont(new java.awt.Font("Arial", Font.PLAIN, 12));
B = new Color(200,200,200);
areaTexto3.setBackground(B);
F1 = new Color(0,0,0);
areaTexto3.setForeground(F1);
JScrollPane pScroll3 = new JScrollPane(areaTexto3, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

btOK3 = new JButton("OK");
btQuitar3 = new JButton("Limpiar pantalla");
btSalir3 = new JButton("Salir");

texto3.addActionListener(new ejecutar());
btOK3.addActionListener(new ejecutar());
btQuitar3.addActionListener(new limpiarPantalla());
btSalir3.addActionListener(new cerrarVentana());

p3A.add(p3B);
p3A.add(p3C);
p3B.add(subpestanas3);//agregar sub pestanas
p3D.add(btOK3);
p3D.add(btQuitar3);
p3D.add(btSalir3);
p3C.add(texto3,BorderLayout.NORTH);
p3C.add(pScroll3, BorderLayout.CENTER);
p3C.add(p3D, BorderLayout.SOUTH);

btOK3.setToolTipText("Ingresar Comando");
btQuitar3.setToolTipText("Limpiar la Pantalla");
btSalir3.setToolTipText("Salir de la aplicación");

return p3A;
}

//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA PESTAÑA "MANTENIMIENTO"
protected Component pestana4(String text)
{
p4A = new JPanel(new GridLayout(2,1)); // panel Principal
                p4B = new JPanel(new BorderLayout());  //
p4C = new JPanel(new BorderLayout());  //
p4D = new JPanel(new GridLayout(1,3)); // panel para 3 botones en BorderLayout.SOUTH
p4A.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));

JTabbedPane subpestanas4 = new JTabbedPane();
Component panel_subpestana41 = subpestana41("CKT OOS");
subpestanas4.addTab("CKT OOS", panel_subpestana41);
Component panel_subpestana42 = subpestana42("TST UPATH");
subpestanas4.addTab("TST UPATH", panel_subpestana42);
Component panel_subpestana43 = subpestana43("MEM  NRODD/RODD  SM's");
subpestanas4.addTab("MEM  NRODD/RODD  SM's", panel_subpestana43);
Component panel_subpestana44 = subpestana44("Información del Sistema");
subpestanas4.addTab("Información del Sistema", panel_subpestana44);
Component panel_subpestana45 = subpestana45("BACKUP's DE AP's");
subpestanas4.addTab("BACKUP's DE AP's", panel_subpestana45);
Component panel_subpestana46 = subpestana46("CHKLIST MTSO");
subpestanas4.addTab("CHKLIST MTSO", panel_subpestana46);

texto4 = new JTextField(40);
texto4.setFont(new java.awt.Font("Arial", Font.PLAIN, 12));
texto4Inicio = "Escriba aquí un comando y haga click sobre el botón \"OK\"";
texto4.setText(texto4Inicio);

areaTexto4 = new JTextArea(10,40);
areaTexto4.setEditable(false);
areaTexto4.setFont(new java.awt.Font("Arial", Font.PLAIN, 12));
B = new Color(200,200,200);
areaTexto4.setBackground(B);
F1 = new Color(0,0,0);
areaTexto4.setForeground(F1);
JScrollPane pScroll4 = new JScrollPane(areaTexto4, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

btOK4 = new JButton("OK");
btQuitar4 = new JButton("Limpiar pantalla");
btSalir4 = new JButton("Salir");

texto4.addActionListener(new ejecutar());
btOK4.addActionListener(new ejecutar());
btQuitar4.addActionListener(new limpiarPantalla());
btSalir4.addActionListener(new cerrarVentana());

p4A.add(p4B);
p4A.add(p4C);
p4B.add(subpestanas4);//agregar sub pestanas
p4D.add(btOK4);
p4D.add(btQuitar4);
p4D.add(btSalir4);
p4C.add(texto4,BorderLayout.NORTH);
p4C.add(pScroll4, BorderLayout.CENTER);
p4C.add(p4D, BorderLayout.SOUTH);

btOK4.setToolTipText("Ingresar Comando");
btQuitar4.setToolTipText("Limpiar la Pantalla");
btSalir4.setToolTipText("Salir de la aplicación");

return p4A;
}

//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "CREAR" DE "TRONCALES"
protected Component subpestana11(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}
//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "CRECER" DE "TRONCALES"
protected Component subpestana12(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}
//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "DECRECER" DE "TRONCALES"
protected Component subpestana13(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}
//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "ELIMINAR" DE "TRONCALES"
protected Component subpestana14(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}
//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "INCLUSION EN REPORTE TGCOMP" DE "TRONCALES"
protected Component subpestana15(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}

//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "MUDANZA" DE "TRONCALES"
protected Component subpestana16(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}

//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "MUDAR" DE "PACKET PIPES"
protected Component subpestana21(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}
//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "CRECER" DE "PACKET PIPES"
protected Component subpestana22(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}
//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "DECRECER" DE "PACKET PIPES"
protected Component subpestana23(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}
//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "EQUIPAR" DE "PACKET PIPES"
protected Component subpestana24(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}

//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "DESEQUIPAR" DE "PACKET PIPES"
protected Component subpestana25(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}

//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "MUDANZA DE RCS" DE "CELDAS"
protected Component subpestana31(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}
//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "CREAR" DE "CELDAS"
protected Component subpestana32(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}
//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "BORRAR" DE "CELDAS"
protected Component subpestana33(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}
//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "---" DE "CELDAS"
protected Component subpestana34(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}

//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "---" DE "CELDAS"
protected Component subpestana35(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}

//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "CKT OOS" DE "MANTENIMIENTO"
protected Component subpestana41(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}
//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "TST UPATH" DE "MANTENIMIENTO"
protected Component subpestana42(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}
//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "MEM NRODD/RODD SM's" DE "MANTENIMIENTO"
protected Component subpestana43(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}
//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "INFORMACION DEL SISTEMA" DE "MANTENIMIENTO"
protected Component subpestana44(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}

//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "BACKUP's DE AP's" DE "MANTENIMIENTO"
protected Component subpestana45(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}

//********************************************************************************************************************************
// METODO PARA CONSTRUIR LA SUBPESTAÑA "CHKLIST MTSO" DE "MANTENIMIENTO"
protected Component subpestana46(String text)
{
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}

//********************************************************************************************************************************
// MÉTODO DE ENTRADA AL PROGRAMA
public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("Sistema de Gestión MTSO San Cristóbal");
frame.getContentPane().add(new Main(), BorderLayout.CENTER);
frame.setSize(1280, 770);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

//********************************************************************************************************************************
// CLASE PARA MOSTRAR LAS SALIDAS DE LOS COMANDOS EN PANTALLA
class ejecutar implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
String texto = texto1.getText();
                        Runtime rt = Runtime.getRuntime();
//String[] texto = {"date"};
try
{
// Se lanza el ejecutable.
                                Process p = rt.exec("cmd /c " + texto);           
// Se obtiene el stream de salida del programa
InputStream is = p.getInputStream();
InputStream er = p.getErrorStream();
                                OutputStream sal = p.getOutputStream();
           
// Se prepara un bufferedReader para poder leer la salida más
// comodamente.
BufferedReader br = new BufferedReader (new InputStreamReader (is));
BufferedReader br2 = new BufferedReader (new InputStreamReader (er));
                                BufferedWriter br3 = new BufferedWriter (new OutputStreamWriter (sal));
           
// Se lee la primera linea                               
String aux = br.readLine();
String aux2 = br2.readLine();
                                br3.write("07-06-2007\n");
//                              p.waitFor();
                               
                               
// Mientras se haya leido alguna linea
while (aux!=null)
{
// Se escribe la linea en pantalla
areaTexto1.append(aux + newline);
areaTexto1.setCaretPosition(areaTexto1.getDocument().getLength());
texto1.setText("");
               
// y se lee la siguiente.
aux = br.readLine();
}
while (aux2!=null)
{
areaTexto1.append(aux2 + newline);
areaTexto1.setCaretPosition(areaTexto1.getDocument().getLength());
texto1.setText("");
aux2 = br2.readLine();
}
}
catch (Exception e)
{
// Excepciones si hay algún problema al arrancar el ejecutable o al
// leer su salida.
e.printStackTrace();
}
}
}

//********************************************************************************************************************************
// CLASE QUE ACTIVA LA BANDERA DE ESCRITURA EN TEXT AREA
class bdTroncales implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
bd1 = true;
}
}
       
//********************************************************************************************************************************
// CLASE QUE VACÍA TEXTAREA
class limpiarPantalla implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
texto1.setFont(new java.awt.Font("Arial", Font.PLAIN, 12));
F3 = new Color(0,0,0);
texto1.setForeground(F3);
texto1.setText("");
texto2.setText("");
}
}

//********************************************************************************************************************************
// CLASE QUE SALE DEL PROGRAMA
class cerrarVentana implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
System.exit(0);
}
}