真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

164個(gè)完整java代碼的簡(jiǎn)單介紹

求用Java編寫的學(xué)生成績(jī)管理系統(tǒng)的完整代碼,要能運(yùn)行的

以下方法實(shí)現(xiàn)了用戶界面登陸

創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供普蘭店網(wǎng)站建設(shè)、普蘭店做網(wǎng)站、普蘭店網(wǎng)站設(shè)計(jì)、普蘭店網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)與制作、普蘭店企業(yè)網(wǎng)站模板建站服務(wù),10多年普蘭店做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。

import java.awt.*;

import java.awt.event.*;

public class DengLuJieMian extends Frame implements ActionListener

{

Label username=new Label("用戶名:");//使用文本創(chuàng)建一個(gè)用戶名標(biāo)簽

TextField t1=new TextField();//創(chuàng)建一個(gè)文本框?qū)ο?/p>

Label password=new Label("密碼:");//創(chuàng)建一個(gè)密碼標(biāo)簽

TextField t2=new TextField();

Button b1=new Button("登陸");//創(chuàng)建登陸按鈕

Button b2=new Button("取消");//創(chuàng)建取消按鈕

public DengLuJieMian()

{

this.setTitle("學(xué)生信息管理系統(tǒng)");//設(shè)置窗口標(biāo)題

this.setLayout(null);//設(shè)置窗口布局管理器

username.setBounds(50,40,60,20);//設(shè)置姓名標(biāo)簽的初始位置

this.add(username);// 將姓名標(biāo)簽組件添加到容器

t1.setBounds(120,40,80,20);// 設(shè)置文本框的初始位置

this.add(t1);// 將文本框組件添加到容器

password.setBounds(50,100,60,20);//密碼標(biāo)簽的初始位置

this.add(password);//將密碼標(biāo)簽組件添加到容器

t2.setBounds(120,100,80,20);//設(shè)置密碼標(biāo)簽的初始位置

this.add(t2);//將密碼標(biāo)簽組件添加到容器

b1.setBounds(50,150,60,20);//設(shè)置登陸按鈕的初始位置

this.add(b1);//將登陸按鈕組件添加到容器

b2.setBounds(120,150,60,20);//設(shè)置取消按鈕的初始位置

this.add(b2);// 將取消按鈕組件添加到容器

b1.addActionListener(this);//給登陸按鈕添加監(jiān)聽器

b2.addActionListener(this);// 給取消按鈕添加監(jiān)聽器

this.setVisible(true);//設(shè)置窗口的可見性

this.setSize(300,200);//設(shè)置窗口的大小

addWindowListener(new WindowAdapter()

{

public void windowClosing(WindowEvent e)

{

System.exit(0);

}

});//通過內(nèi)部類重寫關(guān)閉窗體的方法

}

public void actionPerformed(ActionEvent e)

{

if(e.getSource()==b1)//處理登陸事件

{

String name=t1.getText();

String pass=t2.getText();

if(name!=nullpass.equals("000123"))//判斷語句

{

new StudentJieMian();

}

}

}

public static void main(String args[])//主函數(shù)

{

new DengLuJieMian();

}

}

以下方法實(shí)現(xiàn)了學(xué)生界面設(shè)計(jì)

import java.awt.*;

import java.awt.event.*;

class StudentJieMian extends Frame implements ActionListener

{

MenuBar m=new MenuBar();//創(chuàng)建菜單欄

Menu m1=new Menu("信息");//創(chuàng)建菜單“信息”

MenuItem m11=new MenuItem("插入");//創(chuàng)建“插入”的菜單項(xiàng)

MenuItem m12=new MenuItem("查詢");

Menu m2=new Menu("成績(jī)");//創(chuàng)建菜單“成績(jī)”

MenuItem m21=new MenuItem("查詢");

public StudentJieMian()

{

this.setTitle("學(xué)生界面");//設(shè)置窗口標(biāo)題

this.setLayout(new CardLayout());//設(shè)置窗口布局管理器

this.setMenuBar(m);//將菜單欄組件添加到容器

m.add(m1);//將信息菜單放入菜單欄

m.add(m2);

m1.add(m11);//將“插入”菜單項(xiàng)添加到“信息”菜單

m1.add(m12); //將“查詢”菜單項(xiàng)添加到“信息”菜單

m2.add(m21); //將“查詢”菜單項(xiàng)添加到“成績(jī)”菜單

m11.addActionListener(this); //給“插入”菜單項(xiàng)添加監(jiān)聽器

m12.addActionListener(this); //給“查詢”菜單項(xiàng)添加監(jiān)聽器

m21.addActionListener(this); //給“查詢”菜單項(xiàng)添加監(jiān)聽器

this.setVisible(true); //設(shè)置窗口的可見性

this.setSize(300,200); //設(shè)置窗口的大小

addWindowListener(new WindowAdapter()

{

public void windowClosing(WindowEvent e)

{

System.exit(0);//關(guān)閉窗口

}

});

}

public void actionPerformed(ActionEvent e)

{

if(e.getSource()==m11) //處理“添加信息”事件

{

new AddStudent();

}

if(e.getSource()==m12) //處理“查詢信息”事件

{

new SelectStudent();

}

if(e.getSource()==m21) //處理“查詢成績(jī)”事件

{

new ChengJiStudent();

}

}

public static void main(String args[])

{ new StudentJieMian(); //創(chuàng)建一個(gè)對(duì)象 }

一個(gè)完整的可運(yùn)行的java程序包括哪些基本原代碼

Java程序包括2種

1) Java 應(yīng)用程序,必須具有一個(gè)main方法入口

public class Test{

public static void main(String args[]){

}

}

2) Java 小應(yīng)用程序

Applet類中的四種基本方法用來控制其運(yùn)行狀態(tài):init()、start()、stop()、destroy() ,至少具有init start方法。。

求一個(gè)50行左右的JAVA代碼,最好每行帶注釋,謝謝啦

/*這個(gè)相當(dāng)詳細(xì)了.

程序也不算太難.而且給老師看的時(shí)候效果比較好.因?yàn)橛袌D形化界面,又實(shí)現(xiàn)一個(gè)比較實(shí)用的功能.老師會(huì)比較高興的.

建立一個(gè)文件名為Change.java就可以編譯了*/

/*

* 這個(gè)程序?qū)崿F(xiàn)輸入身高算出標(biāo)準(zhǔn)體重,輸入體重,算出身高的功能

*/

import java.awt.*; //導(dǎo)入相關(guān)類包,這才樣使用相應(yīng)awt圖形界面的類

import java.awt.event.*;//同上

public class Change extends Frame { //定義一個(gè)類Change, 父類是Frame(圖形界面的)

Button b = new Button("互查"); //創(chuàng)建一個(gè)按鈕的對(duì)象b,顯示為"互查"

Label l1 = new Label("身高(cm)");//創(chuàng)建一個(gè)lable.顯示身高

Label l2 = new Label("體重(kg)");//創(chuàng)建一個(gè)lable 顯示體重

double heigth, weigth; //定義變量

double x, y; //定義變量

TextField tf1 = new TextField(null, 10);//添加Text框

TextField tf2 = new TextField(null, 10);//添加Text框

public Change() {//類的構(gòu)造函數(shù),完成初始化

super("互查表");//創(chuàng)建窗口,標(biāo)題為互查表

setLayout(new FlowLayout(FlowLayout.LEFT));//設(shè)置布局

add(l1);//把lable 身高放到window里

add(tf1);//把Text 框 放到窗口上

add(l2); //把lable 體重放到window里

add(tf2);//Test放到窗口里

add(b);//把button放到窗口上

pack();//自動(dòng)放到窗口里排列上邊的組件

setVisible(true);//可以讓用戶看到窗口

addWindowListener(new WindowAdapter() {//如果按 X, 關(guān)閉窗口

public void windowClosing(WindowEvent e) {

System.exit(0);

}

});

b.addActionListener(new ButtonListener());//添加button監(jiān)聽函數(shù)

}

class ButtonListener implements ActionListener {//實(shí)現(xiàn)click button時(shí)功能操作

public void actionPerformed(ActionEvent e) {//當(dāng)click調(diào)用

if (tf1.getText()!=null) {//檢查tf1 test 是否為空

try {//取異常

x = Double.parseDouble(tf1.getText());//字符轉(zhuǎn)為double型

weigth = (x - 100) * 0.9;//算重量

tf2.setText("" + weigth);//顯示重量

} catch (NumberFormatException ex) {

tf1.setText("");//如果輸入不是數(shù)字,設(shè)為空

}

}

if (tf1.getText().equals("")==true){//tf1是否為空

y = Double.parseDouble(tf2.getText());//把tf2里的文本轉(zhuǎn)為double 型 的

heigth = y / 0.9 + 100; //算身高根據(jù)重量

tf1.setText("" + heigth);}//顯示身高

}

}

public static void main(String[] args) {//主函數(shù),程序入口

new Change(); //建立類Change的對(duì)象,并調(diào)用他的構(gòu)造函數(shù)Change().顯示窗口

}

}

幾個(gè)Java小游戲代碼

package reduce;

import java.applet.Applet;

import java.applet.AudioClip;

import java.awt.Dimension;

import java.awt.Font;

import java.awt.Toolkit;

import javax.sound.sampled.AudioFileFormat;

import javax.sound.sampled.AudioSystem;

import javax.swing.JFrame;

import javax.swing.JPanel;

import java.awt.Rectangle;

import javax.swing.BorderFactory;

import javax.swing.JButton;

import javax.swing.JOptionPane;

import javax.swing.JSlider;

import javax.swing.JLabel;

import javax.swing.SwingUtilities;

import javax.swing.UIManager;

import javax.swing.event.ChangeEvent;

import javax.swing.event.ChangeListener;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.KeyAdapter;

import java.awt.event.KeyEvent;

import java.io.File;

import java.util.Vector;

public class Frame extends JFrame implements Runnable {

JPanel contentPane;

JPanel jPanel1 = new JPanel();

JButton jButton1 = new JButton();

JSlider jSlider1 = new JSlider();

JLabel jLabel1 = new JLabel();

JButton jButton2 = new JButton();

JLabel jLabel2 = new JLabel();

int count = 1, rapidity = 80; // count 當(dāng)前進(jìn)行的個(gè)數(shù), rapidity 游標(biāo)的位置

int zhengque = 0, cuowu = 0;

int rush[] = { 10 ,20 ,30 }; //游戲每關(guān)的個(gè)數(shù) 可以自由添加.列 { 10 ,20 ,30 ,40,50}

int rush_count = 0; //記錄關(guān)數(shù)

char list[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',

'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',

'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; //隨機(jī)出現(xiàn)的數(shù)字 可以自由添加

Vector number = new Vector();

String paiduan = "true";

AudioClip Musci_anjian, Music_shibai, Music_chenggong;

public Frame() {

try {

setDefaultCloseOperation(EXIT_ON_CLOSE);

//-----------------聲音文件---------------------

Musci_anjian = Applet.newAudioClip(new File("sounds//anjian.wav")

.toURL());

Music_shibai = Applet.newAudioClip(new File("sounds//shibai.wav")

.toURL());

Music_chenggong = Applet.newAudioClip(new File(

"sounds//chenggong.wav").toURL());

//---------------------------------------

jbInit();

} catch (Exception exception) {

exception.printStackTrace();

}

}

/**

* Component initialization.

*

* @throws java.lang.Exception

*/

private void jbInit() throws Exception {

contentPane = (JPanel) getContentPane();

contentPane.setLayout(null);

setSize(new Dimension(588, 530));

setTitle("Frame Title");

jPanel1.setBorder(BorderFactory.createEtchedBorder());

jPanel1.setBounds(new Rectangle(4, 4, 573, 419));

jPanel1.setLayout(null);

jButton1.setBounds(new Rectangle(277, 442, 89, 31));

jButton1.setText("開始");

jButton1.addActionListener(new Frame1_jButton1_actionAdapter(this));

jSlider1.setBounds(new Rectangle(83, 448, 164, 21));

jSlider1.setMaximum(100);

jSlider1.setMinimum(1);

jSlider1.setValue(50);

jLabel1.setText("速度");

jLabel1.setBounds(new Rectangle(35, 451, 39, 18));

jButton2.setBounds(new Rectangle(408, 442, 89, 31));

jButton2.setText("結(jié)束");

jButton2.addActionListener(new Frame1_jButton2_actionAdapter(this));

jLabel2.setText("第一關(guān):100個(gè)");

jLabel2.setBounds(new Rectangle(414, 473, 171, 21));

contentPane.add(jPanel1);

contentPane.add(jButton2);

contentPane.add(jButton1);

contentPane.add(jSlider1);

contentPane.add(jLabel1);

contentPane.add(jLabel2);

this.addKeyListener(new MyListener());

jButton1.addKeyListener(new MyListener());

jSlider1.addKeyListener(new MyListener());

jSlider1.addChangeListener(new ChangeListener() {

public void stateChanged(ChangeEvent e) {

rapidity = jSlider1.getValue();

}

});

}

public void run() {

number.clear();

zhengque = 0;

cuowu = 0;

paiduan = "true";

while (count = rush[rush_count]) {

try {

Thread t = new Thread(new Tthread());

t.start();

count += 1;

Thread.sleep(1000 + (int) (Math.random() * 2000)); // 生產(chǎn)下組停頓時(shí)間

// 最快1快.最慢2秒

} catch (InterruptedException e) {

e.printStackTrace();

}

}

while (true) { // 等待最后一個(gè)字符消失

if (number.size() == 0) {

break;

}

}

if (zhengque == 0) { // 為了以后相除..如果全部正確或者錯(cuò)誤就會(huì)出現(xiàn)錯(cuò)誤. 所以..

zhengque = 1;

}

if (cuowu == 0) {

cuowu = 1;

}

if (paiduan.equals("true")) { // 判斷是否是自然結(jié)束

if (zhengque / cuowu = 2) {

JOptionPane.showMessageDialog(null, "恭喜你過關(guān)了");

rush_count += 1; // 自動(dòng)加1關(guān)

if (rush_count rush.length) {

if (rapidity 10) { // 當(dāng)速度大于10的時(shí)候在-5提加速度.怕速度太快

rapidity -= 5; // 速度自動(dòng)減10毫秒

jSlider1.setValue(rapidity); // 選擇位置

}

Thread t = new Thread(this);

t.start();

} else {

JOptionPane.showMessageDialog(null, "牛B...你通關(guān)了..");

rush_count = 0;

count = 0;

}

} else {

JOptionPane.showMessageDialog(null, "請(qǐng)?jiān)俳釉賱?lì)");

rush_count = 0;

count = 0;

}

} else {

rush_count = 0;

count = 0;

}

}

public void jButton1_actionPerformed(ActionEvent e) {

Thread t = new Thread(this);

t.start();

}

public void jButton2_actionPerformed(ActionEvent e) {

count = rush[rush_count] + 1;

paiduan = "flase";

}

class Tthread implements Runnable {

public void run() {

boolean fo = true;

int Y = 0, X = 0;

JLabel show = new JLabel();

show.setFont(new java.awt.Font("宋體", Font.PLAIN, 33));

jPanel1.add(show);

X = 10 + (int) (Math.random() * 400);

String parameter = list[(int) (Math.random() * list.length)] + "";

Bean bean = new Bean();

bean.setParameter(parameter);

bean.setShow(show);

number.add(bean);

show.setText(parameter);

while (fo) {

// ---------------------數(shù)字下移--------------------

show.setBounds(new Rectangle(X, Y += 2, 33, 33));

try {

Thread.sleep(rapidity);

} catch (InterruptedException e) {

e.printStackTrace();

}

if (Y = 419) {

fo = false;

for (int i = number.size() - 1; i = 0; i--) {

Bean bn = ((Bean) number.get(i));

if (parameter.equalsIgnoreCase(bn.getParameter())) {

cuowu += 1;

jLabel2.setText("正確:" + zhengque + "個(gè),錯(cuò)誤:" + cuowu

+ "個(gè)");

number.removeElementAt(i);

Music_shibai.play();

break;

}

}

}

}

}

}

class MyListener extends KeyAdapter {

public void keyPressed(KeyEvent e) {

String uu = e.getKeyChar() + "";

for (int i = 0; i number.size(); i++) {

Bean bean = ((Bean) number.get(i));

if (uu.equalsIgnoreCase(bean.getParameter())) {

zhengque += 1;

number.removeElementAt(i);

bean.getShow().setVisible(false);

jLabel2.setText("正確:" + zhengque + "個(gè),錯(cuò)誤:" + cuowu + "個(gè)");

Music_chenggong.play();

break;

}

}

Musci_anjian.play();

}

}

public static void main(String[] args) {

try {

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

} catch (Exception exception) {

exception.printStackTrace();

}

Frame frame = new Frame();

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

Dimension frameSize = frame.getSize();

if (frameSize.height screenSize.height) {

frameSize.height = screenSize.height;

}

if (frameSize.width screenSize.width) {

frameSize.width = screenSize.width;

}

frame.setLocation((screenSize.width - frameSize.width) / 2,

(screenSize.height - frameSize.height) / 2);

frame.setVisible(true);

}

}

class Frame1_jButton2_actionAdapter implements ActionListener {

private Frame adaptee;

Frame1_jButton2_actionAdapter(Frame adaptee) {

this.adaptee = adaptee;

}

public void actionPerformed(ActionEvent e) {

adaptee.jButton2_actionPerformed(e);

}

}

class Frame1_jButton1_actionAdapter implements ActionListener {

private Frame adaptee;

Frame1_jButton1_actionAdapter(Frame adaptee) {

this.adaptee = adaptee;

}

public void actionPerformed(ActionEvent e) {

adaptee.jButton1_actionPerformed(e);

}

}

class Bean {

String parameter = null;

JLabel show = null;

public JLabel getShow() {

return show;

}

public void setShow(JLabel show) {

this.show = show;

}

public String getParameter() {

return parameter;

}

public void setParameter(String parameter) {

this.parameter = parameter;

}

}

我只有一個(gè)打字母小游戲

初學(xué)JAVA的問題

《java2 核心技術(shù)》卷 I,II, 卷I是基礎(chǔ)部分(包括java 基本語法,面向?qū)ο?,IO流與文件,圖形界面,applet, 異常處理,范型設(shè)計(jì)),卷II是高級(jí)部分(多線程,集合,網(wǎng)絡(luò),JDBC,分布式對(duì)象,高級(jí)圖形特性,JavaBean,安全,XML。。。)高手們說看完這兩本書,就可以看《Thinking in java》了,之后就可以去學(xué)J2EE了

PS: 其實(shí)學(xué)完基本語法,I/O,異常,集合,JDBC(當(dāng)然也要看看數(shù)據(jù)庫(kù)Oracle 或MySql, Sql server之類的)后就可以開始學(xué)J2EE了:JSP ,servlet, JavaScript(跟JAVA沒關(guān)系的一種腳本語言,用于B/S架構(gòu)網(wǎng)絡(luò)前臺(tái)處理數(shù)據(jù)),structs 等。。。對(duì)于JFC中的SWING圖形編程,如果覺得麻煩就跳過吧,畢竟桌面級(jí)開發(fā)不是JAVA的強(qiáng)項(xiàng),非常麻煩。。。(寫一個(gè)什么都沒有的對(duì)話框就占去了14M內(nèi)存,那還有啥好說的。。。)

另外,《JAVA編程思想》(《Thinking in JAVA》的中文翻譯版)建議在看完核心技術(shù)I以后再看,對(duì)初學(xué)者而言,《JAVA編程思想》并不見得是本好書,但是對(duì)于有一定JAVA基礎(chǔ)的人來說,這本書就是一本好書

還有就是多練習(xí),初學(xué)者建議使用記事本編輯程序,在控制臺(tái)下使用javac編譯程序, java運(yùn)行程序(這對(duì)你理解環(huán)境變量有幫助),之后你可以使用eclipse進(jìn)行JAVA編程,需要說一點(diǎn)的是eclipse非常方便,它的快捷鍵堪稱一絕,不過對(duì)初學(xué)者不好,會(huì)慣壞你的,學(xué)完面向?qū)ο筇匦砸院笤偈褂茫ǔS每旖萱Ialt + /)。

書上的代碼很多,最好都敲一遍,對(duì)著書理解,其實(shí)你會(huì)發(fā)現(xiàn),JAVA并不難(僅限與J2SE,因?yàn)楸救藙傞_始學(xué)J2EE,還不是很了解J2EE。。。)

誰能給我個(gè)完整的java 分頁代碼 謝謝了

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;

import com.lqh.dao.db.DBCon;

public class PageDAO {

public static final String Text = "text";

public static final String Image = "image";

public static final String BbsText = "bbstext";

public static final String BbsImage = "bbsimage";

private HttpServletRequest request;

private int currentpage = 1; // 當(dāng)前是第幾頁

private int pagecount = 0; // 一共有多少頁

private int rscount = 0; // 一共有多少行

private int pagesize = 10; // 每頁有多少行[默認(rèn)為20行]

public PageDAO(HttpServletRequest request) {

this.request = request;

}

public int getCurrentpage() {

return currentpage;

}

public void setCurrentpage(int currentpage) {

this.currentpage = currentpage;

}

public int getPagecount() {

return pagecount;

}

public void setPagecount(int pagecount) {

this.pagecount = pagecount;

}

public int getPagesize() {

return pagesize;

}

public void setPagesize(int pagesize) {

this.pagesize = pagesize;

}

public int getRscount() {

return rscount;

}

public void setRscount(int rscount) {

this.rscount = rscount;

}

/**

* 傳入SQL語句獲取總記錄數(shù)

*/

public int getRsCountForRs(String sql) {

Connection conn = null;

PreparedStatement ps = null;

ResultSet rs = null;

DBCon dbcon=new DBCon();

try {

conn = dbcon.getConn();

ps = conn.prepareStatement(sql);

rs = ps.executeQuery();

if (rs.next()) {

rs.last();

this.rscount = rs.getRow();

} else {

this.rscount = 0;

}

} catch (Exception ex) {

ex.printStackTrace();

this.rscount = 0;

} finally {

dbcon.tryClose(rs, ps, conn);

}

return this.rscount;

}

public int getRsCountForSQL(String sql) {

Connection conn = null;

PreparedStatement ps = null;

ResultSet rs = null;

DBCon dbcon=new DBCon();

try {

conn = dbcon.getConn();

ps = conn.prepareStatement(sql);

rs = ps.executeQuery();

if (rs.next()) {

this.rscount = rs.getInt("rscount");

} else {

this.rscount = 0;

}

} catch (Exception ex) {

ex.printStackTrace();

this.rscount = 0;

} finally {

dbcon.tryClose(rs, ps, conn);

}

return this.rscount;

}

/**

* 獲取總頁數(shù)

*

* @return int

*/

public int getPageCount() {

try {

this.pagecount = ((this.rscount - 1) / this.pagesize) + 1;

} catch (Exception ex) {

this.pagecount = 0;

}

return this.pagecount;

}

/**

* 獲取當(dāng)前頁碼的設(shè)置

*

* @return int

*/

public int getCurrentPage() {

try {

if (this.request.getParameter("currentpage") != null

Integer.parseInt(this.request

.getParameter("currentpage")) 1) {

this.currentpage = Integer.parseInt(this.request

.getParameter("currentpage"));

} else {

this.currentpage = 1;

}

} catch (Exception ex) {

this.currentpage = 1;

}

return this.currentpage;

}

/**

* 分頁工具條

*

* @param fileName

* String

* @return String

*/

public String pagetool(String flag) {

StringBuffer str = new StringBuffer();

String url = this.getParamUrl();

int ProPage = this.currentpage - 1;

int Nextpage = this.currentpage + 1;

// 文字的分頁

if (flag.equals(PageDAO.Text)) {

str.append("form method='post' name='pageform' action=''");

str

.append("table style='color: windowframe' width='100%' border='0' cellspacing='0' cellpadding='0'");

str.append("tr");

str.append("td width='20%'/td");

str.append("td height='26'");

str.append("共有記錄" + this.rscount + "條?");

str.append("共" + this.pagecount + "頁?");

str.append("每頁" + this.pagesize + "記錄?");

str.append("現(xiàn)在" + this.currentpage + "/" + this.pagecount + "頁");

str.append("/tdtd");

if (this.currentpage 1) {

str.append("a href='" + url + "currentpage=1'首頁/a");

str.append("?");

str.append("a href='" + url + "currentpage=" + ProPage

+ "'上一頁/a");

str.append("?");

} else {

str.append("首頁");

str.append("?");

str.append("上一頁");

str.append("?");

}

if (this.currentpage this.pagecount) {

str.append("a href='" + url + "currentpage=" + Nextpage

+ "'下一頁/a");

str.append("?");

} else {

str.append("下一頁");

str.append("?");

}

if (this.pagecount 1 this.currentpage != this.pagecount) {

str.append("a href='" + url + "currentpage=" + pagecount

+ "'尾頁/a");

str.append("?");

} else {

str.append("尾頁");

str.append("?");

}

str.append("轉(zhuǎn)到");

str

.append("select name='currentpage' onchange='javascript:ChangePage(this.value);'");

for (int j = 1; j = pagecount; j++) {

str.append("option value='" + j + "'");

if (currentpage == j) {

str.append("selected");

}

str.append("");

str.append("" + j + "");

str.append("/option");

}

str.append("/select頁");

str.append("/tdtd width='3%'?/td/tr/table");

str.append("script language='javascript'");

str.append("function ChangePage(testpage){");

str.append("document.pageform.action='" + url

+ "currentpage='+testpage+'';");

str.append("document.pageform.submit();");

str.append("}");

str.append("/script");

str.append("/form");

} else if (flag.equals(PageDAO.Image)) {

/**

* 圖片的分頁

*/

} else if (flag.equals(PageDAO.BbsText)) {

/**

* 論壇形式的分頁[直接以數(shù)字方式體現(xiàn)]

*/

str

.append("table width='100%' border='0' cellspacing='0' cellpadding='0'");

str.append("tr");

str.append("td width='3%'?/td");

str.append("td height='26'");

str.append("記錄" + this.rscount + "條??");

str.append("共" + this.pagecount + "頁??");

str.append("每頁" + this.pagesize + "記錄??");

str.append("現(xiàn)在" + this.currentpage + "/" + this.pagecount + "頁");

str.append("/tdtd");

// 設(shè)定是否有首頁的鏈接

if (this.currentpage 1) {

str.append("a href='" + url + "currentpage=1'首頁/a");

str.append("??");

}

// 設(shè)定是否有上一頁的鏈接

if (this.currentpage 1) {

str.append("a href='" + url + "currentpage=" + ProPage

+ "'上一頁/a");

str.append("???");

}

// 如果總頁數(shù)只有10的話

if (this.pagecount = 10) {

for (int i = 1; i = this.pagecount; i++) {

if (this.currentpage == i) {

str.append("font color=red[" + i

+ "]/font??");

} else {

str.append("a href='" + url + "currentpage=" + i

+ "'" + i + "/a??");

}

}

} else {

// 說明總數(shù)有超過10頁

// 制定特環(huán)的開始頁和結(jié)束頁

int endPage = this.currentpage + 4;

if (endPage this.pagecount) {

endPage = this.pagecount;

}

int startPage = 0;

if (this.pagecount = 8 this.currentpage = 8) {

startPage = this.currentpage - 5;

} else {

// 表示從第一頁開始算

startPage = 1;

}

System.out.println(startPage);

System.out.println(endPage);

for (int i = startPage; i = endPage; i++) {

if (this.currentpage == i) {

str.append("font color=red[" + i

+ "]/font??");

} else {

str.append("a href='" + url + "currentpage=" + i

+ "'" + i + "/a??");

}

}

}

// 設(shè)定是否有下一頁的鏈接

if (this.currentpage this.pagecount) {

str.append("a href='" + url + "currentpage=" + Nextpage

+ "'下一頁/a");

str.append("??");

}

// 設(shè)定是否有尾頁的鏈接

if (this.pagecount 1 this.currentpage != this.pagecount) {

str.append("a href='" + url + "currentpage=" + pagecount

+ "'尾頁/a");

str.append("??");

}

str.append("/tdtd width='3%'?/td/tr/table");

} else if (flag.equals(PageDAO.BbsImage)) {

/**

* 論壇形式的分頁[以圖片的方式體現(xiàn)]

*/

// 設(shè)定分頁顯示的CSS

str.append("style");

str

.append("BODY {FONT-SIZE: 12px;FONT-FAMILY:宋體;WIDTH: 60%; PADDING-LEFT: 25px;}");

str

.append("DIV.meneame {PADDING-RIGHT: 3px; PADDING-LEFT: 3px; FONT-SIZE: 80%; PADDING-BOTTOM: 3px; MARGIN: 3px; COLOR: #ff6500; PADDING-TOP: 3px; TEXT-ALIGN: center}");

str

.append("DIV.meneame A {BORDER-RIGHT: #ff9600 1px solid; PADDING-RIGHT: 7px; BACKGROUND-POSITION: 50% bottom; BORDER-TOP: #ff9600 1px solid; PADDING-LEFT: 7px; BACKGROUND-IMAGE: url('"

+ this.request.getContextPath()

+ "/meneame.jpg'); PADDING-BOTTOM: 5px; BORDER-LEFT: #ff9600 1px solid; COLOR: #ff6500; MARGIN-RIGHT: 3px; PADDING-TOP: 5px; BORDER-BOTTOM: #ff9600 1px solid; TEXT-DECORATION: none}");

str

.append("DIV.meneame A:hover {BORDER-RIGHT: #ff9600 1px solid; BORDER-TOP: #ff9600 1px solid; BACKGROUND-IMAGE: none; BORDER-LEFT: #ff9600 1px solid; COLOR: #ff6500; BORDER-BOTTOM: #ff9600 1px solid; BACKGROUND-COLOR: #ffc794}");

str

.append("DIV.meneame SPAN.current {BORDER-RIGHT: #ff6500 1px solid; PADDING-RIGHT: 7px; BORDER-TOP: #ff6500 1px solid; PADDING-LEFT: 7px; FONT-WEIGHT: bold; PADDING-BOTTOM: 5px; BORDER-LEFT: #ff6500 1px solid; COLOR: #ff6500; MARGIN-RIGHT: 3px; PADDING-TOP: 5px; BORDER-BOTTOM: #ff6500 1px solid; BACKGROUND-COLOR: #ffbe94}");

str

.append("DIV.meneame SPAN.disabled {BORDER-RIGHT: #ffe3c6 1px solid; PADDING-RIGHT: 7px; BORDER-TOP: #ffe3c6 1px solid; PADDING-LEFT: 7px; PADDING-BOTTOM: 5px; BORDER-LEFT: #ffe3c6 1px solid; COLOR: #ffe3c6; MARGIN-RIGHT: 3px; PADDING-TOP: 5px; BORDER-BOTTOM: #ffe3c6 1px solid}");

str.append("/style");

str.append("div class=\"meneame\"");

// 判定是否有上一頁

if (this.currentpage 1) {

str.append("a href='" + url

+ "currentpage=1' hidefocus=\"true\"首頁/a");

str.append("???");

str.append("a href='" + url + "currentpage=" + ProPage

+ "' hidefocus=\"true\"上一頁/a");

str.append("???");

} else {

str.append("span class=\"disabled\"首頁/span");

str.append("??");

str.append("span class=\"disabled\"上一頁/span");

str.append("??");

}

// 顯示中間的圖片

if (this.pagecount = 10) {

for (int i = 1; i = this.pagecount; i++) {

if (this.currentpage == i) {

str.append("span class=\"current\"" + i + "/span");

} else {

str.append("a href='" + url + "currentpage=" + i

+ "' hidefocus=\"true\"" + i

+ "/a??");

}

}

} else {

// 說明總數(shù)有超過10頁

// 制定特環(huán)的開始頁和結(jié)束頁

int endPage = this.currentpage + 4;

if (endPage this.pagecount) {

endPage = this.pagecount;

}

int startPage = 0;

if (this.pagecount = 8 this.currentpage = 8) {

startPage = this.currentpage - 5;

} else {

// 表示從第一頁開始算

startPage = 1;

}

System.out.println(startPage);

System.out.println(endPage);

for (int i = startPage; i = endPage; i++) {

if (this.currentpage == i) {

str.append("span class=\"current\"" + i + "/span");

} else {

str.append("a href='" + url + "currentpage=" + i

+ "' hidefocus=\"true\"" + i

+ "/a??");

}

}

}

// 判斷下一頁和尾頁

if (this.currentpage this.pagecount) {

if (this.currentpage this.pagecount - 10) {

str.append("...");

str.append("a href='" + url + "currentpage="

+ (this.pagecount - 1) + "' hidefocus=\"true\""

+ (this.pagecount - 1) + "/a??");

str.append("a href='" + url + "currentpage="

+ this.pagecount + "' hidefocus=\"true\""

+ this.pagecount + "/a??");

}

str.append("a href='" + url + "currentpage=" + Nextpage

+ "' hidefocus=\"true\"下一頁/a");

str.append("??");

} else {

str.append("span class=\"disabled\"下一頁/span");

str.append("??");

}

if (this.pagecount 1 this.currentpage != this.pagecount) {

str.append("a href='" + url + "currentpage=" + pagecount

+ "' hidefocus=\"true\"尾頁/a");

str.append("??");

} else {

str.append("span class=\"disabled\"尾頁/span");

str.append("??");

}

str.append("/div");

}

return str.toString();

}

public String getParamUrl() {

String url = "";

url = this.request.getRequestURI().toString();

if (url.indexOf("?") == -1) {

url = url + "?";

}

String totalParams = "";

Enumeration params = this.request.getParameterNames();// 得到所有參數(shù)名

while (params.hasMoreElements()) {

String tempName = params.nextElement().toString();

String tempValue = this.request.getParameter(tempName);

if (tempValue != null !tempValue.equals("")

!tempName.equals("currentpage")) {

if (totalParams.equals("")) {

totalParams = totalParams + tempName + "=" + tempValue;

} else {

totalParams = totalParams + "" + tempName + "="

+ tempValue;

}

}

}

String totalUrl = url + totalParams;

return totalUrl;

}

}


分享標(biāo)題:164個(gè)完整java代碼的簡(jiǎn)單介紹
標(biāo)題URL:http://weahome.cn/article/hhgihd.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部