22/10/12 15:58
giordanomalandra
ho creato un webbrowser in java ora il problema è che navigando su questo browser ho scoperto che viene letto solo il codice html della pagina e non il codice javascript come devo fare per far leggere al mio browser anche il codice javascript ecco il codice GRAZIE 1000
package browser; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.net.*; import java.io.*; public class Browser { private JFrame frame; private JPanel panelTop; private JEditorPane editor; private JScrollPane scroll; private JTextField field; private JButton button; private URL url; public Browser(String titolo) { initComponents(); frame.setTitle(ttolo); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(800,600); frame.add(BorderLayout.NORTH, panelTop); panelTop.add(field); panelTop.add(button); frame.add(BorderLayout.CENTER, scroll); frame.setVisible(true); } private void initComponents() { frame = new JFrame(); panelTop = new JPanel(); try { url = new URL("http://www.corrieredellosport.it"); } catch(MalformedURLException mue) { JOptionPane.showMessageDialog(null,mue); } try { editor = new JEditorPane(url); editor.setContentType("text/html"); editor.setEditable(false); } catch(IOException ioe) { JOptionPane.showMessageDialog(null,ioe); } scroll = new JScrollPane(editor); field = new JTextField(); SwingUtilities.invokeLater(new Runnable() { public void run() { field.setText(url.toString()); } }); button = new JButton("VAI"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { editor.setPage(field.getText()); } catch(IOException ioe) { JOptionPane.showMessageDialog(null, ioe); } } }); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { new Browser("Simple web browser"); } }); }//end main method. }
aaa