import java.awt.*; import javax.swing.*; import java.util.*; import java.sql.*; import java.awt.event.*; public class Administrador { static int ancho = 700; static int alto = 550; static int counter = 0; public static void createAndShowGUI(boolean es_nuevo) { try { counter++; //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); //Create and set up the window. JFrame frame = new JFrame("ATENCION MEDICO DOMICILIARIA"); frame.addWindowListener(new windowListener(counter)); //Creacion del content pane a ser utlizado JPanel contentPane = new JPanel(); contentPane.setOpaque(true); contentPane.setLayout(new BorderLayout()); //Agregar los distintos panes al content pane del frame principal. JSplitPane splitH = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new objectivePane(), new subjectivePane()); splitH.setDividerLocation(ancho/2); JSplitPane splitV = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new personalPane2(), splitH); splitV.setDividerLocation(175); contentPane.add(splitV); //Create and set up the content pane. frame.setContentPane(contentPane); frame.setJMenuBar(new MenuBar(frame, es_nuevo)); //Display the window. frame.setSize(ancho, alto); frame.setLocation(0,0); frame.setVisible(true); } catch (Exception e) { System.out.println("ERROR AL ABRIR NUEVO"); } } public static void createAndShowGUI(String RUT, boolean es_nuevo) { try { counter++; int ancho = 700; int alto = 550; dataBase data = new dataBase(); data.getPersonalData(RUT); data.getFilesData(RUT); //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); //Create and set up the window. JFrame frame = new JFrame("ATENCION MEDICO DOMICILIARIA"); frame.addWindowListener( new windowListener(counter)); //Creacion del content pane a ser utlizado JPanel contentPane = new JPanel(); contentPane.setOpaque(true); contentPane.setLayout(new BorderLayout()); //Agregar los distintos panes al content pane del frame principal. JSplitPane splitH = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new objectivePane(data.getVitalSignsFile(),data.getDiagnosticFile(),data.getTreatmentFile(),data.getCommentaryFile()), new subjectivePane()); splitH.setDividerLocation(ancho/2); JSplitPane splitV = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new personalPane(data.getName(),data.getRut1(),data.getRut2(),data.getNacimientoD(),data.getNacimientoM(),data.getNacimientoA(),data.getSex(),data.getAddress(),data.getCity(),data.getFono1(),data.getFono2(),data.getPrevision()), splitH); splitV.setDividerLocation(175); contentPane.add(splitV); //Create and set up the content pane. frame.setContentPane(contentPane); frame.setJMenuBar(new MenuBar(frame,es_nuevo)); //Display the window. frame.setSize(ancho, alto); frame.setLocation(0,0); frame.setVisible(true); } catch (Exception e) { System.out.println("ERROR I/O"); } } public static void createAndShowGUI() { try { String s = (String)JOptionPane.showInputDialog( null, "Ingrese nuevo RUT:\n", "Abrir", JOptionPane.INFORMATION_MESSAGE, null,null,null); if (s == null) { System.out.println("CANCELADO"); Administrador nuevaVentana = new Administrador(); nuevaVentana.createAndShowGUI(true); return; } Administrador nuevaVentana = new Administrador(); nuevaVentana.createAndShowGUI(s,false); } catch (Exception e) { System.out.println("ERROR I/O"); } } public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); // ocupa el constructor por defecto } }); } } class windowListener implements WindowListener { private static int counter; public windowListener(int contador) { counter = contador; } // Do nothing methods required by interface public void windowActivated( WindowEvent e) {} public void windowDeactivated( WindowEvent e) {} public void windowIconified( WindowEvent e) {} public void windowDeiconified( WindowEvent e) {} public void windowOpened( WindowEvent e) {} public void windowClosed( WindowEvent e) {} public void windowClosing( WindowEvent e) { counter--; System.out.println(counter); if(counter<=0) System.exit(0); } }