求教:把Applet直接做为一个LINK连向一个网业应该怎么编???? 处理 click 事件, 当发生事件时,调用 Applet 的 getAppletContext().showDocument(new URL("http://www.csdn.net")); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //I dont't really understand your question//请说的详细点//but you can still try the following code//I think it's helpfulimport java.awt.*;import java.awt.event.*;import java.net.*;import java.io.*;import javax.swing.*;import javax.swing.event.*;public class Test2 extends JFrame { private JTextField enterField; private JEditorPane contentsArea; private String add = new String("http://www.yahoo.com"); public Test2() { 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[] ) { Test2 application = new Test2(); application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); }} 求解,这个递归函数中返回值的执行过程? 一个关于菜单的问题,请教大家。 送分题 JFrame 如何用正则表达式分割字符串 怎么获得ComboBox中选定Item的String值? 急啊,那位兄弟有全球IP地址的分配对应表? java初学者疑惑,请各位高手指点! [公告]撤销sharetop的版主职务 JAVA的SERVERSOCKET线程如何和客户端进行通信? 问一个关于方法重载的简单的问题 JDBC联接MySQL,不能正常输出中文
//请说的详细点
//but you can still try the following code
//I think it's helpfulimport java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import javax.swing.*;
import javax.swing.event.*;public class Test2 extends JFrame {
private JTextField enterField;
private JEditorPane contentsArea;
private String add = new String("http://www.yahoo.com"); public Test2()
{
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[] )
{
Test2 application = new Test2(); application.setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE );
}}