java图片查看器_java实现图片查看器

此篇博客介绍了使用Java AWT和Swing库实现的一个简单的图片显示应用程序,通过JFrame、JButton、JLabel等组件,用户可以打开文件、预览图片并进行页面翻转。展示了ActionListener的使用以及文件I/O的基本操作。
摘要由CSDN通过智能技术生成

package source;

import java.awt.Image;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.BufferedInputStream;

import java.io.BufferedOutputStream;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.util.ArrayList;

import javax.swing.GroupLayout;

import javax.swing.JButton;

import javax.swing.JComponent;

import javax.swing.JFileChooser;

import javax.swing.JOptionPane;

import javax.swing.ImageIcon;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JTextField;

import javax.swing.LayoutStyle;

import javax.swing.border.LineBorder;

import javax.swing.SwingUtilities;

public class PictureShow extends JFrame implements ActionListener

{

private static final long serialVersionUID =

1L;

private

JButton jButton1;

private

JButton jButton4;

private

JLabel jLabel2;

private

JButton jButton3;

private

JButton jButton2;

private

JTextField jTextField1;

private

JLabel jLabel1;

private int

count=0;

private int

num=0;

private

ArrayList list=new

ArrayList();

public static void main(String[] args) {

SwingUtilities.invokeLater(new

Runnable() {

public void

run() {

PictureShow

inst = new PictureShow();

inst.setLocationRelativeTo(null);

inst.setVisible(true);

}

});

}

public PictureShow() {

super();

initGUI();

}

private void initGUI() {

try {

GroupLayout

thisLayout = new GroupLayout((JComponent)getContentPane());

getContentPane().setLayout(thisLayout);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setTitle("图片显示V1.0---王荣喜");

{

jLabel1

= new JLabel();

jLabel1.setText("\u6253\u5f00");

}

{

jTextField1

= new JTextField();

}

{

jButton1

= new JButton();

jButton1.setText("\u6d4f\u89c8...");

jButton1.addActionListener(this);

}

{

jButton4

= new JButton();

jButton4.setText("\u653e\u5165\u96be\u9898\u518c");

jButton4.addActionListener(this);

}

{

jLabel2

= new JLabel();

jLabel2.setBorder(new

LineBorder(new java.awt.Color(0,0,0), 1, false));

jLabel2.setSize(600,

450);

}

{

jButton2

= new JButton();

jButton2.setText("\u4e0a\u4e00\u5f20");

jButton2.addActionListener(this);

}

{

jButton3

= new JButton();

jButton3.setText("\u4e0b\u4e00\u5f20");

jButton3.addActionListener(this);

}

thisLayout.setVerticalGroup(thisLayout.createSequentialGroup()

.addContainerGap()

.addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)

.addComponent(jLabel1, GroupLayout.Alignment.BASELINE,

GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)

.addComponent(jTextField1, GroupLayout.Alignment.BASELINE,

GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,

GroupLayout.PREFERRED_SIZE)

.addComponent(jButton1, GroupLayout.Alignment.BASELINE,

GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,

GroupLayout.PREFERRED_SIZE)

.addComponent(jButton4, GroupLayout.Alignment.BASELINE,

GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE))

.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(thisLayout.createParallelGroup()

.addComponent(jLabel2, GroupLayout.Alignment.LEADING, 0, 496,

Short.MAX_VALUE)

.addGroup(thisLayout.createSequentialGroup()

.addGap(210)

.addGroup(thisLayout.createParallelGroup()

.addGroup(GroupLayout.Alignment.LEADING,

thisLayout.createSequentialGroup()

.addComponent(jButton2, GroupLayout.PREFERRED_SIZE,

GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值