rt 

解决方案 »

  1.   

    你说的是这个吗?try{ 
    String command = 
    "C:\\Program Files\\Internet Explorer\\Iexplore.exe www.csdn.net"; 
    Runtime.getRuntime().exec(command); 
    }catch(IOException ex){} 
    有没有别的方法?
      

  2.   

    //Desktop是JDK1.6的新特性,可以用其中的browse方法调用默认的浏览器来打开网页
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.net.URI;
    import java.io.*;public class Browse extends JFrame{
     private Container container;
     private Desktop desktop;
     private JLabel label;
     public Browse(){
      super("Browse测试");
      desktop = Desktop.getDesktop(); //Desktop类没有构造方法,只能用静态方法getDesktop返回当前浏览器上下文的 Desktop 实例  label = new JLabel();
      label.setText("<html><A   href='http://www.google.cn'>谷歌</A></html>");//让字体以超文本的方式显示
      
      //为label注册鼠标监听器,若单击则打开网页
      label.addMouseListener(
       new MouseAdapter(){
        public void mouseClicked(MouseEvent event){
         try{
          desktop.browse(new URI("www.google.cn"));
         }
         catch(Exception e){
         }
        }
       }
      );
      container = getContentPane();
      container.setLayout(new FlowLayout());
      container.add(label);
      
      setVisible(true);
      pack();
      setResizable(false);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      
      //使窗口屏幕居中
      Dimension frameSize,screenSize = Toolkit.getDefaultToolkit().getScreenSize();
      frameSize = getSize();
      setLocation((screenSize.width-frameSize.width)/2,(screenSize.height-frameSize.height)/2);
     }
     
     public static void main(String args[]){
      Browse browse = new Browse();
     }
    }
      

  3.   

    LZ的意思我想应该是想用Java打开一个网络页面吧?//代码是收藏的import java.awt.BorderLayout;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    import javax.swing.JEditorPane;
    import java.awt.Rectangle;
    import javax.swing.JTextPane;
    import java.awt.Dimension;
    import java.awt.GridBagLayout;
    import java.awt.GridBagConstraints;
    import java.io.File;
    import java.io.IOException;
    import java.net.URL;
    import java.net.MalformedURLException;import javax.swing.JScrollPane;public class Lk extends JFrame {private static final long serialVersionUID = 1L;private JPanel jContentPane = null;private JPanel jPanel = null;private JScrollPane jScrollPane = null;private JTextPane jTextPane = null;public Lk() {
      super();
      initialize();
      try {
       String filepath="//help//1.html";////文件在工程下面的路径   File file=new File("");
       //getAbsolutePath() 返回抽象路径名的绝对路径名字符串。
       String path=file.getAbsolutePath()+filepath;
       //jTextPane.setPage("file:///"+path);
       jTextPane.setPage(new URL("http://www.wozaishuo.com.cn"));
       }
       catch (Exception e) {
       e.printStackTrace();
       }
    }
    private void initialize() {
      this.setSize(764, 542);
      this.setContentPane(getJContentPane());
      this.setTitle("JFrame");
      this.pack();
      this.setSize(500, 450);
      this.setEnabled(true);
      this.setVisible(true);
    }private JPanel getJContentPane() {
      if (jContentPane == null) {
       jContentPane = new JPanel();
       jContentPane.setLayout(null);
       jContentPane.add(getJPanel(), null);
       
      }
      return jContentPane;
    }private JPanel getJPanel() {
      if (jPanel == null) {
       jPanel = new JPanel();
       jPanel.setLayout(null);
       jPanel.setBounds(new Rectangle(18, 8, 715, 493));
       jPanel.add(getJScrollPane(), null);
      }
      return jPanel;
    }
    private JScrollPane getJScrollPane() {
      if (jScrollPane == null) {
       jScrollPane = new JScrollPane();
       jScrollPane.setBounds(new Rectangle(-4, 0, 662, 455));
       jScrollPane.setViewportView(getJTextPane());
      }
      return jScrollPane;
    }private JTextPane getJTextPane() {
      if (jTextPane == null) {
       jTextPane = new JTextPane();
      }
      return jTextPane;
    }    public static void main(String[] args){
            Lk lk = new Lk();
        }}
      

  4.   

    如果是弹出一个对话框的话用JS里的alert("要输出信息")就可以了。
      

  5.   

    用6.0的新特性:Desktop,如果你用开发SWT程序,可以用Program类,内部院里都是一样的
    具体的介绍,看博客:http://blog.csdn.net/neusoftware_20063500/archive/2009/02/20/3913914.aspx