導航:首頁 > 編程語言 > java源代碼在線

java源代碼在線

發布時間:2022-08-06 12:21:58

A. 求java小程序源代碼 在線等 急急急!!!

下面是俄羅斯方塊游戲源代碼
還沒完,這代碼太長了,我用我另一個號再粘上
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類,負責游戲的全局控制。
* 內含
* 1, 一個GameCanvas畫布類的實例引用,
* 2, 一個保存當前活動塊(ErsBlock)實例的引用,
* 3, 一個保存當前控制面板(ControlPanel)實例的引用;*/
public class ErsBlocksGame extends JFrame {
/**
* 每填滿一行計多少分*/
public final static int PER_LINE_SCORE = 100;
/**
* 積多少分以後能升級*/
public final static int PER_LEVEL_SCORE = PER_LINE_SCORE * 20;
/**
* 最大級數是10級*/
public final static int MAX_LEVEL = 10;
/**
* 默認級數是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("游戲設置"),
mControl = new JMenu("游戲控制"),
mWindowStyle = new JMenu("窗口風格");
private JMenuItem
miNewGame = new JMenuItem("新游戲"),
miSetBlockColor = new JMenuItem("設置顏色 ..."),
miSetBackColor = new JMenuItem("設置底色 ..."),
miTurnHarder = new JMenuItem("提升等級"),
miTurnEasier = new JMenuItem("調底等級"),
miExit = new JMenuItem("退出"),

miPlay = new JMenuItem("開始游戲"),
miPause = new JMenuItem("暫停"),
miResume = new JMenuItem("繼續");

private JCheckBoxMenuItem
miAsWindows = new JCheckBoxMenuItem("風格1"),
miAsMotif = new JCheckBoxMenuItem("風格2"),
miAsMetal = new JCheckBoxMenuItem("風格3", true);

/**
* 主游戲類的構造函數
* @param title String,窗口標題*/
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();
}
// 游戲「復位」
public void reset() {
ctrlPanel.reset();
canvas.reset();
}
/**
* 判斷游戲是否還在進行
* @return boolean, true-還在運行,false-已經停止*/
public boolean isPlaying() {
return playing;
}
/**
* 得到當前活動的塊
* @return ErsBlock, 當前活動塊的引用*/
public ErsBlock getCurBlock() {
return block;
}
/**
* 得到當前畫布
* @return GameCanvas, 當前畫布的引用 */
public GameCanvas getCanvas() {
return canvas;
}

/**
* 開始游戲*/
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);
}
/**
* 讓暫停中的游戲繼續*/
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);
}
/**
* 得到當前游戲者設置的游戲難度
* @return int, 游戲難度1-MAX_LEVEL*/
public int getLevel() {
return ctrlPanel.getLevel();
}
/**
* 讓用戶設置游戲難度
* @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;
}
/**
* 得到自上次升級以來的游戲積分,升級以後,此積分清零
* @return int, 積分。*/
public int getScoreForLevelUpdate() {
if (canvas != null) return canvas.getScoreForLevelUpdate();
return 0;
}
/**
* 當分數累計到一定的數量時,升一次級
* @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;
}
/**
* 游戲開始*/
private void play() {
reset();
playing = true;
Thread thread = new Thread(new Game());
thread.start();
}

/**
* 報告游戲結束了*/
private void reportGameOver() {
JOptionPane.showMessageDialog(this, "游戲結束!");
}
/**
* 建立並設置窗口菜單 */
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,
"設置積木顏色", canvas.getBlockColor());
if (newFrontColor != null)
canvas.setBlockColor(newFrontColor);
}
});
miSetBackColor.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
Color newBackColor =
JColorChooser.showDialog(ErsBlocksGame.this,
"設置底版顏色", 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);
}
});
}
/**
* 根據字串設置窗口外觀
* @param plaf String, 窗口外觀的描述
*/
private void setWindowStyle(String plaf) {
try {
UIManager.setLookAndFeel(plaf);
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception e) {
}
}
/**
* 一輪游戲過程,實現了Runnable介面
* 一輪游戲是一個大循環,在這個循環中,每隔100毫秒,
* 檢查游戲中的當前塊是否已經到底了,如果沒有,
* 就繼續等待。如果到底了,就看有沒有全填滿的行,
* 如果有就刪除它,並為游戲者加分,同時隨機產生一個
* 新的當前塊,讓它自動下落。
* 當新產生一個塊時,先檢查畫布最頂上的一行是否已經
* 被佔了,如果是,可以判斷Game Over了。*/
private class Game implements Runnable {
public void run() {
//產生新方快
int col = (int) (Math.random() * (canvas.getCols() - 3)),
style = ErsBlock.STYLES[(int) (Math.random() * 7)][(int) (Math.random() * 4)];
while (playing) {
if (block != null) { //第一次循環時,block為空
if (block.isAlive()) {
try {
Thread.currentThread().sleep(100);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
continue;
}
}
checkFullLine(); //檢查是否有全填滿的行
if (isGameOver()) { //檢查游戲是否應該結束了
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);
}
}
/**
* 檢查畫布中是否有全填滿的行,如果有就刪除之*/
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);
}
}
}

/**
* 根據最頂行是否被占,判斷游戲是否已經結束了。
* @return boolean, true-游戲結束了,false-游戲未結束*/
private boolean isGameOver() {
for (int i = 0; i < canvas.getCols(); i++) {
ErsBox box = canvas.getBox(0, i);
if (box.isColorBox()) return true;
}
return false;
}
}

B. 求Java的在線學習系統源代碼

Java 程序員必須收藏的資源大全

古董級工具

這些工具伴隨著Java一起出現,在各自輝煌之後還在一直使用。

Apache Ant:基於XML的構建管理工具。

cglib:位元組碼生成庫。

GlassFish:應用伺服器,由Oracle贊助支持的Java EE參考實現。

Hudson:持續集成伺服器,目前仍在活躍開發。

JavaServer Faces:Mojarra是JSF標準的一個開源實現,由Oracle開發。

JavaServer Pages:支持自定義標簽庫的網站通用模板庫。

Liquibase:與具體資料庫獨立的追蹤、管理和應用資料庫Scheme變化的工具。

C. 求JAVA小項目的完整代碼

給你個做好了的Java的源程序的記事本,自己看看就行了的,不怎麼難的···
import java.awt.*;
import java.awt.event.*;
import java.io.*;

import javax.swing.*;

public class MyNotepad implements ActionListener{
private JFrame frame=new JFrame("新記事本");
private JTextArea jta=new JTextArea();
private String result="";
private boolean flag=true;
private File f;
private JButton jb=new JButton("開始");
private JTextField jtf=new JTextField(15);
private JTextField jt=new JTextField(15);
private JButton jbt=new JButton("替換為");
private JButton jba=new JButton("全部替換");
private Icon ic=new ImageIcon("D:\\java課堂筆記\\GUI\\11.gif");
private String value;
private int start=0;
private JFrame jf=new JFrame("查找");
private JFrame jfc=new JFrame("替換");

@Override
public void actionPerformed(ActionEvent e) {
String comm=e.getActionCommand();
if("新建".equals(comm)){
if(!(frame.getTitle().equals("新記事本"))){
if(!flag){
write();
newNew();
}else{
JFileChooser jfc=new JFileChooser("D:\\java課堂筆記");
int returnVal = jfc.showDialog(null,"保存為");
if(returnVal == JFileChooser.APPROVE_OPTION) {//選擇文件後再執行下面的語句,保證了程序的健壯性
f=jfc.getSelectedFile();
flag=false;
write();
}
}
}else if(!(jta.getText().isEmpty())){
JFileChooser jfc=new JFileChooser("D:\\java課堂筆記");
int returnVal = jfc.showDialog(null,"保存為");
if(returnVal == JFileChooser.APPROVE_OPTION) {//選擇文件後再執行下面的語句,保證了程序的健壯性
f=jfc.getSelectedFile();
flag=false;
write();
newNew();
}
}else{
newNew();
}
}else if("打開".equals(comm)){
JFileChooser jfc=new JFileChooser("D:\\java課堂筆記");
jfc.setDialogType(JFileChooser.OPEN_DIALOG);
int returnVal = jfc.showOpenDialog(null);
if(returnVal == JFileChooser.APPROVE_OPTION) {//選擇文件後再執行下面的語句,保證了程序的健壯性
f=jfc.getSelectedFile();
frame.setTitle(f.getName());
result=read();
flag=false;
value=result;
jta.setText(result);
}
}else if("保存".equals(comm)){
JFileChooser jfc=new JFileChooser("D:\\java課堂筆記");
if(flag){
int returnVal = jfc.showDialog(null,"保存為");
if(returnVal == JFileChooser.APPROVE_OPTION) {//選擇文件後再執行下面的語句,保證了程序的健壯性
f=jfc.getSelectedFile();
flag=false;
write();
}
}else{
write();
}
}else if("另存".equals(comm)){
JFileChooser jfc=new JFileChooser("D:\\java課堂筆記");
int returnVal = jfc.showDialog(null,"另存");
if(returnVal == JFileChooser.APPROVE_OPTION) {//選擇文件後再執行下面的語句,保證了程序的健壯性
f=jfc.getSelectedFile();
write();
}
}else if("退出".equals(comm)){
System.exit(0);
}else if("撤銷".equals(comm)){
jta.setText(value);
}else if("剪切".equals(comm)){
value=jta.getText();
jta.cut();
}else if("復制".equals(comm)){
jta.();
}else if("粘貼".equals(comm)){
value=jta.getText();
jta.paste();
}else if("刪除".equals(comm)){
value=jta.getText();
jta.replaceSelection(null);
}else if("全選".equals(comm)){
jta.selectAll();
}else if("查找".equals(comm)){
value=jta.getText();
jf.add(jtf,BorderLayout.CENTER);
jf.add(jb,BorderLayout.SOUTH);

jf.setLocation(300,300);
jf.pack();
jf.setVisible(true);
jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}else if("替換".equals(comm)){
value=jta.getText();
GridLayout gl=new GridLayout(3,3);
JLabel jl1=new JLabel("查找內容:");
JLabel jl2=new JLabel("替換為:");
jfc.setLayout(gl);
jfc.add(jl1);
jfc.add(jtf);
jfc.add(jb);
jfc.add(jl2);
jfc.add(jt);
jfc.add(jbt);
JLabel jl3=new JLabel();
JLabel jl4=new JLabel();
jfc.add(jl3);
jfc.add(jl4);
jfc.add(jba);

jfc.setLocation(300,300);
jfc.pack();
jfc.setVisible(true);
jfc.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}else if("版本".equals(comm)){
JDialog jd=new JDialog(frame,"關於對話框");
jd.setSize(200,200);
JLabel l=new JLabel("哈哈哈哈哈哈哈哈哈哈呵呵呵呵呵呵呵呵呵呵呵呵呵");
jd.add(l,BorderLayout.CENTER);
jd.setLocation(100,200);
jd.setSize(300,300);
jd.setVisible(true);
// jd.pack();
jd.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
}else if("開始".equals(comm)||"下一個".equals(comm)){
String temp=jtf.getText();
int s=value.indexOf(temp,start);
if(value.indexOf(temp,start)!=-1){
jta.setSelectionStart(s);
jta.setSelectionEnd(s+temp.length());
jta.setSelectedTextColor(Color.GREEN);
start=s+1;
jb.setText("下一個");
// value=value.substring(s+temp.length());//不能截取字串
}else {
JOptionPane.showMessageDialog(jf, "查找完畢!", "提示", 0, ic);
jf.dispose();
}
}else if("替換為".equals(comm)){
String temp=jtf.getText();
int s=value.indexOf(temp,start);
if(value.indexOf(temp,start)!=-1){
jta.setSelectionStart(s);
jta.setSelectionEnd(s+temp.length());
jta.setSelectedTextColor(Color.GREEN);
start=s+1;
jta.replaceSelection(jt.getText());
}else {
JOptionPane.showMessageDialog(jf, "查找完畢!", "提示", 0, ic);
jf.dispose();
}
}else if("全部替換".equals(comm)){
String temp=jta.getText();
temp=temp.replaceAll(jtf.getText(), jt.getText());
jta.setText(temp);

}
}
public String read(){
String temp="";
try {
FileInputStream fis = new FileInputStream(f.getAbsolutePath());
byte[] b=new byte[1024];
while(true){
int num=fis.read(b);
if(num==-1)break;
temp=temp+new String(b,0,num);
}
fis.close();
} catch (Exception e1) {
e1.printStackTrace();
}
return temp;
}

public void write(){
try {
FileOutputStream fos=new FileOutputStream(f);
fos.write(jta.getText().getBytes());
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public void newNew(){
frame.dispose();
new MyNotepad();
flag=true;
}
public MyNotepad(){
JMenuBar jmb=new JMenuBar();
String[] menuLab={"文件","編輯","幫助"};
String[][] menuItemLab={{"新建","打開","保存","另存","退出"},
{"撤銷","剪切","復制","粘貼","刪除","全選","查找","替換"},
{"版本"}};
for(int i=0;i<menuLab.length;i++){
JMenu menu=new JMenu(menuLab[i]);
jmb.add(menu);
for(int j=0;j<menuItemLab[i].length;j++){
JMenuItem jmi=new JMenuItem(menuItemLab[i][j]);
menu.add(jmi);
jmi.addActionListener(this);
}
}
frame.setJMenuBar(jmb);
jta.setLineWrap(true);//自動換行
JScrollPane jsp=new JScrollPane(jta);//滾動窗口面板
frame.add(jsp);

jb.addActionListener(this);
jbt.addActionListener(this);
jba.addActionListener(this);

frame.setLocation(200,50);
frame.setSize(620,660);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new MyNotepad();
}
}

D. 跪地求好玩的JAVA 源代碼~

連連看java源代碼
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class lianliankan implements ActionListener
{
JFrame mainFrame; //主面板
Container thisContainer;
JPanel centerPanel,southPanel,northPanel; //子面板
JButton diamondsButton[][] = new JButton[6][5];//游戲按鈕數組
JButton exitButton,resetButton,newlyButton; //退出,重列,重新開始按鈕
JLabel fractionLable=new JLabel("0"); //分數標簽
JButton firstButton,secondButton; //分別記錄兩次被選中的按鈕
int grid[][] = new int[8][7];//儲存游戲按鈕位置
static boolean pressInformation=false; //判斷是否有按鈕被選中
int x0=0,y0=0,x=0,y=0,fristMsg=0,secondMsg=0,validateLV; //游戲按鈕的位置坐標
int i,j,k,n;//消除方法控制
public void init(){
mainFrame=new JFrame("JKJ連連看");
thisContainer = mainFrame.getContentPane();
thisContainer.setLayout(new BorderLayout());
centerPanel=new JPanel();
southPanel=new JPanel();
northPanel=new JPanel();
thisContainer.add(centerPanel,"Center");
thisContainer.add(southPanel,"South");
thisContainer.add(northPanel,"North");
centerPanel.setLayout(new GridLayout(6,5));
for(int cols = 0;cols < 6;cols++){
for(int rows = 0;rows < 5;rows++ ){
diamondsButton[cols][rows]=new JButton(String.valueOf(grid[cols+1][rows+1]));
diamondsButton[cols][rows].addActionListener(this);
centerPanel.add(diamondsButton[cols][rows]);
}
}
exitButton=new JButton("退出");
exitButton.addActionListener(this);
resetButton=new JButton("重列");
resetButton.addActionListener(this);
newlyButton=new JButton("再來一局");
newlyButton.addActionListener(this);
southPanel.add(exitButton);
southPanel.add(resetButton);
southPanel.add(newlyButton);
fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())));
northPanel.add(fractionLable);
mainFrame.setBounds(280,100,500,450);
mainFrame.setVisible(true);
}
public void randomBuild() {
int randoms,cols,rows;
for(int twins=1;twins<=15;twins++) {
randoms=(int)(Math.random()*25+1);
for(int alike=1;alike<=2;alike++) {
cols=(int)(Math.random()*6+1);
rows=(int)(Math.random()*5+1);
while(grid[cols][rows]!=0) {
cols=(int)(Math.random()*6+1);
rows=(int)(Math.random()*5+1);
}
this.grid[cols][rows]=randoms;
}
}
}
public void fraction(){
fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())+100));
}
public void reload() {
int save[] = new int[30];
int n=0,cols,rows;
int grid[][]= new int[8][7];
for(int i=0;i<=6;i++) {
for(int j=0;j<=5;j++) {
if(this.grid[i][j]!=0) {
save[n]=this.grid[i][j];
n++;
}
}
}
n=n-1;
this.grid=grid;
while(n>=0) {
cols=(int)(Math.random()*6+1);
rows=(int)(Math.random()*5+1);
while(grid[cols][rows]!=0) {
cols=(int)(Math.random()*6+1);
rows=(int)(Math.random()*5+1);
}
this.grid[cols][rows]=save[n];
n--;
}
mainFrame.setVisible(false);
pressInformation=false; //這里一定要將按鈕點擊信息歸為初始
init();
for(int i = 0;i < 6;i++){
for(int j = 0;j < 5;j++ ){
if(grid[i+1][j+1]==0)
diamondsButton[i][j].setVisible(false);
}
}
}
public void estimateEven(int placeX,int placeY,JButton bz) {
if(pressInformation==false) {
x=placeX;
y=placeY;
secondMsg=grid[x][y];
secondButton=bz;
pressInformation=true;
}
else {
x0=x;
y0=y;
fristMsg=secondMsg;
firstButton=secondButton;
x=placeX;
y=placeY;
secondMsg=grid[x][y];
secondButton=bz;
if(fristMsg==secondMsg && secondButton!=firstButton){
xiao();
}
}
}
public void xiao() { //相同的情況下能不能消去。仔細分析,不一條條注釋
if((x0==x &&(y0==y+1||y0==y-1)) || ((x0==x+1||x0==x-1)&&(y0==y))){ //判斷是否相鄰
remove();
}
else{
for (j=0;j<7;j++ ) {
if (grid[x0][j]==0){ //判斷第一個按鈕同行哪個按鈕為空
if (y>j) { //如果第二個按鈕的Y坐標大於空按鈕的Y坐標說明第一按鈕在第二按鈕左邊
for (i=y-1;i>=j;i-- ){ //判斷第二按鈕左側直到第一按鈕中間有沒有按鈕
if (grid[x][i]!=0) {
k=0;
break;
}
else{ k=1; } //K=1說明通過了第一次驗證
}
if (k==1) {
linePassOne();
}
}
if (y<j){ //如果第二個按鈕的Y坐標小於空按鈕的Y坐標說明第一按鈕在第二按鈕右邊
for (i=y+1;i<=j ;i++ ){ //判斷第二按鈕左側直到第一按鈕中間有沒有按鈕
if (grid[x][i]!=0){
k=0;
break;
}
else { k=1; }
}
if (k==1){
linePassOne();
}
}
if (y==j ) {
linePassOne();
}
}
if (k==2) {
if (x0==x) {
remove();
}
if (x0<x) {
for (n=x0;n<=x-1;n++ ) {
if (grid[n][j]!=0) {
k=0;
break;
}
if(grid[n][j]==0 && n==x-1) {
remove();
}
}
}
if (x0>x) {
for (n=x0;n>=x+1 ;n-- ) {
if (grid[n][j]!=0) {
k=0;
break;
}
if(grid[n][j]==0 && n==x+1) {
remove();
}
}
}
}
}
for (i=0;i<8;i++ ) { //列
if (grid[i][y0]==0) {
if (x>i) {
for (j=x-1;j>=i ;j-- ) {
if (grid[j][y]!=0) {
k=0;
break;
}
else { k=1; }
}
if (k==1) {
rowPassOne();
}
}
if (x<i) {
for (j=x+1;j<=i;j++ ) {
if (grid[j][y]!=0) {
k=0;
break;
}
else { k=1; }
}
if (k==1) {
rowPassOne();
}
}
if (x==i) {
rowPassOne();
}
}
if (k==2){
if (y0==y) {
remove();
}
if (y0<y) {
for (n=y0;n<=y-1 ;n++ ) {
if (grid[i][n]!=0) {
k=0;
break;
}
if(grid[i][n]==0 && n==y-1) {
remove();
}
}
}
if (y0>y) {
for (n=y0;n>=y+1 ;n--) {
if (grid[i][n]!=0) {
k=0;
break;
}
if(grid[i][n]==0 && n==y+1) {
remove();
}
}
}
}
}
}
}
public void linePassOne(){
if (y0>j){ //第一按鈕同行空按鈕在左邊
for (i=y0-1;i>=j ;i-- ){ //判斷第一按鈕同左側空按鈕之間有沒按鈕
if (grid[x0][i]!=0) {
k=0;
break;
}
else { k=2; } //K=2說明通過了第二次驗證
}
}
if (y0<j){ //第一按鈕同行空按鈕在與第二按鈕之間
for (i=y0+1;i<=j ;i++){
if (grid[x0][i]!=0) {
k=0;
break;
}
else{ k=2; }
}
}
}
public void rowPassOne(){
if (x0>i) {
for (j=x0-1;j>=i ;j-- ) {
if (grid[j][y0]!=0) {
k=0;
break;
}
else { k=2; }
}
}
if (x0<i) {
for (j=x0+1;j<=i ;j++ ) {
if (grid[j][y0]!=0) {
k=0;
break;
}
else { k=2; }
}
}
}
public void remove(){
firstButton.setVisible(false);
secondButton.setVisible(false);
fraction();
pressInformation=false;
k=0;
grid[x0][y0]=0;
grid[x][y]=0;
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==newlyButton){
int grid[][] = new int[8][7];
this.grid = grid;
randomBuild();
mainFrame.setVisible(false);
pressInformation=false;
init();
}
if(e.getSource()==exitButton)
System.exit(0);
if(e.getSource()==resetButton)
reload();
for(int cols = 0;cols < 6;cols++){
for(int rows = 0;rows < 5;rows++ ){
if(e.getSource()==diamondsButton[cols][rows])
estimateEven(cols+1,rows+1,diamondsButton[cols][rows]);
}
}
}
public static void main(String[] args) {
lianliankan llk = new lianliankan();
llk.randomBuild();
llk.init();
}
}

//old 998 lines
//new 318 lines

基於JAVA的3D坦克游戲源代碼

http://www.newasp.net/code/java/4400.html

JAVA猜數字小游戲源代碼

/*1、編寫一個猜數字的游戲,由電腦隨機產生一個100以內的整數,讓用戶去猜,如果用戶猜的比電腦大,則輸出「大了,再小點!」,反之則輸出「小了,再大點!」,用戶總共只能猜十次,並根據用戶正確猜出答案所用的次數輸出相應的信息,如:只用一次就猜對,輸出「你是個天才!」,八次才猜對,輸出「笨死了!」,如果十次還沒有猜對,則游戲結束!*/
import java.util.*;
import java.io.*;
public class CaiShu{
public static void main(String[] args) throws IOException{
Random a=new Random();
int num=a.nextInt(100);
System.out.println("請輸入一個100以內的整數:");
for (int i=0;i<=9;i++){
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
String str=bf.readLine();
int shu=Integer.parseInt(str);
if (shu>num)
System.out.println("輸入的數大了,輸小點的!");
else if (shu<num)
System.out.println("輸入的數小了,輸大點的!");
else {
System.out.println("恭喜你,猜對了!");
if (i<=2)
System.out.println("你真是個天才!");
else if (i<=6)
System.out.println("還將就,你過關了!");
else if (i<=8)
System.out.println("但是你還……真笨!");
else
System.out.println("你和豬沒有兩樣了!");

break;}
}
}

}

E. 求java小游戲源代碼

[最佳答案] 連連看java源代碼 import javax.swing.*; import java.awt.*; import java.awt.event.*; pu... int x0=0,y0=0,x=0,y=0,fristMsg=0,secondMsg=0,validateLV; //游戲按鈕的位...

F. 求一個用JAVA寫的簡單的記事本源代碼程序 要有運行結果的截圖和源代碼,在線等

這個是我以前寫著玩的一個例子,可以運行起來看看,有保存,撤銷,復制,剪切功能,自己研究研究

package test;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class MyNote {
private JFrame frame = new JFrame("記事本");
private JTextArea text = new JTextArea();
private static boolean flag = false; // 判斷是否保存

public MyNote() {
JMenuBar bar = new JMenuBar();
JMenu edit = new JMenu("check");
JMenu check = new JMenu("edit");
JMenu help = new JMenu("help");
JMenuItem term = new JMenuItem("");
JMenuItem term1 = new JMenuItem("paste");
JMenuItem term2 = new JMenuItem("cut");
JMenuItem term3 = new JMenuItem("backout");
JMenuItem term4 = new JMenuItem("import");
JMenuItem term5 = new JMenuItem("open");
JMenuItem term6 = new JMenuItem("exit");
JMenuItem term7 = new JMenuItem("save to");
JMenuItem term8 = new JMenuItem("about");
JMenuItem term9 = new JMenuItem("save");
JMenuItem term10 = new JMenuItem("new");
Font font = new Font(null, JFrame.ABORT, 24);
text.setFont(font);
JScrollPane scroll = new JScrollPane(text);
frame.setJMenuBar(bar);
bar.add(edit);
bar.add(check);
bar.add(help);
edit.add(term7);
edit.add(term4);
edit.add(term5);
edit.add(term6);
check.add(term);
check.add(term1);
check.add(term2);
check.add(term3);
help.add(term8);
check.add(term9);
edit.add(term10);

frame.add(scroll);
text.setVisible(false);
frame.setSize(400, 400);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
frame.setLocation(500, 500);
// 事件注冊
MenuListener m = new MenuListener();
term5.addActionListener(m);
NewListener n = new NewListener();
term4.addActionListener(n);
SaveListener s = new SaveListener();
term7.addActionListener(s);
CopyListener c = new CopyListener();
term.addActionListener(c);
PasteListener p = new PasteListener();
term1.addActionListener(p);
CutListener c1 = new CutListener();
term2.addActionListener(c1);
HelpListener h = new HelpListener();
term8.addActionListener(h);
ExitListener e = new ExitListener();
term6.addActionListener(e);
CloseListener c2 = new CloseListener();
frame.addWindowListener(c2);
BackOutListener b = new BackOutListener();
term3.addActionListener(b);
SaveActionListener s1 = new SaveActionListener();
term9.addActionListener(s1);
NewFileListener n1 = new NewFileListener();
term10.addActionListener(n1);
}

private class MenuListener implements ActionListener {

public void actionPerformed(ActionEvent e) {
text.setVisible(true);
}

}

// 打開新文件
private class NewListener implements ActionListener {

public void actionPerformed(ActionEvent e) {
text.setText("");
JFileChooser fileChooser = new JFileChooser();
int r = fileChooser.showOpenDialog(frame);
if (r == JFileChooser.APPROVE_OPTION) {
try {
File file = fileChooser.getSelectedFile();
FileReader fr = new FileReader(file);
char[] buf = new char[1024];
int len = 0;
while ((len = fr.read(buf)) != -1) {
text.append(new String(buf, 0, len));
}
fr.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}

// 另存為
private class SaveListener implements ActionListener {

public void actionPerformed(ActionEvent e) {
JFileChooser filechoose = new JFileChooser();
int r = filechoose.showSaveDialog(frame);
if (r == JFileChooser.APPROVE_OPTION) {
File file = filechoose.getSelectedFile();
try {
FileWriter writer = new FileWriter(file);
writer.write((String) text.getText());
writer.close();
// 下面方法也可以
/*
* PrintWriter print=new PrintWriter(file);
* print.write(text.getText()); print.close();
*/
} catch (IOException e1) {
e1.printStackTrace();
}
}
}

}

// 復制
private class CopyListener implements ActionListener {

public void actionPerformed(ActionEvent e) {
text.();
}
}

// 粘貼
private class PasteListener implements ActionListener {

public void actionPerformed(ActionEvent e) {
text.paste();
}
}

// 剪切
private class CutListener implements ActionListener {

public void actionPerformed(ActionEvent e) {
text.cut();
}
}

// 關於主題
private class HelpListener implements ActionListener {

public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(frame, "汪雄輝的無敵記事本");
}
}

private class ExitListener implements ActionListener {

public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(frame, "謝謝!");
try {
Thread.sleep(2000);
System.exit(0);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}

private class CloseListener implements WindowListener {

public void windowActivated(WindowEvent e) {

}

public void windowClosed(WindowEvent e) {
}

// 關閉窗口
public void windowClosing(WindowEvent e) {
StringBuffer sb = new StringBuffer();
try {
FileReader fr = new FileReader("未命名文件.txt");
char[] buf = new char[1024];
int len = 0;
while ((len = fr.read(buf)) != -1) {
sb.append(new String(buf, 0, len));
}
fr.close();
} catch (Exception e1) {
e1.getStackTrace();
}
String s = sb.toString();
if (flag == false || !(text.getText().equals(s))) {
int r = JOptionPane.showConfirmDialog(frame, "你還沒有保存,要保存嗎?");
if (r == JOptionPane.OK_OPTION) {
JFileChooser filechoose = new JFileChooser();
int r1 = filechoose.showSaveDialog(frame);
if (r1 == JFileChooser.APPROVE_OPTION) {
File file = filechoose.getSelectedFile();
try {
FileWriter writer = new FileWriter(file);
writer.write((String) text.getText());
writer.close();
System.exit(0);
// 下面方法也可以
/*
* PrintWriter print=new PrintWriter(file);
* print.write(text.getText()); print.close();
*/
} catch (IOException e1) {
e1.printStackTrace();
}
} else {
}
} else if (r == JOptionPane.NO_OPTION) {
System.exit(0);
} else {
}
} else
System.exit(0);

}

public void windowDeactivated(WindowEvent e) {
}

public void windowDeiconified(WindowEvent e) {
}

public void windowIconified(WindowEvent e) {
}

public void windowOpened(WindowEvent e) {
}
}

// 撤銷
private class BackOutListener implements ActionListener {

public void actionPerformed(ActionEvent e) {
if (flag == false)
text.setText("");
else {
try {
FileReader fr = new FileReader("未命名文件.txt");
char[] buf = new char[1024];
int len = 0;
while ((len = fr.read(buf)) != -1) {
text.setText(new String(buf, 0, len));
}
fr.close();
} catch (IOException e1) {
e1.getStackTrace();
}
}
}
}

// 保存文件
private class SaveActionListener implements ActionListener {

public void actionPerformed(ActionEvent e) {
flag = true;
FileWriter writer;
try {
writer = new FileWriter("未命名文件.txt");
writer.write((String) text.getText());
writer.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}

private class NewFileListener implements ActionListener {

public void actionPerformed(ActionEvent e) {
new MyNote();
}
}

public static void main(String[] args) {
new MyNote();
}
}

G. java記事本源代碼

給你個做好了的Java的源程序的記事本,自己看看就行了的,不怎麼難的···
import java.awt.*;
import java.awt.event.*;
import java.io.*;

import javax.swing.*;

public class MyNotepad implements ActionListener{
private JFrame frame=new JFrame("新記事本");
private JTextArea jta=new JTextArea();
private String result="";
private boolean flag=true;
private File f;
private JButton jb=new JButton("開始");
private JTextField jtf=new JTextField(15);
private JTextField jt=new JTextField(15);
private JButton jbt=new JButton("替換為");
private JButton jba=new JButton("全部替換");
private Icon ic=new ImageIcon("D:\\java課堂筆記\\GUI\\11.gif");
private String value;
private int start=0;
private JFrame jf=new JFrame("查找");
private JFrame jfc=new JFrame("替換");

@Override
public void actionPerformed(ActionEvent e) {
String comm=e.getActionCommand();
if("新建".equals(comm)){
if(!(frame.getTitle().equals("新記事本"))){
if(!flag){
write();
newNew();
}else{
JFileChooser jfc=new JFileChooser("D:\\java課堂筆記");
int returnVal = jfc.showDialog(null,"保存為");
if(returnVal == JFileChooser.APPROVE_OPTION) {//選擇文件後再執行下面的語句,保證了程序的健壯性
f=jfc.getSelectedFile();
flag=false;
write();
}
}
}else if(!(jta.getText().isEmpty())){
JFileChooser jfc=new JFileChooser("D:\\java課堂筆記");
int returnVal = jfc.showDialog(null,"保存為");
if(returnVal == JFileChooser.APPROVE_OPTION) {//選擇文件後再執行下面的語句,保證了程序的健壯性
f=jfc.getSelectedFile();
flag=false;
write();
newNew();
}
}else{
newNew();
}
}else if("打開".equals(comm)){
JFileChooser jfc=new JFileChooser("D:\\java課堂筆記");
jfc.setDialogType(JFileChooser.OPEN_DIALOG);
int returnVal = jfc.showOpenDialog(null);
if(returnVal == JFileChooser.APPROVE_OPTION) {//選擇文件後再執行下面的語句,保證了程序的健壯性
f=jfc.getSelectedFile();
frame.setTitle(f.getName());
result=read();
flag=false;
value=result;
jta.setText(result);
}
}else if("保存".equals(comm)){
JFileChooser jfc=new JFileChooser("D:\\java課堂筆記");
if(flag){
int returnVal = jfc.showDialog(null,"保存為");
if(returnVal == JFileChooser.APPROVE_OPTION) {//選擇文件後再執行下面的語句,保證了程序的健壯性
f=jfc.getSelectedFile();
flag=false;
write();
}
}else{
write();
}
}else if("另存".equals(comm)){
JFileChooser jfc=new JFileChooser("D:\\java課堂筆記");
int returnVal = jfc.showDialog(null,"另存");
if(returnVal == JFileChooser.APPROVE_OPTION) {//選擇文件後再執行下面的語句,保證了程序的健壯性
f=jfc.getSelectedFile();
write();
}
}else if("退出".equals(comm)){
System.exit(0);
}else if("撤銷".equals(comm)){
jta.setText(value);
}else if("剪切".equals(comm)){
value=jta.getText();
jta.cut();
}else if("復制".equals(comm)){
jta.();
}else if("粘貼".equals(comm)){
value=jta.getText();
jta.paste();
}else if("刪除".equals(comm)){
value=jta.getText();
jta.replaceSelection(null);
}else if("全選".equals(comm)){
jta.selectAll();
}else if("查找".equals(comm)){
value=jta.getText();
jf.add(jtf,BorderLayout.CENTER);
jf.add(jb,BorderLayout.SOUTH);

jf.setLocation(300,300);
jf.pack();
jf.setVisible(true);
jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}else if("替換".equals(comm)){
value=jta.getText();
GridLayout gl=new GridLayout(3,3);
JLabel jl1=new JLabel("查找內容:");
JLabel jl2=new JLabel("替換為:");
jfc.setLayout(gl);
jfc.add(jl1);
jfc.add(jtf);
jfc.add(jb);
jfc.add(jl2);
jfc.add(jt);
jfc.add(jbt);
JLabel jl3=new JLabel();
JLabel jl4=new JLabel();
jfc.add(jl3);
jfc.add(jl4);
jfc.add(jba);

jfc.setLocation(300,300);
jfc.pack();
jfc.setVisible(true);
jfc.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}else if("版本".equals(comm)){
JDialog jd=new JDialog(frame,"關於對話框");
jd.setSize(200,200);
JLabel l=new JLabel("哈哈哈哈哈哈哈哈哈哈呵呵呵呵呵呵呵呵呵呵呵呵呵");
jd.add(l,BorderLayout.CENTER);
jd.setLocation(100,200);
jd.setSize(300,300);
jd.setVisible(true);
// jd.pack();
jd.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
}else if("開始".equals(comm)||"下一個".equals(comm)){
String temp=jtf.getText();
int s=value.indexOf(temp,start);
if(value.indexOf(temp,start)!=-1){
jta.setSelectionStart(s);
jta.setSelectionEnd(s+temp.length());
jta.setSelectedTextColor(Color.GREEN);
start=s+1;
jb.setText("下一個");
// value=value.substring(s+temp.length());//不能截取字串
}else {
JOptionPane.showMessageDialog(jf, "查找完畢!", "提示", 0, ic);
jf.dispose();
}
}else if("替換為".equals(comm)){
String temp=jtf.getText();
int s=value.indexOf(temp,start);
if(value.indexOf(temp,start)!=-1){
jta.setSelectionStart(s);
jta.setSelectionEnd(s+temp.length());
jta.setSelectedTextColor(Color.GREEN);
start=s+1;
jta.replaceSelection(jt.getText());
}else {
JOptionPane.showMessageDialog(jf, "查找完畢!", "提示", 0, ic);
jf.dispose();
}
}else if("全部替換".equals(comm)){
String temp=jta.getText();
temp=temp.replaceAll(jtf.getText(), jt.getText());
jta.setText(temp);

}
}
public String read(){
String temp="";
try {
FileInputStream fis = new FileInputStream(f.getAbsolutePath());
byte[] b=new byte[1024];
while(true){
int num=fis.read(b);
if(num==-1)break;
temp=temp+new String(b,0,num);
}
fis.close();
} catch (Exception e1) {
e1.printStackTrace();
}
return temp;
}

public void write(){
try {
FileOutputStream fos=new FileOutputStream(f);
fos.write(jta.getText().getBytes());
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public void newNew(){
frame.dispose();
new MyNotepad();
flag=true;
}
public MyNotepad(){
JMenuBar jmb=new JMenuBar();
String[] menuLab={"文件","編輯","幫助"};
String[][] menuItemLab={{"新建","打開","保存","另存","退出"},
{"撤銷","剪切","復制","粘貼","刪除","全選","查找","替換"},
{"版本"}};
for(int i=0;i<menuLab.length;i++){
JMenu menu=new JMenu(menuLab[i]);
jmb.add(menu);
for(int j=0;j<menuItemLab[i].length;j++){
JMenuItem jmi=new JMenuItem(menuItemLab[i][j]);
menu.add(jmi);
jmi.addActionListener(this);
}
}
frame.setJMenuBar(jmb);
jta.setLineWrap(true);//自動換行
JScrollPane jsp=new JScrollPane(jta);//滾動窗口面板
frame.add(jsp);

jb.addActionListener(this);
jbt.addActionListener(this);
jba.addActionListener(this);

frame.setLocation(200,50);
frame.setSize(620,660);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new MyNotepad();
}
}

H. 怎樣在網上查找JAVA源代碼

用網路搜索一下,就用「JAVA源代碼「做為搜索條件。一般能找到很多網站。
要學JAVA最好還是找本書看一看。JAVA能做的東西很多,你要決定你的主攻方向然後就去找相應的資料。
你要學哪方面:
JAVA應用程序開發,
JAVA網路開發:JSP,APPLET。
JAVA手持設備軟體開發,像手機軟體等。

如果對程序還不是很懂,最好找本JAVA入門級的書看看,然後再決定。

I. 區域網在線掃描 IP,MAC Java源代碼

1.得到區域網網段,可由自己機器的IP來確定 (也可以手動獲取主機IP-CMD-ipconfig /all)
2.根據IP類型,一次遍歷區域網內IP地址
JAVA類,編譯之後直接運行便可以得到區域網內所有IP,具體怎樣使用你自己編寫相應代碼調用便可
代碼如下::
package bean;
import java.io.*;
import java.util.*;
public class Ip{
static public HashMap ping; //ping 後的結果集
public HashMap getPing(){ //用來得到ping後的結果集
return ping;
}
//當前線程的數量, 防止過多線程摧毀電腦
static int threadCount = 0;
public Ip() {
ping = new HashMap();
}
public void Ping(String ip) throws Exception{
//最多30個線程
while(threadCount>30)
Thread.sleep(50);
threadCount +=1;
PingIp p = new PingIp(ip);
p.start();
}
public void PingAll() throws Exception{
//首先得到本機的IP,得到網段
InetAddress host = InetAddress.getLocalHost();
String hostAddress = host.getHostAddress();
int k=0;
k=hostAddress.lastIndexOf(「.」);
String ss = hostAddress.substring(0,k+1);
for(int i=1;i <=255;i++){ //對所有區域網Ip
String iip=ss+i;
Ping(iip);
}
//等著所有Ping結束
while(threadCount>0)
Thread.sleep(50);
}
public static void main(String[] args) throws Exception{
Ip ip= new Ip();
ip.PingAll();
java.util.Set entries = ping.entrySet();
Iterator iter=entries.iterator();
String k;
while(iter.hasNext()){
Map.Entry entry=(Map.Entry)iter.next();
String key=(String)entry.getKey();
String value=(String)entry.getValue();
if(value.equals(「true」))
System.out.println(key+「-->」+value);
}
}
class PingIp extends Thread{
public String ip; // IP
public PingIp(String ip){
this.ip=ip;
}
public void run(){
try{
Process p= Runtime.getRuntime()。exec (「ping 」+ip+ 「 -w 300 -n 1」);
InputStreamReader ir = new InputStreamReader(p.getInputStream());
LineNumberReader input = new LineNumberReader (ir);
//讀取結果行
for (int i=1 ; i <7; i++)
input.readLine();
String line= input.readLine();
if (line.length() <17 || line.substring(8,17)。equals(「timed out」))
ping.put(ip,「false」);
else
ping.put(ip,「true」);
//線程結束
threadCount -= 1;
}catch (IOException e){}
}
}
}

J. java源代碼 在線急急急等,一個簡單的停車庫管理系統。1,有多個停車場,每一個停車場車位與收費不同。

可以使用Bai Hi聯系我你的任務
有機會可解決你遇到的任務
針對此題目
我們可以提供一套適合於學生水平的代碼
如果你有同樣的要求也可聯系我

ES:\\
交易提醒:預付定金是詐騙
交易提醒:勿輕信網路名中的聯系方式

閱讀全文

與java源代碼在線相關的資料

熱點內容
客戶端框架源碼 瀏覽:206
python自動辦公能幹嘛 瀏覽:873
程序員追愛 瀏覽:252
程序員邏輯故事 瀏覽:768
加密icsot23i2c 瀏覽:713
你們有什麼好的解壓軟體 瀏覽:607
常州空氣壓縮機廠家 瀏覽:241
安卓如何關閉app內彈出的更新提示 瀏覽:409
e4a寫的app怎麼裝蘋果手機 瀏覽:201
海立壓縮機海信系 瀏覽:210
社保如何在app上合並 瀏覽:220
小米加密照片後綴 瀏覽:236
我的世界網易手機怎麼創伺服器 瀏覽:978
載入單頁源碼 瀏覽:930
阿里雲伺服器seo 瀏覽:777
海洋斗什麼時候上線安卓 瀏覽:86
中行app如何查每日匯款限額 瀏覽:840
輸入伺服器sn是什麼意思 瀏覽:725
sha1演算法java 瀏覽:90
asp代碼壓縮 瀏覽:851