问题描述
代码应该怎么写?请各位指导下。谢谢!
解决方案
解决方案二:
aGUI界面中加载HTML页面importjavax.swing.*;importjava.awt.*;importjava.io.*;/***@authorHardneedl*/finalclassHTMLDemoextendsJFrame{publicStringgetTitle(){return"htmldemo";}staticprivatefinalDimensionsize=newDimension(600,400);publicDimensiongetPreferredSize(){returnsize;}publicDimensiongetMaximumSize(){returnsize;}publicDimensiongetMinimumSize(){returnsize;}publicDimensiongetSize(){returnsize;}privateStringu;HTMLDemo(Stringurl)throwsHeadlessException{u=url;attachListeners();doLay();}privatevoidattachListeners(){setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}privatevoiddoLay(){Containercontainer=getContentPane();try{container.add(newJScrollPane(newJEditorPane(u)));}catch(IOExceptione){e.printStackTrace();}pack();setVisible(true);}publicstaticvoidmain(finalString[]args){SwingUtilities.invokeLater(newRunnable(){publicvoidrun(){newHTMLDemo(args[0]);}});}}