用百度搜索一下,就用“JAVA源代碼“做為搜索條件。一般能找到很多網(wǎng)站。
創(chuàng)新互聯(lián)服務(wù)緊隨時(shí)代發(fā)展步伐,進(jìn)行技術(shù)革新和技術(shù)進(jìn)步,經(jīng)過(guò)10年的發(fā)展和積累,已經(jīng)匯集了一批資深網(wǎng)站策劃師、設(shè)計(jì)師、專業(yè)的網(wǎng)站實(shí)施團(tuán)隊(duì)以及高素質(zhì)售后服務(wù)人員,并且完全形成了一套成熟的業(yè)務(wù)流程,能夠完全依照客戶要求對(duì)網(wǎng)站進(jìn)行成都做網(wǎng)站、成都網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)、建設(shè)、維護(hù)、更新和改版,實(shí)現(xiàn)客戶網(wǎng)站對(duì)外宣傳展示的首要目的,并為客戶企業(yè)品牌互聯(lián)網(wǎng)化提供全面的解決方案。
要學(xué)JAVA最好還是找本書(shū)看一看。JAVA能做的東西很多,你要決定你的主攻方向然后就去找相應(yīng)的資料。
你要學(xué)哪方面:
JAVA應(yīng)用程序開(kāi)發(fā),
JAVA網(wǎng)絡(luò)開(kāi)發(fā):JSP,APPLET。
JAVA手持設(shè)備軟件開(kāi)發(fā),像手機(jī)軟件等。
如果對(duì)程序還不是很懂,最好找本JAVA入門級(jí)的書(shū)看看,然后再?zèng)Q定。
下面是俄羅斯方塊游戲源代碼
還沒(méi)完,這代碼太長(zhǎng)了,我用我另一個(gè)號(hào)再粘上
import javax.swing.*;
import javax.swing.JOptionPane;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
import java.awt.*;
import java.awt.event.*;
/**
* 游戲主類,繼承自JFrame類,負(fù)責(zé)游戲的全局控制。
* 內(nèi)含
* 1, 一個(gè)GameCanvas畫(huà)布類的實(shí)例引用,
* 2, 一個(gè)保存當(dāng)前活動(dòng)塊(ErsBlock)實(shí)例的引用,
* 3, 一個(gè)保存當(dāng)前控制面板(ControlPanel)實(shí)例的引用;*/
public class ErsBlocksGame extends JFrame {
/**
* 每填滿一行計(jì)多少分*/
public final static int PER_LINE_SCORE = 100;
/**
* 積多少分以后能升級(jí)*/
public final static int PER_LEVEL_SCORE = PER_LINE_SCORE * 20;
/**
* 最大級(jí)數(shù)是10級(jí)*/
public final static int MAX_LEVEL = 10;
/**
* 默認(rèn)級(jí)數(shù)是5*/
public final static int DEFAULT_LEVEL = 5;
private GameCanvas canvas;
private ErsBlock block;
private boolean playing = false;
private ControlPanel ctrlPanel;
private JMenuBar bar = new JMenuBar();
private JMenu
mGame = new JMenu("游戲設(shè)置"),
mControl = new JMenu("游戲控制"),
mWindowStyle = new JMenu("窗口風(fēng)格");
private JMenuItem
miNewGame = new JMenuItem("新游戲"),
miSetBlockColor = new JMenuItem("設(shè)置顏色 ..."),
miSetBackColor = new JMenuItem("設(shè)置底色 ..."),
miTurnHarder = new JMenuItem("提升等級(jí)"),
miTurnEasier = new JMenuItem("調(diào)底等級(jí)"),
miExit = new JMenuItem("退出"),
miPlay = new JMenuItem("開(kāi)始游戲"),
miPause = new JMenuItem("暫停"),
miResume = new JMenuItem("繼續(xù)");
private JCheckBoxMenuItem
miAsWindows = new JCheckBoxMenuItem("風(fēng)格1"),
miAsMotif = new JCheckBoxMenuItem("風(fēng)格2"),
miAsMetal = new JCheckBoxMenuItem("風(fēng)格3", true);
/**
* 主游戲類的構(gòu)造函數(shù)
* @param title String,窗口標(biāo)題*/
public ErsBlocksGame(String title) {
super(title);
//this.setTitle("lskdf");
setSize(315, 392);
Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
//獲得屏幕的大小
setLocation((scrSize.width - getSize().width) / 2,
(scrSize.height - getSize().height) / 2);
createMenu();
Container container = getContentPane();
container.setLayout(new BorderLayout(6, 0));
canvas = new GameCanvas(20, 12);
ctrlPanel = new ControlPanel(this);
container.add(canvas, BorderLayout.CENTER);
container.add(ctrlPanel, BorderLayout.EAST);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
JOptionPane about=new JOptionPane();
stopGame();
System.exit(0);
}
});
addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent ce) {
canvas.fanning();
}
});
show();
canvas.fanning();
}
// 游戲“復(fù)位”
public void reset() {
ctrlPanel.reset();
canvas.reset();
}
/**
* 判斷游戲是否還在進(jìn)行
* @return boolean, true-還在運(yùn)行,false-已經(jīng)停止*/
public boolean isPlaying() {
return playing;
}
/**
* 得到當(dāng)前活動(dòng)的塊
* @return ErsBlock, 當(dāng)前活動(dòng)塊的引用*/
public ErsBlock getCurBlock() {
return block;
}
/**
* 得到當(dāng)前畫(huà)布
* @return GameCanvas, 當(dāng)前畫(huà)布的引用 */
public GameCanvas getCanvas() {
return canvas;
}
/**
* 開(kāi)始游戲*/
public void playGame() {
play();
ctrlPanel.setPlayButtonEnable(false);
miPlay.setEnabled(false);
ctrlPanel.requestFocus();
}
/**
* 游戲暫停*/
public void pauseGame() {
if (block != null) block.pauseMove();
ctrlPanel.setPauseButtonLabel(false);
miPause.setEnabled(false);
miResume.setEnabled(true);
}
/**
* 讓暫停中的游戲繼續(xù)*/
public void resumeGame() {
if (block != null) block.resumeMove();
ctrlPanel.setPauseButtonLabel(true);
miPause.setEnabled(true);
miResume.setEnabled(false);
ctrlPanel.requestFocus();
}
/**
* 用戶停止游戲 */
public void stopGame() {
playing = false;
if (block != null) block.stopMove();
miPlay.setEnabled(true);
miPause.setEnabled(true);
miResume.setEnabled(false);
ctrlPanel.setPlayButtonEnable(true);
ctrlPanel.setPauseButtonLabel(true);
}
/**
* 得到當(dāng)前游戲者設(shè)置的游戲難度
* @return int, 游戲難度1-MAX_LEVEL*/
public int getLevel() {
return ctrlPanel.getLevel();
}
/**
* 讓用戶設(shè)置游戲難度
* @param level int, 游戲難度1-MAX_LEVEL*/
public void setLevel(int level) {
if (level 11 level 0) ctrlPanel.setLevel(level);
}
/**
* 得到游戲積分
* @return int, 積分。*/
public int getScore() {
if (canvas != null) return canvas.getScore();
return 0;
}
/**
* 得到自上次升級(jí)以來(lái)的游戲積分,升級(jí)以后,此積分清零
* @return int, 積分。*/
public int getScoreForLevelUpdate() {
if (canvas != null) return canvas.getScoreForLevelUpdate();
return 0;
}
/**
* 當(dāng)分?jǐn)?shù)累計(jì)到一定的數(shù)量時(shí),升一次級(jí)
* @return boolean, ture-update successufl, false-update fail
*/
public boolean levelUpdate() {
int curLevel = getLevel();
if (curLevel MAX_LEVEL) {
setLevel(curLevel + 1);
canvas.resetScoreForLevelUpdate();
return true;
}
return false;
}
/**
* 游戲開(kāi)始*/
private void play() {
reset();
playing = true;
Thread thread = new Thread(new Game());
thread.start();
}
/**
* 報(bào)告游戲結(jié)束了*/
private void reportGameOver() {
JOptionPane.showMessageDialog(this, "游戲結(jié)束!");
}
/**
* 建立并設(shè)置窗口菜單 */
private void createMenu() {
bar.add(mGame);
bar.add(mControl);
bar.add(mWindowStyle);
mGame.add(miNewGame);
mGame.addSeparator();
mGame.add(miSetBlockColor);
mGame.add(miSetBackColor);
mGame.addSeparator();
mGame.add(miTurnHarder);
mGame.add(miTurnEasier);
mGame.addSeparator();
mGame.add(miExit);
mControl.add(miPlay);
mControl.add(miPause);
mControl.add(miResume);
mWindowStyle.add(miAsWindows);
mWindowStyle.add(miAsMotif);
mWindowStyle.add(miAsMetal);
setJMenuBar(bar);
miPause.setAccelerator(
KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_MASK));
miResume.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
miNewGame.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
stopGame();
reset();
setLevel(DEFAULT_LEVEL);
}
});
miSetBlockColor.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
Color newFrontColor =
JColorChooser.showDialog(ErsBlocksGame.this,
"設(shè)置積木顏色", canvas.getBlockColor());
if (newFrontColor != null)
canvas.setBlockColor(newFrontColor);
}
});
miSetBackColor.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
Color newBackColor =
JColorChooser.showDialog(ErsBlocksGame.this,
"設(shè)置底版顏色", canvas.getBackgroundColor());
if (newBackColor != null)
canvas.setBackgroundColor(newBackColor);
}
});
miTurnHarder.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
int curLevel = getLevel();
if (curLevel MAX_LEVEL) setLevel(curLevel + 1);
}
});
miTurnEasier.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
int curLevel = getLevel();
if (curLevel 1) setLevel(curLevel - 1);
}
});
miExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
System.exit(0);
}
});
miPlay.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
playGame();
}
});
miPause.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
pauseGame();
}
});
miResume.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
resumeGame();
}
});
miAsWindows.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
String plaf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
setWindowStyle(plaf);
canvas.fanning();
ctrlPanel.fanning();
miAsWindows.setState(true);
miAsMetal.setState(false);
miAsMotif.setState(false);
}
});
miAsMotif.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
String plaf = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
setWindowStyle(plaf);
canvas.fanning();
ctrlPanel.fanning();
miAsWindows.setState(false);
miAsMetal.setState(false);
miAsMotif.setState(true);
}
});
miAsMetal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
String plaf = "javax.swing.plaf.metal.MetalLookAndFeel";
setWindowStyle(plaf);
canvas.fanning();
ctrlPanel.fanning();
miAsWindows.setState(false);
miAsMetal.setState(true);
miAsMotif.setState(false);
}
});
}
/**
* 根據(jù)字串設(shè)置窗口外觀
* @param plaf String, 窗口外觀的描述
*/
private void setWindowStyle(String plaf) {
try {
UIManager.setLookAndFeel(plaf);
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception e) {
}
}
/**
* 一輪游戲過(guò)程,實(shí)現(xiàn)了Runnable接口
* 一輪游戲是一個(gè)大循環(huán),在這個(gè)循環(huán)中,每隔100毫秒,
* 檢查游戲中的當(dāng)前塊是否已經(jīng)到底了,如果沒(méi)有,
* 就繼續(xù)等待。如果到底了,就看有沒(méi)有全填滿的行,
* 如果有就刪除它,并為游戲者加分,同時(shí)隨機(jī)產(chǎn)生一個(gè)
* 新的當(dāng)前塊,讓它自動(dòng)下落。
* 當(dāng)新產(chǎn)生一個(gè)塊時(shí),先檢查畫(huà)布最頂上的一行是否已經(jīng)
* 被占了,如果是,可以判斷Game Over了。*/
private class Game implements Runnable {
public void run() {
//產(chǎn)生新方快
int col = (int) (Math.random() * (canvas.getCols() - 3)),
style = ErsBlock.STYLES[(int) (Math.random() * 7)][(int) (Math.random() * 4)];
while (playing) {
if (block != null) { //第一次循環(huán)時(shí),block為空
if (block.isAlive()) {
try {
Thread.currentThread().sleep(100);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
continue;
}
}
checkFullLine(); //檢查是否有全填滿的行
if (isGameOver()) { //檢查游戲是否應(yīng)該結(jié)束了
miPlay.setEnabled(true);
miPause.setEnabled(true);
miResume.setEnabled(false);
ctrlPanel.setPlayButtonEnable(true);
ctrlPanel.setPauseButtonLabel(true);
reportGameOver();
return;
}
block = new ErsBlock(style, -1, col, getLevel(), canvas);
block.start();
col = (int) (Math.random() * (canvas.getCols() - 3));
style = ErsBlock.STYLES[(int) (Math.random() * 7)][(int) (Math.random() * 4)];
ctrlPanel.setTipStyle(style);
}
}
/**
* 檢查畫(huà)布中是否有全填滿的行,如果有就刪除之*/
public void checkFullLine() {
for (int i = 0; i canvas.getRows(); i++) {
int row = -1;
boolean fullLineColorBox = true;
for (int j = 0; j canvas.getCols(); j++) {
if (!canvas.getBox(i, j).isColorBox()) {
fullLineColorBox = false;
break;
}
}
if (fullLineColorBox) {
row = i--;
canvas.removeLine(row);
}
}
}
/**
* 根據(jù)最頂行是否被占,判斷游戲是否已經(jīng)結(jié)束了。
* @return boolean, true-游戲結(jié)束了,false-游戲未結(jié)束*/
private boolean isGameOver() {
for (int i = 0; i canvas.getCols(); i++) {
ErsBox box = canvas.getBox(0, i);
if (box.isColorBox()) return true;
}
return false;
}
}
Java 程序員必須收藏的資源大全
古董級(jí)工具
這些工具伴隨著Java一起出現(xiàn),在各自輝煌之后還在一直使用。
Apache Ant:基于XML的構(gòu)建管理工具。
cglib:字節(jié)碼生成庫(kù)。
GlassFish:應(yīng)用服務(wù)器,由Oracle贊助支持的Java EE參考實(shí)現(xiàn)。
Hudson:持續(xù)集成服務(wù)器,目前仍在活躍開(kāi)發(fā)。
JavaServer Faces:Mojarra是JSF標(biāo)準(zhǔn)的一個(gè)開(kāi)源實(shí)現(xiàn),由Oracle開(kāi)發(fā)。
JavaServer Pages:支持自定義標(biāo)簽庫(kù)的網(wǎng)站通用模板庫(kù)。
Liquibase:與具體數(shù)據(jù)庫(kù)獨(dú)立的追蹤、管理和應(yīng)用數(shù)據(jù)庫(kù)Scheme變化的工具。
2.構(gòu)建工具
構(gòu)建及應(yīng)用依賴關(guān)系處理工具。
Apache Maven:Maven是一款聲明式構(gòu)建及依賴管理工具,采用約定優(yōu)于配置方式進(jìn)行管理。相對(duì)Apache Ant更推薦使用Maven,前者采用了過(guò)程式管理,維護(hù)相對(duì)困難。
Bazel:來(lái)自Google的構(gòu)建工具,可以快速、可靠地構(gòu)建代碼。
Gradle:使用Groovy(非XML)進(jìn)行增量構(gòu)建,可以很好地與Maven依賴管理配合工作。
需要這些學(xué)習(xí)資料和工具的可以自己下載哦
文章題目:java源代碼在線,在線看java源碼
本文鏈接:http://chinadenli.net/article40/heioeo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司、虛擬主機(jī)、企業(yè)建站、網(wǎng)站維護(hù)、微信公眾號(hào)、搜索引擎優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)