import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; public class objectivePane extends JPanel { //agregadas por mi. areas de texto sin estilo. protected JTextArea diagnosticoArea; protected JTextArea tratamientoArea; protected JTextArea comentariosArea; protected JTextArea area1; protected JLabel label1; public objectivePane(String archivo1, String archivo2, String archivo3) throws IOException { SpringLayout layout = new SpringLayout(); setLayout(layout); setOpaque(true); label1 = new JLabel("Signos Vitales anteriores:"); area1 = new JTextArea(5,35); JScrollPane scrollPane1 = new JScrollPane(area1); scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); JComponent panel0 = makeScrollPanel(scrollPane1); add(label1); add(panel0); layout.putConstraint(SpringLayout.NORTH, label1, 10, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, label1, 10, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, panel0, 10, SpringLayout.SOUTH, label1); layout.putConstraint(SpringLayout.WEST, panel0, 10, SpringLayout.WEST, this); /**********************************************/ File diagnostico = new File(archivo1); File tratamiento = new File(archivo2); File comentarios = new File(archivo3); FileReader in1 = new FileReader(diagnostico); FileReader in2 = new FileReader(tratamiento); FileReader in3 = new FileReader(comentarios); StringWriter out1 = new StringWriter(); StringWriter out2 = new StringWriter(); StringWriter out3 = new StringWriter(); String diagnosticoString = new String(); String tratamientoString = new String(); String comentariosString = new String(); int c; while ((c = in1.read()) != -1) { out1.write(c); diagnosticoString = out1.toString(); } while ((c = in2.read()) != -1) { out2.write(c); tratamientoString = out2.toString(); } while ((c = in3.read()) != -1) { out3.write(c); comentariosString = out3.toString(); } /**************************************************/ //Creación de las distintas paneles de texto con sus características respectivas diagnosticoArea = new JTextArea(diagnosticoString,5,35); 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(); // ImageIcon icon = createImageIcon("images/middle.gif"); JComponent panel1 = makeScrollPanel(diagnosticoScrollPane); // tabbedPane.addTab("Diagnóstico", icon, panel1, "Diagnósticos y avances"); tabbedPane.addTab("Diagnóstico", panel1); tabbedPane.setMnemonicAt(0, KeyEvent.VK_D); JComponent panel2 = makeScrollPanel(tratamientoScrollPane); // tabbedPane.addTab("Tratamiento", icon, panel2, "Medicamentos recetados"); tabbedPane.addTab("Tratamiento", panel2); tabbedPane.setMnemonicAt(1, KeyEvent.VK_M); JComponent panel3 = makeScrollPanel(comentariosScrollPane); // tabbedPane.addTab("Comentarios", icon, panel3, "Comentarios"); 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, 10, SpringLayout.WEST, this); in1.close(); in2.close(); in3.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; } /** Returns an ImageIcon, or null if the path was invalid. */ /* protected static ImageIcon createImageIcon(String path) { java.net.URL imgURL = objectivePane.class.getResource(path); if (imgURL != null) { return new ImageIcon(imgURL); } else { System.err.println("Couldn't find file: " + path); return null; } }*/ }