est-ce possible? J'ai fait un simple navigateur Web, il peut voir quelques pages bien, mais la plupart sont foiré, je crois que cela peut être à cause de cela (javascript n'est pas activé). Par exemple voici comment CNN.com apparaît: http://www.glowfoto.com/static_image/07-181402L/5111/png/07/2010/img5/glowfotoJavascript fonctionne dans le navigateur Web Java?
ici est mon code à ce jour:
public class Browser extends JPanel {
private JEditorPane mainArea;
private JTextField adress;
private JPanel justtoseparatethings;
public Browser() {
setLayout(new BorderLayout());
setVisible(true);
mainArea = new JEditorPane();
adress = new JTextField();
justtoseparatethings = new JPanel();
adress.setEditable(true);
adress.setSize(0, 0);
mainArea.setEditable(false);
mainArea.setContentType("text/html");
justtoseparatethings.setLayout(new BorderLayout());
justtoseparatethings.add(adress);
add(justtoseparatethings, BorderLayout.NORTH);
//mejor separar estos por paneles tb
//add(mainArea, BorderLayout.CENTER);
add(new JScrollPane(mainArea),BorderLayout.CENTER);
adress.addKeyListener(new KeyListener() {
public void keyReleased(KeyEvent ke) {
}
public void keyPressed(KeyEvent ke) {
if (adress.hasFocus() && ke.getKeyCode() == KeyEvent.VK_ENTER) {
try {
String unproc = adress.getText();
String start = "http://";
int index1 = unproc.indexOf(start);
if (index1 != -1) {
mainArea.setPage(adress.getText());
} else {
unproc = start + unproc;
}
adress.setText(unproc);
mainArea.setPage(unproc);
} catch (Exception a) {
System.out.println("there was an error in your request");
}
}
}
public void keyTyped(KeyEvent ke) {
}
});
mainArea.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent hle) {
if (hle.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
try {
mainArea.setPage(hle.getURL());
adress.setText(mainArea.getPage().toString());
} catch (Exception ex) {
mainArea.setText("Error ocurred" + ex.getMessage());
}
}
}
});
}
}
merci à l'avance
Je pense qu'une partie du problème est que le CSS n'est pas correctement analysé non plus. – qw3n