请问在applet中怎么打开html(asp,jsp)页! applet.getAppletContext().showDocument(URL url, String target) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //try this, this is an application, if u like //you can just simply change it to applet//good luckimport java.awt.*;import java.awt.event.*;import java.net.*;import java.io.*;import javax.swing.*;import javax.swing.event.*;public class Test extends JFrame { private JTextField enterField; private JEditorPane contentsArea; private String add = new String("http://www.yahoo.com"); public Test() { super( "Simple Web Browser" ); Container container = getContentPane(); enterField = new JTextField( add ); enterField.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent event ) { getThePage( event.getActionCommand() ); } } ); container.add( enterField, BorderLayout.NORTH ); contentsArea = new JEditorPane(); contentsArea.setEditable( false ); contentsArea.addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate( HyperlinkEvent event ) { if ( event.getEventType() == HyperlinkEvent.EventType.ACTIVATED ) getThePage( event.getURL().toString() ); } } ); container.add( new JScrollPane( contentsArea ), BorderLayout.CENTER ); setSize( 400, 300 ); setVisible( true ); this.getThePage(add) ; } private void getThePage( String location ) { setCursor( Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR ) ); try { contentsArea.setPage( location ); enterField.setText( location ); } catch ( IOException ioException ) { JOptionPane.showMessageDialog( this, "Error retrieving specified URL", "Bad URL", JOptionPane.ERROR_MESSAGE ); } setCursor( Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR ) ); } public static void main( String args[] ) { Test application = new Test(); application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); }} java编写坦克大战遇到的问题 jsp的转换form action java代码 Socket通信问题 初学java 如何发布java程序? 一算法,一方法!!! 求救!!高手和好心人!! 终于把thinking in java 前3章看完了,请出题!! java的类继承问题!!!!!! Java中异步调用如何实现 哪位高手知道哪里有应用在网络传输中的加密IO流 事件模型,请大家讨论,讲的好的加分 请问各位大哥﹐谁可以提供thinking in java 3rd edition & core java I,II的电子书或者是下载网址给我?
//you can just simply change it to applet
//good luckimport java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import javax.swing.*;
import javax.swing.event.*;public class Test extends JFrame {
private JTextField enterField;
private JEditorPane contentsArea;
private String add = new String("http://www.yahoo.com"); public Test()
{
super( "Simple Web Browser" ); Container container = getContentPane(); enterField = new JTextField( add ); enterField.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent event )
{
getThePage( event.getActionCommand() );
}
}
); container.add( enterField, BorderLayout.NORTH );
contentsArea = new JEditorPane();
contentsArea.setEditable( false ); contentsArea.addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate( HyperlinkEvent event )
{
if ( event.getEventType() ==
HyperlinkEvent.EventType.ACTIVATED )
getThePage( event.getURL().toString() );
}
} ); container.add( new JScrollPane( contentsArea ),
BorderLayout.CENTER ); setSize( 400, 300 );
setVisible( true ); this.getThePage(add) ;
} private void getThePage( String location )
{
setCursor( Cursor.getPredefinedCursor(
Cursor.WAIT_CURSOR ) ); try {
contentsArea.setPage( location );
enterField.setText( location );
} catch ( IOException ioException ) {
JOptionPane.showMessageDialog( this,
"Error retrieving specified URL",
"Bad URL", JOptionPane.ERROR_MESSAGE );
} setCursor( Cursor.getPredefinedCursor(
Cursor.DEFAULT_CURSOR ) );
} public static void main( String args[] )
{
Test application = new Test(); application.setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE );
}}