這個(gè)要配合數(shù)據(jù)庫(kù)的分頁(yè)的,前臺(tái)異步發(fā)送請(qǐng)求,后臺(tái)根據(jù)你的參數(shù),如當(dāng)前頁(yè),是下一頁(yè)還是什么的,然后傳數(shù)據(jù)到前臺(tái)。
祁縣網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián)建站,祁縣網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為祁縣1000多家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站建設(shè)要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的祁縣做網(wǎng)站的公司定做!
重載渲染控件的paintComponent(Graphics
g)方法.
設(shè)你當(dāng)前圖像實(shí)例為img,已初始化,需要旋轉(zhuǎn)的角度為ang
public
void
paintComponent(Graphics
g){
super.paintCompoent(g);
Graphics2D
g2d
=
(Graphics2D)g;
g2d.rotate(-angle);
g2d.drawImage(img,0,0,this.getWidth(),this.getHeight(),null);
}
Graphics,Graphics2D
類中有對(duì)當(dāng)前描繪環(huán)境進(jìn)行仿射變換的方法,包括translate,scale,rotate,也可以直接設(shè)置仿射變換矩陣,利用這點(diǎn)就可以根據(jù)所需要的實(shí)現(xiàn)方式來(lái)進(jìn)行描繪.
//改編的,CopyOfImageViewer.java?打開(kāi)一個(gè)有圖片的文件夾就可瀏覽了。
//MP3播放相關(guān)庫(kù)到:;nbsp;下載
//將下載到的zip文件里的?jl1.0.1.jar?復(fù)制到?JDK目錄下的?jre/lib/ext/?目錄里即可.
//將?源代碼?main?方法里的?playMp3("d:\\bad.mp3");改成自己的地址,換種方法BMP是可以支持的,這里不行暫不討論。
import?java.awt.*;
import?java.awt.event.*;
import?java.io.*;
import?javax.swing.*;
import?javazoom.jl.player.Player;
public?class?CopyOfImageViewer?implements?ActionListener,Runnable?{
JPanel?bts;
JLabel?pl;
JScrollPane?jsp;
JButton?cf,start,next,prev,stop;
JFrame?f;
JFileChooser?fc;
File?[]?sf;
int?index;
Thread?auto;
boolean?autoFlag;
int?delay=5*1000;
//這里就是GUI布局
CopyOfImageViewer(){
pl=new?JLabel();
pl.setHorizontalAlignment(JLabel.CENTER);
jsp=new?JScrollPane(pl);
start=new?JButton("start");
next=new?JButton("");
prev=new?JButton("");
stop=new?JButton("stop");
bts=new?JPanel(new?FlowLayout(FlowLayout.CENTER));
bts.add(start);
bts.add(prev);
bts.add(next);
bts.add(stop);
cf=new?JButton("Select?a?picture?folder");
fc=new?JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
f=new?JFrame();
f.setDefaultCloseOperation(3);
f.getContentPane().add(cf,"North");
f.getContentPane().add(jsp,"Center");
f.getContentPane().add(bts,"South");
f.setSize(400,300);
f.setLocationRelativeTo(null);
f.setVisible(true);
//給按鈕加入事件偵聽(tīng)器
start.addActionListener(this);
next.addActionListener(this);
prev.addActionListener(this);
stop.addActionListener(this);
cf.addActionListener(this);
auto=new?Thread(this);
auto.start();
}
public?static?void?main(String[]?args)?{
try{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
}catch(Exception?e){
try{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}catch(Exception?e2){}
}
new?CopyOfImageViewer();
playMp3("d:\\bad.mp3");
}
//簡(jiǎn)單MP3播放
private?static?void?playMp3(String?file){
try{
Player?p?=?new?Player(new?FileInputStream(file));
p.play();
}catch(Exception?e){}
}
//處理各按鍵事件
public?void?actionPerformed(ActionEvent?e)?{
Object?src=e.getSource();
if(src==cf){
int?o=fc.showOpenDialog(f);
if(o==JFileChooser.APPROVE_OPTION){
sf=fc.getSelectedFile().listFiles(new?FilenameFilter(){
//合法的文件后綴
String[]?suf={".PNG",".GIF",".JPG",};
public?boolean?accept(File?dir,?String?name)?{
name=name.toUpperCase();
for(int?i=0;?isuf.length;?i++)
if(name.endsWith(suf[i]))return?true;
return?false;
}
});
if(sf.length0){
index=0;
showPic();
}
}
}
if(sf==null||sf.length==0)return;
if(src==start)startB();
else?if(src==stop)stopB();
else?if(src==next)next();
else?if(src==prev)prev();
}
void?prev(){
index=--index0?sf.length-1:index;
showPic();
}
void?next(){
index=++indexsf.length-1?0:index;
showPic();
}
public?void?run(){
while(true){
if(sf!=null??sf.length0??autoFlag){
try?{Thread.sleep(delay);}?catch?(Exception?e)?{}
next();
}
try?{Thread.sleep(100);}?catch?(Exception?e)?{}
}
}
private?void?stopB()?{
autoFlag=false;
}
private?void?startB()?{
autoFlag=true;
}
//顯示圖片
private?void?showPic()?{
if(sf==null?||?sf.length==0)return;
pl.setIcon(new?ImageIcon(sf[index].getAbsolutePath()));
System.out.println(sf[index].getAbsolutePath());
}
}