别踩白块儿java源代码的简单介绍
求一个JAVA的压缩程序源代码。
package com.io2.homework;
成都创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站制作、成都网站设计、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的黑河网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/*压缩文件夹*/
public class MyMultipleFileZip
{
private String currentZipFilePath = "F:/MyZip.zip";
private String sourceFilePath;
private ZipOutputStream zos;
private FileInputStream fis;
public MyMultipleFileZip(String sourceFilePath)
{
try
{
this.sourceFilePath = sourceFilePath;
zos = new ZipOutputStream(new FileOutputStream(currentZipFilePath));
//设定文件压缩级别
zos.setLevel(9);
} catch (FileNotFoundException e)
{
e.printStackTrace();
}
}
// 在当前条目中写入具体内容
public void writeToEntryZip(String filePath)
{
try
{
fis = new FileInputStream(filePath);
} catch (FileNotFoundException e1)
{
e1.printStackTrace();
}
byte[] buff = new byte[1024];
int len = 0;
try
{
while ((len = fis.read(buff)) != -1)
{
zos.write(buff, 0, len);
}
} catch (IOException e)
{
e.printStackTrace();
}finally
{
if (fis != null)
try
{
fis.close();
} catch (IOException e)
{
e.printStackTrace();
}
}
}
// 添加文件条目
public void addFileEntryZip(String fileName)
{
try
{
zos.putNextEntry(new ZipEntry(fileName));
} catch (IOException e)
{
e.printStackTrace();
}
}
public void addDirectoryEntryZip(String directoryName)
{
try
{
zos.putNextEntry(new ZipEntry(directoryName + "/"));
} catch (IOException e)
{
e.printStackTrace();
}
}
// 遍历文件夹
public void listMyDirectory(String filePath)
{
File f = new File(filePath);
File[] files = f.listFiles();
if(files!=null)
{
for (File currentFile : files)
{
// 设置条目名称(此步骤非常关键)
String entryName= currentFile.getAbsolutePath().split(":")[1].substring(1);
// 获取文件物理路径
String absolutePath = currentFile.getAbsolutePath();
if (currentFile.isDirectory())
{
addDirectoryEntryZip(entryName);
//进行递归调用
listMyDirectory(absolutePath);
}
else
{
addFileEntryZip(entryName);
writeToEntryZip(absolutePath);
}
}
}
}
// 主要流程
public void mainWorkFlow()
{
listMyDirectory(this.sourceFilePath);
if(zos!=null)
try
{
zos.close();
} catch (IOException e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
new MyMultipleFileZip("F:/fountainDirectory").mainWorkFlow();
}
}
java:哪里能看到JDK的源代码?
你安装JDK的目录下,有个src.zip文件,这个就是JDK源代码的java文件。
你可以解压来查看,但,最好是关联到IDE如 eclipse 中(不需解压),然后 CTRL + 点击就可以查看到源代码了。
如下图:
求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;
}
}
JAVA别踩白块怎么让一行除了黑块其他都是白块
import java.awt.Color;import java.awt.GridLayout;import javax.swing.JButton;import javax.swing.JFrame; public class MiGong extends JFrame{ private static final long serialVersionUID = 1L; private static final int ROW = 8; private static final int COL = 9; int[][] map = { {2,0,1,0,0,0,1,0}, {0,0,1,0,0,0,1,0}, {0,0,1,0,1,1,0,0}, {0,1,1,1,0,0,0,0}, {0,0,0,1,0,0,0,0}, {0,1,0,0,0,1,0,1}, {0,1,1,1,1,0,0,1}, {1,1,0,0,0,1,0,1}, {1,1,0,0,0,0,0,3} }; public static void main ( String args[] ) { new MiGong (); } public MiGong () { setTitle ("迷宫"); setLayout (new GridLayout (ROW, COL, 0, 0)); for ( int h = 0; h COL; h++ ) { for ( int g = 0; g ROW; g++ ) { switch (map[h][g]) { case 0: JButton p = new JButton (); p.setBackground (Color.red); add (p); break; case 1: JButton q = new JButton (); q.setBackground (Color.blue); add (q); break; case 2: JButton m = new JButton ("入口"); m.setBackground (Color.green); add (m); break; case 3: JButton n = new JButton ("出口"); n.setBackground (Color.green); add (n); break; } } } pack (); setLocationRelativeTo (null); setDefaultCloseOperation (EXIT_ON_CLOSE); setVisible (true); }}
求编写一个超级简单的Java的程序源代码
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class ConstructFrame extends JFrame
{
private static final long serialVersionUID = 1L;
String value1="",result,value2="";
int flag=0,fix=0,sum=1;
Boolean happy;
JTextField text=new JTextField(30);
int flagsum=0;
Container c=getContentPane();
JButton buttonx;
ConstructFrame()
{ super("计算器");
c.setLayout(null);
c.setBackground(Color.blue);
this.setSize(400, 400);
c.add(text);
text.setHorizontalAlignment(JTextField.RIGHT);
final JButton buttonx=new JButton("BackSpace");
c.add(buttonx);
buttonx.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
int count=0;
String temp;
if(flag==0)
{
count=value1.length();
if(count!=1)
temp=value1.substring(0, count-1);
else
temp="0";
value1=temp;
}
else
{
count=value2.length();
if(count!=1)
temp=value2.substring(0, count-1);
else
temp="0";
value2=temp;
}
text.setText(temp);
}
});
final JButton buttony=new JButton("CE");
c.add(buttony);
buttony.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
value1="";
value2="";
flag=0;
text.setText("0");
}
});
final JButton button1=new JButton("1");
c.add(button1);
button1.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+1;
temp=value1;
}
else
{
value2=value2+1;
temp=value2;
}
text.setText(temp);
}
});
final JButton button2=new JButton(" 2 ");
c.add(button2);
button2.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+2;
temp=value1;
}
else
{
value2=value2+2;
temp=value2;
}
text.setText(temp);
}
});
final JButton button3=new JButton("3");
c.add(button3);
button3.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+3;
temp=value1;
}
else
{
value2=value2+3;
temp=value2;
}
text.setText(temp);
}
});
final JButton button4=new JButton("4");
c.add(button4);
button4.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+4;
temp=value1;
}
else
{
value2=value2+4;
temp=value2;
}
text.setText(temp);
}
});
final JButton button5=new JButton("5");
c.add(button5);
button5.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+5;
temp=value1;
}
else
{
value2=value2+5;
temp=value2;
}
text.setText(temp);
}
});
final JButton button6=new JButton("6");
c.add(button6);
button6.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+6;
temp=value1;
}
else
{
value2=value2+6;
temp=value2;
}
text.setText(temp);
}
});
final JButton button7=new JButton("7");
c.add(button7);
button7.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+7;
temp=value1;
}
else
{
value2=value2+7;
temp=value2;
}
text.setText(temp);
}
});
final JButton button8=new JButton("8");
c.add(button8);
button8.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+8;
temp=value1;
}
else
{
value2=value2+8;
temp=value2;
}
text.setText(temp);
}
});
final JButton button9=new JButton("9");
c.add(button9);
button9.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+9;
temp=value1;
}
else
{
value2=value2+9;
temp=value2;
}
text.setText(temp);
}
});
final JButton button0=new JButton("0");
c.add(button0);
button0.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+0;
temp=value1;
}
else
{
value2=value2+0;
temp=value2;
}
text.setText(temp);
}
});
final JButton buttonadd=new JButton(" + ");
c.add(buttonadd);
buttonadd.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
flag=1;
fix=1;
flagsum=0;
}
});
final JButton buttonsubtract=new JButton(" - ");
c.add(buttonsubtract);
buttonsubtract.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
flag=1;
fix=2;
flagsum=0;
}
});
final JButton buttoncheng=new JButton(" * ");
c.add(buttoncheng);
buttoncheng.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
flag=1;
fix=3;
flagsum=0;
}
});
final JButton buttonchu=new JButton(" / ");
c.add(buttonchu);
buttonchu.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
flag=1;
flagsum=0;
fix=4;
}
});
final JButton buttonequal=new JButton(" = ");
c.add(buttonequal);
buttonequal.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
double temp1,temp2;
double temp=0;
flagsum=0;
temp1=Double.parseDouble(value1);
temp2=Double.parseDouble(value2);
flag=0;
switch(fix)
{
case 1: temp=temp1+temp2;break;
case 2: temp=temp1-temp2;break;
case 3: temp=temp1*temp2;break;
case 4: temp=temp1/temp2;break;
}
result=Double.valueOf(temp).toString();
value1=result;
value2="";
flag=1;
text.setText(result);
}
});
final JButton buttonpoint=new JButton(".");
c.add(buttonpoint);
buttonpoint.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{ if(flagsum==0)
{
String temp;
if(flag==0 )
{
value1=value1+".";
temp=value1;
}
else
{
value2=value2+".";
temp=value2;
}
flagsum=1;
text.setText(temp);
}
}
});
JButton buttonz=new JButton("Start");
c.add(buttonz);
buttonz.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{ if(sum%2==1)
{
happy=true;
text.setText("0.");
flag=0;
}
else
{
happy=false;
value1="";
value2="";
text.setText("");
}
text.setEnabled(happy);
button1.setEnabled(happy);
button2.setEnabled(happy);
button3.setEnabled(happy);
button4.setEnabled(happy);
button5.setEnabled(happy);
button6.setEnabled(happy);
button7.setEnabled(happy);
button8.setEnabled(happy);
button9.setEnabled(happy);
button0.setEnabled(happy);
buttonx.setEnabled(happy);
buttony.setEnabled(happy);
buttonadd.setEnabled(happy);
buttonsubtract.setEnabled(happy);
buttonpoint.setEnabled(happy);
buttonequal.setEnabled(happy);
buttoncheng.setEnabled(happy);
buttonchu.setEnabled(happy);
sum++;
}
});
button1.setEnabled(false);
button2.setEnabled(false);
button3.setEnabled(false);
button4.setEnabled(false);
button5.setEnabled(false);
button6.setEnabled(false);
button7.setEnabled(false);
button8.setEnabled(false);
button9.setEnabled(false);
button0.setEnabled(false);
buttonx.setEnabled(false);
buttony.setEnabled(false);
buttonadd.setEnabled(false);
buttonsubtract.setEnabled(false);
buttonpoint.setEnabled(false);
buttonequal.setEnabled(false);
buttoncheng.setEnabled(false);
buttonchu.setEnabled(false);
text.setEnabled(false);
text.setBounds(20, 20, 200, 40);
buttonx.setBounds(20, 60,100, 40);
buttony.setBounds(140, 60,100, 40);
buttonz.setBounds(260, 60,80, 40);
button1.setBounds(20, 120,60, 40);
button2.setBounds(100, 120,60, 40);
button3.setBounds(180, 120,60, 40);
buttonadd.setBounds(260, 120,60, 40);
button4.setBounds(20, 180,60, 40);
button5.setBounds(100, 180,60, 40);
button6.setBounds(180, 180,60, 40);
buttonsubtract.setBounds(260, 180,60, 40);
button7.setBounds(20, 240,60, 40);
button8.setBounds(100, 240,60, 40);
button9.setBounds(180, 240,60, 40);
buttoncheng.setBounds(260,240,60,40);
button0.setBounds(20, 300,60, 40);
buttonpoint.setBounds(100, 300, 60, 40);
buttonequal.setBounds(180,300,60, 40);
buttonchu.setBounds(260, 300,60, 40);
setVisible(true);
}
class MYMouseEvent extends MouseAdapter
{
public void mousePressed(MouseEvent e)
{
value1=e.toString();
text.setText(value1);
}
}
}
class Calutator
{
public static void main(String[] args)
{
new ConstructFrame();
}
}
你自己慢慢的看吧!
分享标题:别踩白块儿java源代码的简单介绍
URL分享:http://azwzsj.com/article/hdcdod.html