import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; public class objectivePane extends JPanel { public JTextArea diagnosticoArea; public JTextArea tratamientoArea; public JTextArea comentariosArea; public JTextArea vitalSignsArea; public JLabel vitalSignsLabel; public objectivePane() { try { SpringLayout layout = new SpringLayout(); setLayout(layout); setOpaque(true); vitalSignsLabel = new JLabel("SIGNOS VITALES ANTERIORES"); vitalSignsArea = new JTextArea("No existen datos anteriores",5,25); vitalSignsArea.setEditable(false); JScrollPane scrollPane1 = new JScrollPane(vitalSignsArea); scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); JComponent panel0 = makeScrollPanel(scrollPane1); add(vitalSignsLabel); add(panel0); layout.putConstraint(SpringLayout.NORTH, vitalSignsLabel, 10, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, vitalSignsLabel, 15, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, panel0, 10, SpringLayout.SOUTH, vitalSignsLabel); layout.putConstraint(SpringLayout.WEST, panel0, 15, SpringLayout.WEST, this); //Creación de las distintas paneles de texto con sus características respectivas diagnosticoArea = new JTextArea("No existen diagnosticos anteriores",5,25); diagnosticoArea.setEditable(false); JScrollPane diagnosticoScrollPane = new JScrollPane(diagnosticoArea); diagnosticoScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); tratamientoArea = new JTextArea("No existen tratamientos anteriores"); tratamientoArea.setEditable(false); JScrollPane tratamientoScrollPane = new JScrollPane(tratamientoArea); tratamientoScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); comentariosArea = new JTextArea(); //comentariosArea.setEditable(false); JScrollPane comentariosScrollPane = new JScrollPane(comentariosArea); comentariosScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); //Creación del tabbedPane con sus tabs JTabbedPane tabbedPane = new JTabbedPane(); JComponent panel1 = makeScrollPanel(diagnosticoScrollPane); tabbedPane.addTab("Diagnóstico", panel1); tabbedPane.setMnemonicAt(0, KeyEvent.VK_D); JComponent panel2 = makeScrollPanel(tratamientoScrollPane); tabbedPane.addTab("Tratamiento", panel2); tabbedPane.setMnemonicAt(1, KeyEvent.VK_M); JComponent panel3 = makeScrollPanel(comentariosScrollPane); tabbedPane.addTab("Comentarios", panel3); tabbedPane.setMnemonicAt(2, KeyEvent.VK_C); add(tabbedPane); //Uncomment the following line to use scrolling tabs. tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); layout.putConstraint(SpringLayout.NORTH, tabbedPane, 20, SpringLayout.SOUTH, panel0); layout.putConstraint(SpringLayout.WEST, tabbedPane, 15, SpringLayout.WEST, this); } catch(Exception e) { System.out.println(e.toString()); } } public objectivePane(String ARCHIVO1, String ARCHIVO2, String ARCHIVO3, String ARCHIVO4) throws Exception { SpringLayout layout = new SpringLayout(); setLayout(layout); setOpaque(true); /**********************************************/ File signos = new File(ARCHIVO1); File diagnostico = new File(ARCHIVO2); File tratamiento = new File(ARCHIVO3); File comentarios = new File(ARCHIVO4); FileReader in1 = new FileReader(signos); FileReader in2 = new FileReader(diagnostico); FileReader in3 = new FileReader(tratamiento); FileReader in4 = new FileReader(comentarios); StringWriter out1 = new StringWriter(); StringWriter out2 = new StringWriter(); StringWriter out3 = new StringWriter(); StringWriter out4 = new StringWriter(); String signosString = new String(); String diagnosticoString = new String(); String tratamientoString = new String(); String comentariosString = new String(); int c; while ((c = in1.read()) != -1) { out1.write(c); signosString = out1.toString(); } while ((c = in2.read()) != -1) { out2.write(c); diagnosticoString = out2.toString(); } while ((c = in3.read()) != -1) { out3.write(c); tratamientoString = out3.toString(); } while ((c = in4.read()) != -1) { out4.write(c); comentariosString = out4.toString(); } /**************************************************/ vitalSignsLabel = new JLabel("SIGNOS VITALES ANTERIORES"); vitalSignsArea = new JTextArea(signosString,5,25); vitalSignsArea.setEditable(false); vitalSignsArea.setTabSize(7); JScrollPane scrollPane1 = new JScrollPane(vitalSignsArea); scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); JComponent panel0 = makeScrollPanel(scrollPane1); add(vitalSignsLabel); add(panel0); layout.putConstraint(SpringLayout.NORTH, vitalSignsLabel, 10, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, vitalSignsLabel, 15, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, panel0, 10, SpringLayout.SOUTH, vitalSignsLabel); layout.putConstraint(SpringLayout.WEST, panel0, 15, SpringLayout.WEST, this); //Creación de las distintas paneles de texto con sus características respectivas diagnosticoArea = new JTextArea(diagnosticoString,5,25); diagnosticoArea.setEditable(false); JScrollPane diagnosticoScrollPane = new JScrollPane(diagnosticoArea); diagnosticoScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); tratamientoArea = new JTextArea(tratamientoString); tratamientoArea.setEditable(false); JScrollPane tratamientoScrollPane = new JScrollPane(tratamientoArea); tratamientoScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); comentariosArea = new JTextArea(comentariosString); // comentariosArea.setEditable(false); JScrollPane comentariosScrollPane = new JScrollPane(comentariosArea); comentariosScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); //Creación del tabbedPane con sus tabs JTabbedPane tabbedPane = new JTabbedPane(); JComponent panel1 = makeScrollPanel(diagnosticoScrollPane); tabbedPane.addTab("Diagnóstico", panel1); tabbedPane.setMnemonicAt(0, KeyEvent.VK_D); JComponent panel2 = makeScrollPanel(tratamientoScrollPane); tabbedPane.addTab("Tratamiento", panel2); tabbedPane.setMnemonicAt(1, KeyEvent.VK_M); JComponent panel3 = makeScrollPanel(comentariosScrollPane); tabbedPane.addTab("Comentarios", panel3); tabbedPane.setMnemonicAt(2, KeyEvent.VK_C); //Add the tabbed pane to this panel. add(tabbedPane); //Uncomment the following line to use scrolling tabs. tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); layout.putConstraint(SpringLayout.NORTH, tabbedPane, 20, SpringLayout.SOUTH, panel0); layout.putConstraint(SpringLayout.WEST, tabbedPane, 15, SpringLayout.WEST, this); in1.close(); in2.close(); in3.close(); in4.close(); } //Convierte el scrollPane en un componente (panel) normal protected JComponent makeScrollPanel(JScrollPane pane) { JPanel panel = new JPanel(false); panel.setLayout(new GridLayout(1, 1)); panel.add(pane); return panel; } }