请问怎么用JAVA编一个WEB浏览器? 有特定的类可以实现, 不过要处理图片和其它脚本的话可能会比较费事(我以前是用专门的线程处理图像下载, 笨笨:))具体请看一下<<Java Networking Programming>>(有英文版最好, 看中文版的话你会很郁闷.) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不过那个类不支持最新的HTML版本的. 目前正在看《JAVA2网络协议内幕》,可是还是不太懂。我的想法是想作一个类似IE的浏览器,当然只是简单的而已。可是图形界面就把我难住了。还是学的太浅。各位高手多指点。 http://www.netcluesoft.com/ /) (\ .-._((,~~.))_.-, `-. @@ ,-' / ,n--n. \ (`'\ ( ( .__. ) ) /`') `.'"._ ) `----' (_,"`.' "._ _," / \ hjw ( ) `97 (`-.__ __.-') \ /`--'\ / ) / \ ( /._\ /_,\Power by CSDN论坛助手 这里就有一个Horstmann写得简单的,大致结构就这样了你可以用JInternalFrame,建立一个MDI的/** * @version 1.00 1999-07-17 * @author Cay Horstmann */import java.awt.*;import java.awt.event.*;import java.io.*;import java.util.*;import javax.swing.*;import javax.swing.event.*;public class EditorPaneTest{ public static void main(String[] args) { JFrame frame = new EditorPaneFrame(); frame.show(); }}class EditorPaneFrame extends JFrame{ public EditorPaneFrame() { setTitle("EditorPaneTest"); setSize(600, 400); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } } ); // set up text field and load button for typing in URL url = new JTextField(30); loadButton = new JButton("Load"); loadButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { // remember URL for back button urlStack.push(url.getText()); editorPane.setPage(url.getText()); } catch(IOException e) { editorPane.setText("Error: " + e); } } }); // set up back button and button action backButton = new JButton("Back"); backButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { if (urlStack.size() <= 1) return; try { // get URL from back button urlStack.pop(); // show URL in text field String urlString = (String)urlStack.peek(); url.setText(urlString); editorPane.setPage(urlString); } catch(IOException e) { editorPane.setText("Error: " + e); } } }); // set up editor pane and hyperlink listener editorPane = new JEditorPane(); editorPane.setEditable(false); editorPane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { // remember URL for back button urlStack.push(event.getURL().toString()); // show URL in text field url.setText(event.getURL().toString()); editorPane.setPage(event.getURL()); } catch(IOException e) { editorPane.setText("Error: " + e); } } } }); // set up checkbox for toggling edit mode editable = new JCheckBox(); editable.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { editorPane.setEditable(editable.isSelected()); } }); Container contentPane = getContentPane(); contentPane.add(new JScrollPane(editorPane), "Center"); // put all control components in a panel JPanel panel = new JPanel(); panel.add(new JLabel("URL")); panel.add(url); panel.add(loadButton); panel.add(backButton); panel.add(new JLabel("Editable")); panel.add(editable); contentPane.add(panel, "South"); } private JTextField url; private JCheckBox editable; private JButton loadButton; private JButton backButton; private JEditorPane editorPane; private Stack urlStack = new Stack();} 不过要是支持script什么的,就麻烦了 谢谢akara(阿剑),skyyoung(路人甲)(可惜校园网访问不了国外的网站) 当然更要感谢DanielYWoo(绿色毒汁),你的代码正在研究中。 求:swing hacks电子书 classloader相关基础知识 初学问题 多谢。简单问题。 如何在applet中点击按扭,打开浏览器窗口,然后跳转到指定网页面中?就象点击超连接一样?谢谢! 新手请教的问题 JOptionPane.showMessageDialog弹出框如何显示JTable? 初学者100分求助:关于applet GUI的问题! ****如何执行外部exe程序? 怎么样捕获鼠标的双击事件? 如何区分oracle里的number型和float型?急!!! 如何用java编一个计算器
我的想法是想作一个类似IE的浏览器,当然只是简单的而已。
可是图形界面就把我难住了。
还是学的太浅。
各位高手多指点。
.-._((,~~.))_.-,
`-. @@ ,-'
/ ,n--n. \
(`'\ ( ( .__. ) ) /`')
`.'"._ ) `----' (_,"`.'
"._ _,"
/ \
hjw ( )
`97 (`-.__ __.-')
\ /`--'\ /
) / \ (
/._\ /_,\Power by CSDN论坛助手
你可以用JInternalFrame,建立一个MDI的/**
* @version 1.00 1999-07-17
* @author Cay Horstmann
*/import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;public class EditorPaneTest
{ public static void main(String[] args)
{ JFrame frame = new EditorPaneFrame();
frame.show();
}
}class EditorPaneFrame extends JFrame
{ public EditorPaneFrame()
{ setTitle("EditorPaneTest");
setSize(600, 400);
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{ System.exit(0);
}
} ); // set up text field and load button for typing in URL url = new JTextField(30); loadButton = new JButton("Load");
loadButton.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent event)
{ try
{ // remember URL for back button
urlStack.push(url.getText()); editorPane.setPage(url.getText());
}
catch(IOException e)
{ editorPane.setText("Error: " + e);
}
}
}); // set up back button and button action backButton = new JButton("Back");
backButton.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent event)
{ if (urlStack.size() <= 1) return;
try
{ // get URL from back button
urlStack.pop();
// show URL in text field
String urlString = (String)urlStack.peek();
url.setText(urlString); editorPane.setPage(urlString);
}
catch(IOException e)
{ editorPane.setText("Error: " + e);
}
}
}); // set up editor pane and hyperlink listener editorPane = new JEditorPane();
editorPane.setEditable(false);
editorPane.addHyperlinkListener(new HyperlinkListener()
{ public void hyperlinkUpdate(HyperlinkEvent event)
{ if (event.getEventType()
== HyperlinkEvent.EventType.ACTIVATED)
{ try
{ // remember URL for back button
urlStack.push(event.getURL().toString());
// show URL in text field
url.setText(event.getURL().toString()); editorPane.setPage(event.getURL());
}
catch(IOException e)
{ editorPane.setText("Error: " + e);
}
}
}
}); // set up checkbox for toggling edit mode editable = new JCheckBox();
editable.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent event)
{ editorPane.setEditable(editable.isSelected());
}
}); Container contentPane = getContentPane();
contentPane.add(new JScrollPane(editorPane), "Center"); // put all control components in a panel JPanel panel = new JPanel();
panel.add(new JLabel("URL"));
panel.add(url);
panel.add(loadButton);
panel.add(backButton);
panel.add(new JLabel("Editable"));
panel.add(editable); contentPane.add(panel, "South");
} private JTextField url;
private JCheckBox editable;
private JButton loadButton;
private JButton backButton;
private JEditorPane editorPane;
private Stack urlStack = new Stack();
}
当然更要感谢DanielYWoo(绿色毒汁),你的代码正在研究中。