java浏览器源代码 java开源浏览器

求一个java图片浏览器的源代码,拜托大家了?。。?/h2>给你代码java浏览器源代码,看一下注释java浏览器源代码 , 为是防止左右移动时鼠标是水平java浏览器源代码的移动java浏览器源代码,所以加了一个范轩 ,
在二十个象素内,认为是水平的 。
你看一下吧
还好你这个是鼠标按住移动,如果只是鼠移动就麻烦了
----------------------------------------
import java.awt.Graphics;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.filechooser.FileNameExtensionFilter;
public class App extends JFrame implements MouseListener, ActionListener {
int x = 0;
int y = 0;
File[] selectedFiles = null;
int fileIndex = 0;
int width = 200;
int height = 200;
public App() {
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setSize(400, 300);
setResizable(false);
getContentPane().setLayout(null);
JPanel panel = new ImagePanel();
panel.setBounds(12, 40, 370, 218);
getContentPane().add(panel);
addMouseListener(this);
JButton btnBrowse = new JButton("Browse");
btnBrowse.addActionListener(this);
btnBrowse.setBounds(12, 9, 91, 21);
getContentPane().add(btnBrowse);
setVisible(true);
}
public static void main(String[] args) {
new App();
}
public void actionPerformed(ActionEvent e) {
JFileChooser chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(true);
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"JPGGIF Images", "jpg", "gif");
// 设置文件类型
chooser.setFileFilter(filter);
// 打开选择器面板
int returnVal = chooser.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
selectedFiles = chooser.getSelectedFiles();
repaint();
}
}
public void mouseClicked(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
Point point = MouseInfo.getPointerInfo().getLocation();
x = point.x;
y = point.y;
}
public void mouseReleased(MouseEvent e) {
Point point = MouseInfo.getPointerInfo().getLocation();
int thisX = point.x;
int thisY = point.y;
System.out.println("thisX="thisX"""thisY="thisY);
if ((y - thisY20y - thisY0)
|| (y - thisY0y - thisY-20)) {
// Y 在20范围内移动认为是水平移动
if (xthisX) {
// right
if (selectedFiles != null
fileIndexselectedFiles.length - 1) {
fileIndex;
}
} else {
// left
if (selectedFiles != nullfileIndex0) {
fileIndex--;
}
}
} else {
if (xthisX) {
// 右下
width= 20;
height= 20;
} else {
// 左上
width -= 20;
height -= 20;
}
}
repaint();
}
class ImagePanel extends JPanel {
public void paint(Graphics g) {
super.paint(g);
if (selectedFiles != null) {
ImageIcon icon = new ImageIcon(selectedFiles[fileIndex]
.getPath());
g.drawImage(icon.getImage(), 0, 0, width, height, this);
}
}
}
【java浏览器源代码 java开源浏览器】}
java源代码怎么打开源代码默认是打不开的,可以使用反编译工具,进行逆向解析才能看到源代码 。
eclipse这个开发工具,默认有反编译的插件,在查看的类,按住ctrl点击鼠标左键即可查看源代码 。
java中如何根据一个网址获得该网页的源代码,急求import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class HttpTest {
String urlString;
public static void main(String[] args) throws Exception {
HttpTest client = new HttpTest(网址);
client.run();
}
public HttpTest(String urlString) {
this.urlString = urlString;
}
public void run() throws Exception {
//生成一个URL对象
URL url = new URL(urlString);
//打开URL
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
//得到输入流,即获得了网页的内容
BufferedReader reader = new BufferedReader(new InputStreamReader(urlConnection
.getInputStream()));
String line;
// 读取输入流的数据,并显示
while ((line = reader.readLine()) != null){
System.out.println(line);
}
}
}
java浏览器源代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java开源浏览器、java浏览器源代码的信息别忘了在本站进行查找喔 。

    推荐阅读