资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

java源代码边解释 JAVA的购物系统源代码

java简单记事本源代码 带解释

import java.awt.*;

成都创新互联始终坚持【策划先行,效果至上】的经营理念,通过多达10年累计超上千家客户的网站建设总结了一套系统有效的全网推广解决方案,现已广泛运用于各行各业的客户,其中包括:搅拌罐车等企业,备受客户赞赏。

import java.awt.event.*;

import javax.swing.*;

import javax.swing.border.*;

class test implements ActionListener

{

JFrame frame;

JButton b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26,b27,b28,b29,b30,b31;

JTextArea ta;

JPanel p1,p2,p3,p4;

JMenuBar mb;

JMenu m1,m2,m3;

JMenuItem mt1,mt2,mt3,mt4,mt5,mt6,mt7;

JRadioButton rb1,rb2;

ButtonGroup bg;

Double d1=0.0,d2=0.0,d3=0.0,d4=1.0,d5=1.0;

String s1="",s2="",s3="",s4="";

int a=0;

char c1;

int i=0;

public static void main(String[] args)

{

test that=new test();

that.go();

}

public void go()

{

frame=new JFrame("计算器");

Container cp= frame.getContentPane();

cp.setLayout(new FlowLayout());

b1=new JButton("7");b2=new JButton("8");b3=new JButton("9");b4=new JButton("/");b5=new JButton("1/x");b6=new JButton("sin");b7=new JButton("log");

b8=new JButton("4");b9=new JButton("5");b10=new JButton("6");b11=new JButton("*");b12=new JButton("x^y");b13=new JButton("cos");b14=new JButton("ln");

b15=new JButton("1");b16=new JButton("2");b17=new JButton("3");b18=new JButton("-");b19=new JButton(new ImageIcon("lanying.gif"));b20=new JButton("tan");b21=new JButton("x^3");

b22=new JButton("0");b23=new JButton("+/-");b24=new JButton(".");b25=new JButton("+");b26=new JButton("√x");b27=new JButton("cot");b28=new JButton("x^2");

b29=new JButton("Backspace");b30=new JButton("C");b31=new JButton("=");

mb=new JMenuBar();

m1=new JMenu("文件(F)");m2=new JMenu("编辑(E)");m3=new JMenu("帮助(H)");

mt1=new JMenuItem("清零");mt2=new JMenuItem("退出");mt3=new JMenuItem("复制");mt4=new JMenuItem("粘贴");mt5=new JMenuItem("版本");mt6=new JMenuItem("标准型");mt7=new JMenuItem("科学型");

ta=new JTextArea(1,30);

p1=new JPanel();p2=new JPanel();p3=new JPanel();p4=new JPanel();

rb1=new JRadioButton("科学型");rb2=new JRadioButton("标准型");

bg=new ButtonGroup();

b1.setForeground(Color.blue);b1.setBackground(Color.white);b2.setForeground(Color.blue);b2.setBackground(Color.white);

b3.setForeground(Color.blue);b3.setBackground(Color.white);b8.setForeground(Color.blue);b8.setBackground(Color.white);

b9.setForeground(Color.blue);b9.setBackground(Color.white);b10.setForeground(Color.blue);b10.setBackground(Color.white);

b15.setForeground(Color.blue);b15.setBackground(Color.white);b16.setForeground(Color.blue);b16.setBackground(Color.white);

b17.setForeground(Color.blue);b17.setBackground(Color.white);b22.setForeground(Color.blue);b22.setBackground(Color.white);

b23.setForeground(Color.blue);b23.setBackground(Color.white);b24.setForeground(Color.blue);b24.setBackground(Color.white);

b4.setForeground(Color.red);b4.setBackground(Color.white);b11.setForeground(Color.red);b11.setBackground(Color.white);

b18.setForeground(Color.red);b18.setBackground(Color.white);b25.setForeground(Color.red);b25.setBackground(Color.white);

b5.setForeground(Color.blue);b5.setBackground(Color.white);b6.setForeground(Color.blue);b6.setBackground(Color.white);

b7.setForeground(Color.blue);b7.setBackground(Color.white);b12.setForeground(Color.blue);b12.setBackground(Color.white);

b13.setForeground(Color.blue);b13.setBackground(Color.white);b14.setForeground(Color.blue);b14.setBackground(Color.white);

b19.setForeground(Color.blue);b19.setBackground(Color.white);b20.setForeground(Color.blue);b20.setBackground(Color.white);

b21.setForeground(Color.blue);b21.setBackground(Color.white);b26.setForeground(Color.blue);b26.setBackground(Color.white);

b27.setForeground(Color.blue);b27.setBackground(Color.white);b28.setForeground(Color.blue);b28.setBackground(Color.white);

b29.setForeground(Color.red);b29.setBackground(Color.white);b30.setForeground(Color.red);b30.setBackground(Color.white);

b31.setForeground(Color.red);b31.setBackground(Color.white);

bg.add(rb1);bg.add(rb2);

p1.setBackground(Color.yellow);

cp.setBackground(Color.CYAN);

m1.setMnemonic(KeyEvent.VK_F);m2.setMnemonic(KeyEvent.VK_E);m3.setMnemonic(KeyEvent.VK_H);

m1.add(mt6);m1.add(mt7);m1.addSeparator();m1.add(mt1);m1.addSeparator();m1.add(mt2);m2.add(mt3);m2.addSeparator();m2.add(mt4);m3.add(mt5);

mb.add(m1);mb.add(m2);mb.add(m3);

frame.setJMenuBar(mb);

p2.setLayout(new GridLayout(4,7));

p3.setLayout(new GridLayout(1,3));

ta.setEditable(false);

p1.add(ta);

p2.add(b1);p2.add(b2);p2.add(b3);p2.add(b4);p2.add(b5);p2.add(b6);p2.add(b7);

p2.add(b8);p2.add(b9);p2.add(b10);p2.add(b11);p2.add(b12);p2.add(b13);p2.add(b14);

p2.add(b15);p2.add(b16);p2.add(b17);p2.add(b18);p2.add(b19);p2.add(b20);p2.add(b21);

p2.add(b22);p2.add(b23);p2.add(b24);p2.add(b25);p2.add(b26);p2.add(b27);p2.add(b28);

p3.add(b29);p3.add(b30);p3.add(b31);

Border etched=BorderFactory.createEtchedBorder();

Border border=BorderFactory.createTitledBorder(etched,"计算类型");

p4.add(rb1);p4.add(rb2);

p4.setBorder(border);

b2.setActionCommand("8");

b2.addActionListener(this);

cp.add(p1);cp.add(p4);cp.add(p2);cp.add(p3);

frame.setSize(400,330);

frame.setVisible(true);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

b1.setActionCommand("7");

b1.addActionListener(this);

b2.setActionCommand("8");

b2.addActionListener(this);

b3.setActionCommand("9");

b3.addActionListener(this);

b4.setActionCommand("/");

b4.addActionListener(this);

b5.setActionCommand("1/x");

b5.addActionListener(this);

b6.setActionCommand("sin");

b6.addActionListener(this);

b7.setActionCommand("log");

b7.addActionListener(this);

b8.setActionCommand("4");

b8.addActionListener(this);

b9.setActionCommand("5");

b9.addActionListener(this);

b10.setActionCommand("6");

b10.addActionListener(this);

b11.setActionCommand("*");

b11.addActionListener(this);

b12.setActionCommand("x^y");

b12.addActionListener(this);

b13.setActionCommand("cos");

b13.addActionListener(this);

b14.setActionCommand("ln");

b14.addActionListener(this);

b15.setActionCommand("1");

b15.addActionListener(this);

b16.setActionCommand("2");

b16.addActionListener(this);

b17.setActionCommand("3");

b17.addActionListener(this);

b18.setActionCommand("-");

b18.addActionListener(this);

b19.setActionCommand("x!");

b19.addActionListener(this);

b20.setActionCommand("tan");

b20.addActionListener(this);

b21.setActionCommand("x^3");

b21.addActionListener(this);

b22.setActionCommand("0");

b22.addActionListener(this);

b23.setActionCommand("+/-");

b23.addActionListener(this);

b24.setActionCommand(".");

b24.addActionListener(this);

b25.setActionCommand("+");

b25.addActionListener(this);

b26.setActionCommand("√x");

b26.addActionListener(this);

b27.setActionCommand("cot");

b27.addActionListener(this);

b28.setActionCommand("x^2");

b28.addActionListener(this);

b29.setActionCommand("Backspace");

b29.addActionListener(this);

b30.setActionCommand("C");

b30.addActionListener(this);

b31.setActionCommand("=");

b31.addActionListener(this);

rb1.setActionCommand("kxx");

rb1.addActionListener(this);

rb2.setActionCommand("bzx");

rb2.addActionListener(this);

}

public void actionPerformed(ActionEvent e) //throws Exception

{

if (e.getActionCommand()=="bzx")

{

b5.setEnabled(false);b6.setEnabled(false);b7.setEnabled(false);

b12.setEnabled(false);b13.setEnabled(false);b14.setEnabled(false);

b19.setEnabled(false);b20.setEnabled(false);b21.setEnabled(false);

b26.setEnabled(false);b27.setEnabled(false);b28.setEnabled(false);

}

if (e.getActionCommand()=="kxx")

{

b5.setEnabled(true);b6.setEnabled(true);b7.setEnabled(true);

b12.setEnabled(true);b13.setEnabled(true);b14.setEnabled(true);

b19.setEnabled(true);b20.setEnabled(true);b21.setEnabled(true);

b26.setEnabled(true);b27.setEnabled(true);b28.setEnabled(true);

}

if (e.getActionCommand()=="1")

{

ta.append("1");

}

if (e.getActionCommand()=="2")

{

ta.append("2");

}

if (e.getActionCommand()=="3")

{

ta.append("3");

}

if (e.getActionCommand()=="4")

{

ta.append("4");

}

if (e.getActionCommand()=="5")

{

ta.append("5");

}

if (e.getActionCommand()=="6")

{

ta.append("6");

}

if (e.getActionCommand()=="7")

{

ta.append("7");

}

if (e.getActionCommand()=="8")

{

ta.append("8");

}

if (e.getActionCommand()=="9")

{

ta.append("9");

}

if (e.getActionCommand()=="0")

{

ta.append("0");

}

if (e.getActionCommand()=="+")

{

s1=ta.getText();

d1 = Double.parseDouble(s1);

ta.setText("");

i=1;

}

if (e.getActionCommand()=="-")

{

s1=ta.getText();

d1 = Double.parseDouble(s1);

ta.setText("");

i=2;

}

if (e.getActionCommand()=="*")

{

s1=ta.getText();

d1 = Double.parseDouble(s1);

ta.setText("");

i=3;

}

if (e.getActionCommand()=="/")

{

s1=ta.getText();

d1 = Double.parseDouble(s1);

ta.setText("");

i=4;

}

if (e.getActionCommand()=="=")

{

s2=ta.getText();

d2=Double.parseDouble(s2);

if(i==1)

{

d3=d1+d2;

ta.setText( d3.toString());

}

if(i==2)

{

d3=d1-d2;

ta.setText( d3.toString());

}

if(i==3)

{

d3=d1*d2;

ta.setText( d3.toString());

}

if(i==4)

{

if(d2==0.0)

ta.setText("ERROR");

else

{

d3=d1/d2;

ta.setText( d3.toString());

}

}

if (i==5)

{

s2=ta.getText();

d2 = Double.parseDouble(s2);

for (int l=1;l=d2 ; l++)

{

d5=d5*d1;

}

ta.setText( d5.toString());

}

}

if (e.getActionCommand()=="C")

{

ta.setText("");

d4=1.0;

d5=1.0;

}

/*if (e.getActionCommand()=="Backspace")

{

s3=ta.getText();

a=s3.length();

//ta.cut(ta.select(a-1,a));

s4=ta.getText(1,3);

ta.setText(s4);

}

*/

if (e.getActionCommand()=="1/x")

{

s1=ta.getText();

d1 = Double.parseDouble(s1);

d2=1/d1;

ta.setText( d2.toString());

}

if (e.getActionCommand()==".")

{

ta.append(".");

}

if (e.getActionCommand()=="+/-")

{

s1=ta.getText();

d1 = Double.parseDouble(s1);

d2=0-d1;

ta.setText( d2.toString());

}

if (e.getActionCommand()=="x^2")

{

s1=ta.getText();

d1 = Double.parseDouble(s1);

d2=d1*d1;

ta.setText( d2.toString());

}

if (e.getActionCommand()=="x^3")

{

s1=ta.getText();

d1 = Double.parseDouble(s1);

d2=d1*d1*d1;

ta.setText( d2.toString());

}

if (e.getActionCommand()=="x^y")

{

s1=ta.getText();

d1 = Double.parseDouble(s1);

ta.setText("");

i=5;

// d2=d1*d1*d1;

// ta.setText( d2.toString());

}

if (e.getActionCommand()=="√x")

{

s1=ta.getText();

d1 = Double.parseDouble(s1);

d2=Math.sqrt(d1);

ta.setText( d2.toString());

}

if (e.getActionCommand()=="x!")

{

s1=ta.getText();

d1 = Double.parseDouble(s1);

if (d10)

{

ta.setText( "error");

}

else if (d1==0)

{

ta.setText( "0.0");

}

else {

for (int k=1;k=d1 ;k++ )

d4=d4*k;

ta.setText( d4.toString());

}

}

if (e.getActionCommand()=="sin")

{

s1=ta.getText();

d1 = Double.parseDouble(s1);

d2=Math.sin(3.1415926*d1/180);

ta.setText( d2.toString());

}

}

}

急!!对一个JAVA源代码加注释~~~

import java.awt.*; // 导入相应的awt工具组件

import java.awt.event.*;// 导入awt工具组件的事件类

/**

* 作用:calc类用于演示加法计算器的功能p

* @author 网络用户

* @version 1.0 2009-6-3

* @since JDK 1.5

*/

class calc extends WindowAdapter implements ActionListener

{

//以下声明相关变量

Frame f; //窗口

// Button b0,b1,b2,b3,b4,b5,b6,b7,b8,b9;

Button b[] = new Button[10]; //10个按钮,分别对应数字0到9

Button be, badd, bc; //bc为=,badd为+,bc为归0按钮

TextField answer; //文本框answer用于显示相加的结果

Panel p; //面板

String s = ""; //临时变量,用于记住被加数

int t1, t2; //t1,t2分别表示被加数,加数

/**

* 作用:main方法为程序运行的入口

* @param args

*/

public static void main( String args[] )

{

calc cg = new calc(); //创建一个calc类的对象

cg.go(); //调用go方法,显示加法器界面,并完成加法功能

}

/**

* 作用:go()方法用于显示加法器界面,并完成加法功能

*/

public void go()

{

p = new Panel(); //创建面板的对象,10个按钮将在此面板对象上添加和显示

answer = new TextField("0", 15); //设置文本框的默认值为0,文本框的长度15个字符

b[0] = new Button("0"); //以下就是那10个按钮,按钮上的文本就是0到9的数字

b[1] = new Button("1");

b[2] = new Button("2");

b[3] = new Button("3");

b[4] = new Button("4");

b[5] = new Button("5");

b[6] = new Button("6");

b[7] = new Button("7");

b[8] = new Button("8");

b[9] = new Button("9");

be = new Button("="); //等号

badd = new Button("+"); //加号

bc = new Button("C"); //归0按钮

p.setLayout(new GridLayout(4, 3)); //将面板设置为4行3列,即12个格子,刚好可以存放地10个数字按钮另加+号按钮和=号按钮,共12个按钮

p.add(b[7]); //添加10个数字按钮到面板上

p.add(b[8]);

p.add(b[9]);

p.add(b[4]);

p.add(b[5]);

p.add(b[6]);

p.add(b[1]);

p.add(b[2]);

p.add(b[3]);

p.add(b[0]);

for( int i = 0; i b.length; i++ )

b[i].addActionListener(this); //为10个数字按钮添加事件监听器,以用于实现加法功能

p.add(be); //添加=号按钮到面板上

p.add(badd); //添加+号按钮到面板上

be.addActionListener(this); //为=号按钮添加事件监听器,用于实现加法功能

badd.addActionListener(this); //为+号按钮添加事件监听器,用于实现加法功能

f = new Frame("calc"); //创建一个Frame对象(窗口),窗口的标题就是calc

f.setSize(300, 300); //窗口的大小为300*300像素

f.add(answer, "North"); //将文本框设置在窗口的北部(上),窗口的默认布局为BorderLayout,即东西南北中5个位置

f.add(p, "Center"); //将面板设置在窗口的中部(中)

f.add(bc, "South"); //将归0按钮设置在窗口的南部(下)

bc.addActionListener(this); //为归0按钮添加事件监听器,用于将计算结果归0

f.addWindowListener(this); //为窗口添加事件监听器,用于实现关闭窗口的功能

f.pack(); //此方法用于窗口到合适的大小

f.setVisible(true); //显示窗口,为false时将不会显示窗口

}

//在10个数字按钮和3个功能按钮上单击,将触发此方法

public void actionPerformed( ActionEvent e )

{

if( e.getSource() == bc )

{//单击了归0按钮,设置为默认值

s = "";

t1 = 0; //被加数设0

t2 = 0; //加数设0

answer.setText("0"); //文本框设为0

} else if( e.getSource() == badd )

{//单击+号按钮

t1 = Integer.parseInt(s); //记下被加数

s = "";

} else if( e.getSource() == be )

{//单击=号按钮

t2 = Integer.parseInt(s); //记下加数

t2 = t2 + t1; //把被加数与加数相加

answer.setText((new Integer(t2)).toString()); //在文本框上显示相加的结果

} else

{//单击0到9之间的任意一个数字按钮

for( int i = 0; i b.length; i++ )

if( e.getSource() == b[i] )

{

System.out.println("1");

s = s + b[i].getActionCommand(); //获得被单击按钮上的数字

answer.setText(s); //在文本框上显示连续单击那几个数字

}

}

}

//关闭窗口,触发此方法

public void windowClosing( WindowEvent ev )

{

System.exit(0); //退出程序

}

}

为什么说java程序是边解释边执行的

java应用程序的开发周期包括编译、下载、解释和执行几个部分。java编译程序将java源程序翻译为jvm可执行代码--字节码。这一编译过程同c/c++的编译有些不同。当c编译器编译生成一个对象的代码时,该代码是为在某一特定硬件平台运行而产生的。因此,在编译过程中,编译程序通过查表将所有对符号的引用转换为特定的内存偏移量,以保证程序运行。java编译器却不将对变量和方法的引用编译为数值引用,也不确定程序执行过程中的内存布局,而是将这些符号引用信息保留在字节码中,由解释器在运行过程中创立内存布局,然后再通过查表来确定一个方法所在的地址。这样就有效的保证了java的可移植性和安全性。运行jvm字节码的工作是由解释器(java命令)来完成的。解释执行过程分三部进行:代码的装入、代码的校验和代码的执行。装入代码的工作由"类装载器"(classloader)完成。类装载器负责装入运行一个程序需要的所有代码,这也包括程序代码中的类所继承的类和被其调用的类。当类装载器装入一个类时,该类被放在自己的名字空间中。除了通过符号引用自己名字空间以外的类,类之间没有其他办法可以影响其他类。在本台计算机上的所有类都在同一地址空间内,而所有从外部引进的类,都有一个自己独立的名字空间。这使得本地类通过共享相同的名字空间获得较高的运行效率,同时又保证它们与从外部引进的类不会相互影响。当装入了运行程序需要的所有类后,解释器便可确定整个可执行程序的内存布局。解释器为符号引用同特定的地址空间建立对应关系及查询表。通过在这一阶段确定代码的内存布局,java很好地解决了由超类改变而使子类崩溃的问题,同时也防止了代码对地址的非法访问。随后,被装入的代码由字节码校验器进行检查。校验器可发现操作数栈溢出,非法数据类型转化等多种错误。通过校验后,代码便开始执行了。java字节码的执行有两种方式:1.即时编译方式:解释器先将字节码编译成机器码,然后再执行该机器码。2.解释执行方式:解释器通过每次解释并执行一小段代码来完成java字节码程序的所有操作。通常采用的是第二种方法。由于jvm规格描述具有足够的灵活性,这使得将字节码翻译为机器代码的工作具有较高的效率。对于那些对运行速度要求较高的应用程序,解释器可将java字节码即时编译为机器码,从而很好地保证了java代码的可移植性和高性能。java宣称的一处编写随处运行就是由jvm来完成.在sun的网站上你可以下载到基于各种cpu和各种操作系统的jdk和jre的下载版本,只要寻找到合适你使用的版本,以前你所编写的class文件copy到其他的机器上可以直接运行JAVA,不需要再编译.其实j2se是一种规范,这种规范约定了其跨平台执行的所需要关注很多实现,基于该规范开发人员可以任意编写自己的java代码而不需要关心这个程序可能在其他的机器和cpu上无法很好运行问题.其实你也可以看到ibm和weblogic都有基于j2se规范的自己实现的java虚拟机.而且sun所宣称的不需要编译而可以直接用class文件在各个jvm上直接运行并不精确,博格曾经遇到过用sunjre开发的class文件在ibmjre上有一个自动转换的过程,然后这个类可以很好的工作了,幸好这种情况是自动完成,否则我们又要陷入类似于各种cc++的版本编译器兼容性问题中.以下下摘录了几个主要的概念:jvmjavavirtualmachine(java虚拟机),它是一个虚构出来的计算机,是通过在实际的计算机上仿真模拟各种计算机功能来实现的。java虚拟机有自己完善的硬件架构,如处理器、堆栈、寄存器等,还具有相应的指令系统。jvm屏蔽了与具体操作系统平台相关的信息,使得java程序只需生成在java虚拟机上运行的目标代码(字节码),就可以在多种平台上不加修改地运行。java虚拟机在执行字节码时,实际上最终还是把字节码解释成具体平台上的机器指令执行。jrejavaruntimeenvironment(java运行环境),运行java程序所必须的环境的集合,包含jvm标准实现及java核心类库。jsdkjavasoftwaredevelopmentkit,和jdk以及j2se等同。jdkjavadevelopmentkit(java开发工具包):包括运行环境、编译工具及其它工具、源代码等,基本上和j2se等同。j2mejava2microedition(java2精简版)api规格基于j2se,但是被修改为可以适合某种产品的单一要求。j2me使java程序可以很方便的应用于电话卡、寻呼机等小型设备,它包括两种类型的组件,即配置(configuration)和描述(profile)。j2eejava2enterpriseedition(java2企业版),使用java进行企业开发的一套扩展标准,必须基于j2se,提供一个基于组件设计、开发、集合、展开企业应用的途径。j2ee平台提供了多层、分布式的应用模型,重新利用组件的能力,统一安全的模式以及灵活的处理控制能力。j2ee包括ejb,jta,jdbc,jca,jmx,jndi,jms,javamail,servlet,jsp等规范。j2sejava2standardedition(java2标准版),用来开发java程序的基础,包括编译器、小工具、运行环境,sun发布的标准版本中还包括核心类库的所有源代码。

求将java源代码加详细的注释,程序已给出

package com.the2cities.servlet;

import java.awt.Color;

import java.awt.Graphics;

import java.awt.Graphics2D;

import java.awt.Rectangle;

import java.awt.TexturePaint;

import java.awt.event.KeyEvent;

import java.awt.event.KeyListener;

import java.awt.geom.GeneralPath;

import java.awt.geom.RoundRectangle2D;

import java.awt.image.BufferedImage;

import javax.swing.JFrame;

public class pentagram extends JFrame implements KeyListener {

int x=150,y=150;

public pentagram() {

//初始化

setSize(400, 400);//设置大小

setVisible(true);//显示

this.addKeyListener(this);//按键的监听事件

}

public void keyPressed(KeyEvent e) {

//方向键

if(e.getKeyCode()==37)

{

x-=10; //向左边移动10像素

repaint(); //刷新

}

if(e.getKeyCode()==38)

{

y-=10; //向上边移动10像素

repaint();//刷新

}

if(e.getKeyCode()==39)

{

x+=10;//向右边移动10像素

repaint();//刷新

}

if(e.getKeyCode()==40)

{

y+=10;//向下边移动10像素

repaint();//刷新

}

}

public void keyReleased(KeyEvent e) {

}

public void keyTyped(KeyEvent e) {

}

public void paint(Graphics g) {//重写了JFrame的paint,在上面刷新的方法可以调用到这个方法。

super.paint(g);

//A

int xPoint[]={55,67,109,73,83,55,27,37,1,43};

int yPoint[]={0,36,36,54,96,72,96,54,36,36};

Graphics2D g2d=(Graphics2D)g;//整个窗口就是一个画板

GeneralPath star=new GeneralPath();

star.moveTo(xPoint[0], yPoint[0]);

for(int count=1;countxPoint.length;count++)

{

star.lineTo(xPoint[count], yPoint[count]);

}

star.closePath();

//B

//A到B是画出一个星星。

g2d.translate(x, y);//设置星星位置,x,y就是上面,按方向键产生的数字。

g2d.setColor(new Color((int)(Math.random()*256),(int)(Math.random()*256),(int)(Math.random()*256)));//随机设置颜色

g2d.fill(star);//把星星放到画板里去。

}

public static void main(String[] arge) {

pentagram s = new pentagram();

s.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

}


文章标题:java源代码边解释 JAVA的购物系统源代码
网页URL:http://cdkjz.cn/article/dooeceh.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220