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);
推荐阅读
- 开发游戏赚钱要交税嘛,开发游戏赚钱要交税嘛
- asp.net过滤html标签,net 过滤器
- 阿里云服务器如何端口,阿里云服务器如何端口访问
- 企业微信直播上课好处,用企业微信直播上课
- php采集数据函数 php 采集
- 修改Oracle表里的数据,oracle数据库修改
- 如何打开excel选项,如何打开excel选项对话框
- jquery页面刷新1次,jquery 页面刷新
- rrd数据库php re数据库