手机代码查看器java 如何用手机查看代码( 四 )


else if(url.length ()==0){
JOptionPane.showMessageDialog (WebBrowser.this,"请输入链接地址","网页浏览器",JOptionPane.ERROR_MESSAGE);
}
}
//输入地址后点击回车
else if (e.getSource() == jurl){
url=jurl.getText ();
if(url.length ()0url.startsWith ("http://")) {
try {
jEditorPane1.setPage (url);
history.add(url);
historyIndex=history.size()-1;
jEditorPane1.setEditable(false); //add by copy editor :)
jEditorPane1.revalidate ();
jurl.setMaximumSize (jurl.getPreferredSize ());
}
catch(Exception ex) {
JOptionPane.showMessageDialog (WebBrowser.this,"无法打开该搜索页","网页浏览器",JOptionPane.ERROR_MESSAGE);
}
}
else if(url.length ()0!url.startsWith ("http://")) {
url="http://"+url;
try {
jEditorPane1.setPage (url );
history.add(url);
historyIndex=history.size()-1;
jEditorPane1.setEditable(false); //add by copy editor :)
jEditorPane1.revalidate ();
}
catch(Exception ex) {
JOptionPane.showMessageDialog (WebBrowser.this,"无法打开该搜索页","网页浏览器",JOptionPane.ERROR_MESSAGE);
}
}
else if(url.length ()==0){
JOptionPane.showMessageDialog (WebBrowser.this,"请输入链接地址","网页浏览器",JOptionPane.ERROR_MESSAGE);
}
}
//另存为...
else if (e.getSource() == picSave||e.getSource() == saveAsItem){
url = jurl.getText ().toString ().trim();
if(url.length ()0!url.startsWith ("http://")) {
url="http://"+url;
}
if(!url.equals ("")) {
//保存文件
saveFile(url);
}
else {
JOptionPane.showMessageDialog (WebBrowser.this,"请输入链接地址","网页浏览器",JOptionPane.ERROR_MESSAGE);
}
}
//退出
else if (e.getSource() == exitItem ||e.getSource() == picExit){
System.exit(0);
}
//后退
else if (e.getSource() == backItem ||e.getSource() == picBack){
historyIndex--;
if(historyIndex0)
historyIndex = 0;
url = jurl.getText();
try{
//获得history对象中本地址之前访问的地址
url = (String)history.get(historyIndex);
jEditorPane1.setPage(url);
jurl.setText(url.toString());
jEditorPane1.setEditable(false); //add by copy editor :)
jEditorPane1.revalidate ();
}
catch(Exception ex){
}
}
//前进
else if (e.getSource() == forwardItem ||e.getSource() == picForward){
historyIndex++;
if(historyIndex = history.size())
historyIndex = history.size()-1;
url = jurl.getText();
try{
//获得history对象中本地址之后访问的地址
url = (String)history.get(historyIndex);
jEditorPane1.setPage(url);
jurl.setText(url.toString());
jEditorPane1.setEditable(false); //add by copy editor :)
jEditorPane1.revalidate ();
}
catch(Exception ex){
}
}
//全屏
else if (e.getSource() == fullscreenItem){
boolean add_button2=true;
//获得屏幕大小
Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
Container content = window.getContentPane();
content.add (bar,"North");
content.add (scrollPane,"Center");
//button2为点击“全屏”后的还原按钮
if(add_button2==true) {
bar.add (button2);
}
//为button2添加事件
button2.addActionListener (new ActionListener () {
public void actionPerformed (ActionEvent evt) {
WebBrowser.this.setEnabled (true);
window.remove (bar);
window.remove (toolBar);
window.remove (scrollPane);
window.setVisible (false);
scrollPane.setPreferredSize (new Dimension (100,500));
getContentPane ().add (scrollPane,BorderLayout.SOUTH);
getContentPane ().add (bar,BorderLayout.CENTER);
getContentPane ().add (toolBar,BorderLayout.NORTH);

推荐阅读