| |
| 如何用Java开发"多画面浏览器" 有没有源程序? |
| |
发布者:DJ 发布时间:2007-01-02 |
|
|
如何用Java开发"多画面浏览器" 有没有源程序! 我只会写这些:
import java.io.IOException; import java.net.URL; import javax.swing.*; import javax.swing.text.Document; import javax.swing.text.JTextComponent; import java.awt.*; import java.awt.event.*; import javax.swing.event.*; public class HtmlBrowser extends JFrame{ JPanel contentPane; BorderLayout borderLayoutAll=new BorderLayout(); JLabel jLabelPrompt=new JLabel(); JPanel jPanelMain=new JPanel(); BorderLayout borderLayoutMain=new BorderLayout(); JTextField textFieldURL=new JTextField(); JEditorPane jEditorPane=new JEditorPane(); public HtmlBrowser() { try{jbInit(); } catch(Exception e){ e.printStackTrace();} } private void jbInit()throws Exception{ contentPane=(JPanel)getContentPane(); contentPane.setLayout(borderLayoutAll); jPanelMain.setLayout(borderLayoutMain); jLabelPrompt.setText("please enter url"); textFieldURL.setText(" "); textFieldURL.addActionListener(new java.awt.event.ActionListener(){ public void actionPerformed(ActionEvent e) {textFieldURL_actionPerformed(e);} }); jEditorPane.setEditable(false); jEditorPane.addHyperlinkListener(new javax.swing.event.HyperlinkListener() {public void hyperlinkUpdate(HyperlinkEvent e){ jEditorPane_hyperlinkUpdate(e);} }); JScrollPane scrollPane=new JScrollPane(); scrollPane.getViewport().add(jEditorPane); jPanelMain.add(textFieldURL,"North"); jPanelMain.add(scrollPane,"Center"); contentPane.add(jLabelPrompt,"North"); contentPane.add(jPanelMain,"Center"); enableEvents(AWTEvent.WINDOW_EVENT_MASK); this.setSize(new Dimension(600,500)); this.setTitle("我的浏览器"); this.setVisible(true); } void textFieldURL_actionPerformed(ActionEvent e){ try{jEditorPane.setPage(textFieldURL.getText()); } catch(IOException ex){JOptionPane msg=new JOptionPane(); JOptionPane.showMessageDialog(this,"URL地址不正确:"+textFieldURL.getText(),"输入不正确 !",0); } } void jEditorPane_hyperlinkUpdate(HyperlinkEvent e) { if(e.getEventType ()== javax.swing.event.HyperlinkEvent.EventType.ACTIVATED) { try{ URL url=e.getURL(); jEditorPane.setPage(url); textFieldURL.setText(url.toString());} catch(IOException io){ JOptionPane msg=new JOptionPane(); JOptionPane.showMessageDialog(this,"打开文件失败!"+textFieldURL.getText(),"输入的不正确!",0); } } } protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } public static void main(String[] args) { new HtmlBrowser(); } }
|
| (转载文章请保留出处:北天JAVA技术网(www.java114.com)) |
| |
| 更多精彩文章: |
| 基于Socket的Java网络编程集粹 |
| java进度条 |
| 商业智能和决策分析 |
| OA办公软件闹革命 阵营开始分化 |
| ERP走向平台化 |
| YODODO苗湾儿:为自己的梦想打工 |
| |
| 最近评论: |
|
|
| 你曾悄悄的来过! |
| wow gold,wow gold,wow gold,ffxi gil max(7923) |
|
|
| 你曾悄悄的来过! |
| wow gold,wow gold,wow gold,ffxi gil max(1331) |
|
|
| 冰封的往事! |
| wow power leveling,wow gold,wow power leveling,wow gold
max(9230) |
|
|
| 冰封的往事! |
| wow power leveling,wow gold,WoW Gold,wow gold
max(9974) |
|
|
| 飞舞的传奇! |
| 传世私服,传世私服.传奇世界私服传奇世界私服,传世私服传世私服, 传奇世界私服传奇世界私服.传奇私服传奇私服. max(9257) |
|
|
| |
| 免责声明:该文章由网友发表,如果对您造成侵权,请联系站长。 |
|