资讯

精准传达 • 有效沟通

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

java源代码书写 mainclassjava源代码

JAVA源代码的编写

import java.util.Date;

创新互联是一家专业提供廉江企业网站建设,专注与成都做网站、网站设计、外贸营销网站建设HTML5、小程序制作等业务。10年已为廉江众多企业、政府机构等服务。创新互联专业的建站公司优惠进行中。

public class Travel{

TravelLeg mid = new TravelLeg();

private String start;

private String end;

private Date startTime;

private Date endTime;

private String travelId;

private String comment;

public void add(TravelLeg mid){

this.start = mid.getStart();

this.mid = mid;

this.end = mid.getEnd();

}

public boolean check_date(){

if(!mid.getStartTime().before(mid.getEndTime())){

System.out.println("时间错误");

return false;

}else return true;

}

public void print(){

System.out.println("开始地点:"+this.start+"中间地点"+this.mid.getEnd()+this.end);

}

}

用Java编写简易记事本源代码

importjava.awt.BorderLayout;importjava.awt.Container;importjava.awt.Font;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.event.InputEvent;importjava.awt.event.KeyAdapter;importjava.awt.event.KeyEvent;importjava.awt.event.MouseAdapter;importjava.awt.event.MouseEvent;importjava.awt.event.WindowAdapter;importjava.awt.event.WindowEvent;importjava.io.BufferedReader;importjava.io.BufferedWriter;importjava.io.File;importjava.io.FileReader;importjava.io.FileWriter;importjava.io.IOException;importjavax.swing.BorderFactory;importjavax.swing.JFileChooser;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JMenu;importjavax.swing.JMenuBar;importjavax.swing.JMenuItem;importjavax.swing.JOptionPane;importjavax.swing.JPopupMenu;importjavax.swing.JScrollPane;importjavax.swing.JTextArea;importjavax.swing.KeyStroke;importjavax.swing.ScrollPaneConstants;importjavax.swing.SwingConstants;publicclassJNotePadUIextendsJFrame{privateJMenuItemmenuOpen;privateJMenuItemmenuSave;privateJMenuItemmenuSaveAs;privateJMenuItemmenuClose;privateJMenueditMenu;privateJMenuItemmenuCut;privateJMenuItemmenuCopy;privateJMenuItemmenuPaste;privateJMenuItemmenuAbout;privateJTextAreatextArea;privateJLabelstateBar;privateJFileChooserfileChooser;privateJPopupMenupopUpMenu;publicJNotePadUI(){super("新建文本文件");setUpUIComponent();setUpEventListener();setVisible(true);}privatevoidsetUpUIComponent(){setSize(640,480);//菜单栏JMenuBarmenuBar=newJMenuBar();//设置「文件」菜单JMenufileMenu=newJMenu("文件");menuOpen=newJMenuItem("打开");//快捷键设置menuOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,InputEvent.CTRL_MASK));menuSave=newJMenuItem("保存");menuSave.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,InputEvent.CTRL_MASK));menuSaveAs=newJMenuItem("另存为");menuClose=newJMenuItem("关闭");menuClose.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,InputEvent.CTRL_MASK));fileMenu.add(menuOpen);fileMenu.addSeparator();//分隔线fileMenu.add(menuSave);fileMenu.add(menuSaveAs);fileMenu.addSeparator();//分隔线fileMenu.add(menuClose);//设置「编辑」菜单JMenueditMenu=newJMenu("编辑");menuCut=newJMenuItem("剪切");menuCut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,InputEvent.CTRL_MASK));menuCopy=newJMenuItem("复制");menuCopy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,InputEvent.CTRL_MASK));menuPaste=newJMenuItem("粘贴");menuPaste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,InputEvent.CTRL_MASK));editMenu.add(menuCut);editMenu.add(menuCopy);editMenu.add(menuPaste);//设置「关于」菜单JMenuaboutMenu=newJMenu("关于");menuAbout=newJMenuItem("关于JNotePad");aboutMenu.add(menuAbout);menuBar.add(fileMenu);menuBar.add(editMenu);menuBar.add(aboutMenu);setJMenuBar(menuBar);//文字编辑区域textArea=newJTextArea();textArea.setFont(newFont("宋体",Font.PLAIN,16));textArea.setLineWrap(true);JScrollPanepanel=newJScrollPane(textArea,ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);ContainercontentPane=getContentPane();contentPane.add(panel,BorderLayout.CENTER);//状态栏stateBar=newJLabel("未修改");stateBar.setHorizontalAlignment(SwingConstants.LEFT);stateBar.setBorder(BorderFactory.createEtchedBorder());contentPane.add(stateBar,BorderLayout.SOUTH);popUpMenu=editMenu.getPopupMenu();fileChooser=newJFileChooser();}privatevoidsetUpEventListener(){//按下窗口关闭钮事件处理addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){closeFile();}});//菜单-打开menuOpen.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){openFile();}});//菜单-保存menuSave.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){saveFile();}});//菜单-另存为menuSaveAs.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){saveFileAs();}});//菜单-关闭文件menuClose.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){closeFile();}});//菜单-剪切menuCut.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){cut();}});//菜单-复制menuCopy.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){copy();}});//菜单-粘贴menuPaste.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){paste();}});//菜单-关于menuAbout.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){//显示对话框JOptionPane.showOptionDialog(null,"程序名称:\nJNotePad\n"+"程序设计:\n\n"+"简介:\n一个简单的文字编辑器\n"+"可作为验收Java的实现对象\n"+"欢迎网友下载研究交流\n\n"+"/","关于JNotePad",JOptionPane.DEFAULT_OPTION,JOptionPane.INFORMATION_MESSAGE,null,null,null);}});//编辑区键盘事件textArea.addKeyListener(newKeyAdapter(){publicvoidkeyTyped(KeyEvente){processTextArea();}});//编辑区鼠标事件textArea.addMouseListener(newMouseAdapter(){publicvoidmouseReleased(MouseEvente){if(e.getButton()==MouseEvent.BUTTON3)popUpMenu.show(editMenu,e.getX(),e.getY());}publicvoidmouseClicked(MouseEvente){if(e.getButton()==MouseEvent.BUTTON1)popUpMenu.setVisible(false);}});}privatevoidopenFile(){if(isCurrentFileSaved()){//文件是否为保存状态open();//打开}else{//显示对话框intoption=JOptionPane.showConfirmDialog(null,"文件已修改,是否保存?","保存文件?",JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE,null);switch(option){//确认文件保存caseJOptionPane.YES_OPTION:saveFile();//保存文件break;//放弃文件保存caseJOptionPane.NO_OPTION:open();break;}}}privatebooleanisCurrentFileSaved(){if(stateBar.getText().equals("未修改")){returnfalse;}else{returntrue;}}privatevoidopen(){//fileChooser是JFileChooser的实例//显示文件选取的对话框intoption=fileChooser.showDialog(null,null);//使用者按下确认键if(option==JFileChooser.APPROVE_OPTION){try{//开启选取的文件BufferedReaderbuf=newBufferedReader(newFileReader(fileChooser.getSelectedFile()));//设定文件标题setTitle(fileChooser.getSelectedFile().toString());//清除前一次文件textArea.setText("");//设定状态栏stateBar.setText("未修改");//取得系统相依的换行字符StringlineSeparator=System.getProperty("line.separator");//读取文件并附加至文字编辑区Stringtext;while((text=buf.readLine())!=null){textArea.append(text);textArea.append(lineSeparator);}buf.close();}catch(IOExceptione){JOptionPane.showMessageDialog(null,e.toString(),"开启文件失败",JOptionPane.ERROR_MESSAGE);}}}privatevoidsaveFile(){//从标题栏取得文件名称Filefile=newFile(getTitle());//若指定的文件不存在if(!file.exists()){//执行另存为saveFileAs();}else{try{//开启指定的文件BufferedWriterbuf=newBufferedWriter(newFileWriter(file));//将文字编辑区的文字写入文件buf.write(textArea.getText());buf.close();//设定状态栏为未修改stateBar.setText("未修改");}catch(IOExceptione){JOptionPane.showMessageDialog(null,e.toString(),"写入文件失败",JOptionPane.ERROR_MESSAGE);}}}privatevoidsaveFileAs(){//显示文件对话框intoption=fileChooser.showSaveDialog(null);//如果确认选取文件if(option==JFileChooser.APPROVE_OPTION){//取得选择的文件Filefile=fileChooser.getSelectedFile();//在标题栏上设定文件名称setTitle(file.toString());try{//建立文件file.createNewFile();//进行文件保存saveFile();}catch(IOExceptione){JOptionPane.showMessageDialog(null,e.toString(),"无法建立新文件",JOptionPane.ERROR_MESSAGE);}}}privatevoidcloseFile(){//是否已保存文件if(isCurrentFileSaved()){//释放窗口资源,而后关闭程序dispose();}else{intoption=JOptionPane.showConfirmDialog(null,"文件已修改,是否保存?","保存文件?",JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE,null);switch(option){caseJOptionPane.YES_OPTION:saveFile();break;caseJOptionPane.NO_OPTION:dispose();}}}privatevoidcut(){textArea.cut();stateBar.setText("已修改");popUpMenu.setVisible(false);}privatevoidcopy(){textArea.copy();popUpMenu.setVisible(false);}privatevoidpaste(){textArea.paste();stateBar.setText("已修改");popUpMenu.setVisible(false);}privatevoidprocessTextArea(){stateBar.setText("已修改");}publicstaticvoidmain(String[]args){newJNotePadUI();}}

java源程序什么格式

Java程序使用下列文件后缀:

文件类别

文件后缀

Java源文件

.java

Java字节码文件

.class

2.2 常用文件名(CommonFile Names)

常用的文件名包括:

文件名 

用途

GNUmakefile    

makefiles的首选文件名。我们采用gnumake来创建(build)软件。

README        

概述特定目录下所含内容的文件的首选文件名。

3. 文件组织(FileOrgnization)

一个文件由被空行分割而成的段落以及标识每个段落的可选注释共同组成。超过2000行的程序难以阅读,应该尽量避免。“Java源文件范例”提供了一个页面布局合理的Java程序范例。

JAVA中登录窗口设计,源代码该怎么写?

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class Test_Login extends javax.swing.JFrame {

private JPanel jPanel1;

private JButton bntLogin;

private JButton bntCannel;

private JPasswordField pwd;

private JTextField username;

private JLabel jLabel2;

private JLabel jLabel1;

public static void main(String[] args) {

Test_Login inst = new Test_Login();

inst.setLocationRelativeTo(null);

inst.setVisible(true);

}

public Test_Login() {

super();

initGUI();

}

private void initGUI() {

try {

setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

{

jPanel1 = new JPanel();

getContentPane().add(jPanel1, BorderLayout.CENTER);

jPanel1.setLayout(null);

{

jLabel1 = new JLabel();

jPanel1.add(jLabel1);

jLabel1.setText("用户名");

jLabel1.setBounds(45, 30, 75, 25);

}

{

jLabel2 = new JLabel();

jPanel1.add(jLabel2);

jLabel2.setText("密码");

jLabel2.setBounds(45, 75, 55, 15);

}

{

username = new JTextField();

jPanel1.add(username);

username.setBounds(100, 30, 140, 25);

}

{

pwd = new JPasswordField();

jPanel1.add(pwd);

pwd.setBounds(100, 70, 140, 25);

}

{

bntLogin = new JButton();

jPanel1.add(bntLogin);

bntLogin.setText("登陆");

bntLogin.setBounds(40, 120, 60, 30);

bntLogin.addMouseListener(new MouseAdapter() {

public void mouseClicked(MouseEvent e) {

if (username.getText().equals("lisong")

pwd.getText().equals("lisong")) {

JOptionPane.showMessageDialog(Test_Login.this,

"登录成功");

} else {

JOptionPane.showMessageDialog(Test_Login.this,

"登录失败");

}

}

});

bntCannel = new JButton();

jPanel1.add(bntCannel);

bntCannel.setText("取消");

bntCannel.setBounds(180, 120, 60, 30);

bntCannel.addMouseListener(new MouseAdapter() {

public void mouseClicked(MouseEvent e) {

System.exit(0);

}

});

}

}

pack();

setSize(300, 215);

} catch (Exception e) {

e.printStackTrace();

}

}

}

求编写一个超级简单的Java的程序源代码

class Stack_Float

{

float nums[];

int top;

Stack_Float()

{

nums = new float[50];

top = -1;

}

boolean IsEmpty()

{

if(top == -1)

return true;

else

return false;

}

float Pop_Stack()

{

if(top==-1)

{

return 0;

}

top--;

return nums[top + 1];

}

float GetTop()

{

return nums[top];

}

void Push_Stack(float num)

{

if(top == 49)

return;

top++;

nums[top] = num;

}

}

/*****************************************************************************/

class Stack_Char

{

char str[];

int top;

Stack_Char()

{

str = new char[50];

top = -1;

}

boolean IsEmpty()

{

if(top==-1)

return true;

else

return false;

}

void Push_Stack(char ch)

{

if(top == 49)

return;

top++;

str[top] = ch;

}

char Pop_Stack()

{

if(top == -1)

return '\0';

top--;

return str[top + 1];

}

char GetTop()

{

if(top == -1)

{

System.out.print("error");

System.exit(0);

}

return str[top];

}

}

/*****************************************************************************/

public class jisuanqi extends javax.swing.JFrame

{

String show = "";

public jisuanqi()

{

initComponents();

}

char[] TranSmit(char str[])

{

char houzhui[] = new char[50]; //存放后缀表达式的字符串

int i = 0,j = 0;

char c = str[i];

Stack_Char s = new Stack_Char(); //存放运算符的栈

while(c != '=') //对算术表达式扫描未结束时

{

if(c = '0' c = '9')

{

while(c = '0' c = '9')//数字直接入栈

{

houzhui[j]=c;

j++;

i++;

c=str[i];

}

houzhui[j]='#';//用#隔开数字

j++;

}

switch(c) //扫描到运算符时

{

case '+':

case '-':

case '*':

case '/':

if(s.IsEmpty() == true) //栈空,直接入栈

{

s.Push_Stack(c);

i++;

c=str[i];

break;

}

if(ComPare(s.GetTop(),c) == -1)

{

s.Push_Stack(c); //入栈

i++;

c=str[i];

break;

}

if(ComPare(s.GetTop(),c) == 1)

{

houzhui[j]=s.Pop_Stack();//出栈元素存入后缀表达式

j++;

break;

}

}

}

while(s.IsEmpty() != true)//把剩余的运算符直接出栈

{

houzhui[j]=s.Pop_Stack();

j++;

}

houzhui[j] = '=';//后缀表达式后面加 =

j++;

houzhui[j] = '\0';

j++;

return houzhui;

}

float Count(char str[])

{

Stack_Float s = new Stack_Float();//定义存放数字的栈

char c = str[0];

int i = 0,j = 0;

float result = 0,temp,left,right;

while(c != '=') //未扫描到 = 时

{

if(c = '0' c = '9')//扫描到数字

{

temp = 0;

while(c != '#')//未读到分隔符时

{

temp = temp * 10 + c - '0';

i++;

c = str[i];

}

s.Push_Stack(temp);//进栈

}

switch(c)//扫描到运算符时

{

case '+':

{

result = s.Pop_Stack() + s.Pop_Stack();//2个数字出栈相加

s.Push_Stack(result);//最后得数进栈

break;

}

case '-':

{

right = s.Pop_Stack();//右操作数出栈

left = s.Pop_Stack();//左操作数出栈

result = left - right;

s.Push_Stack(result);

break;

}

case '*':

{

result = s.Pop_Stack() * s.Pop_Stack();//2个数字出栈相乘

s.Push_Stack(result);

break;

}

case '/':

{

right = s.Pop_Stack();//右操作数出栈

left = s.Pop_Stack();//左操作数出栈

result = left / right;

s.Push_Stack(result);

break;

}

}

i++;

c = str[i];

}

return result;

}

int ComPare(char a,char b) //判断运算符的优先级函数

{

int s[][] =

{// 栈顶元素高于算术表达式中的元素时, 返回 1,否则返回 -1

{1,1,-1,-1},

{1,1,-1,-1},

{1,1,1,1},

{1,1,1,1},

};

char x1[]={'+','-','*','/'};//栈顶元素

char x2[]={'+','-','*','/'};//算术表达式中的元素

int k=0,m,n = 0;

for(m=0;m4;m++) //查找2个进行比较的运算符在表中的位置,并返回比较结果

{

for(n=0;n4;n++)

{

if(x1[m]==ax2[n]==b)

{

k=1;break; //找到比较结果后,跳出循环

}

}

if(k==1)

break;

}

return s[m][n];//返回比较结果

}

/*****************************************************************************/

@SuppressWarnings("unchecked")

// editor-fold defaultstate="collapsed" desc="Generated Code"//GEN-BEGIN:initComponents

private void initComponents() {

text = new javax.swing.JTextField();

jButton1 = new javax.swing.JButton();

jButton2 = new javax.swing.JButton();

jButton3 = new javax.swing.JButton();

jButton4 = new javax.swing.JButton();

jButton5 = new javax.swing.JButton();

jButton6 = new javax.swing.JButton();

jButton7 = new javax.swing.JButton();

jButton8 = new javax.swing.JButton();

jButton9 = new javax.swing.JButton();

jButton10 = new javax.swing.JButton();

jButton11 = new javax.swing.JButton();

jButton12 = new javax.swing.JButton();

jButton13 = new javax.swing.JButton();

jButton14 = new javax.swing.JButton();

jButton21 = new javax.swing.JButton();

jButton22 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

getContentPane().setLayout(null);

getContentPane().add(text);

text.setBounds(10, 10, 270, 30);

jButton1.setText("1");

jButton1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

}

});

getContentPane().add(jButton1);

jButton1.setBounds(10, 50, 60, 25);

jButton2.setText("2");

jButton2.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

}

});

getContentPane().add(jButton2);

jButton2.setBounds(80, 50, 60, 25);

jButton3.setText("3");

jButton3.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton3ActionPerformed(evt);

}

});

getContentPane().add(jButton3);

jButton3.setBounds(150, 50, 60, 25);

jButton4.setText("4");

jButton4.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton4ActionPerformed(evt);

}

});

getContentPane().add(jButton4);

jButton4.setBounds(220, 50, 60, 25);

jButton5.setText("5");

jButton5.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton5ActionPerformed(evt);

}

});

getContentPane().add(jButton5);

jButton5.setBounds(10, 80, 60, 25);

jButton6.setText("6");

jButton6.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton6ActionPerformed(evt);

}

});

getContentPane().add(jButton6);

jButton6.setBounds(80, 80, 60, 25);

jButton7.setText("7");

jButton7.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton7ActionPerformed(evt);

}

});

getContentPane().add(jButton7);

jButton7.setBounds(150, 80, 60, 25);

jButton8.setText("8");

jButton8.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton8ActionPerformed(evt);

}

});

getContentPane().add(jButton8);

jButton8.setBounds(220, 80, 60, 25);

jButton9.setText("9");

jButton9.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton9ActionPerformed(evt);

}

});

getContentPane().add(jButton9);

jButton9.setBounds(10, 110, 60, 25);

jButton10.setText("0");

jButton10.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton10ActionPerformed(evt);

}

});

getContentPane().add(jButton10);

jButton10.setBounds(80, 110, 60, 25);

jButton11.setText("+");

jButton11.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton11ActionPerformed(evt);

}

});

getContentPane().add(jButton11);

jButton11.setBounds(150, 110, 60, 25);

jButton12.setText("-");

jButton12.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton12ActionPerformed(evt);

}

});

getContentPane().add(jButton12);

jButton12.setBounds(220, 110, 60, 25);

jButton13.setText("*");

jButton13.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton13ActionPerformed(evt);

}

});

getContentPane().add(jButton13);

jButton13.setBounds(10, 140, 60, 25);

jButton14.setText("/");

jButton14.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton14ActionPerformed(evt);

}

});

getContentPane().add(jButton14);

jButton14.setBounds(80, 140, 60, 25);

jButton21.setText("CE");

jButton21.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton21ActionPerformed(evt);

}

});

getContentPane().add(jButton21);

jButton21.setBounds(150, 140, 60, 25);

jButton22.setText("=");

jButton22.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton22ActionPerformed(evt);

}

});

getContentPane().add(jButton22);

jButton22.setBounds(220, 140, 60, 25);

pack();

}// /editor-fold//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

show += "1";

text.setText(show);

}//GEN-LAST:event_jButton1ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

show += "2";

text.setText(show);

}//GEN-LAST:event_jButton2ActionPerformed

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed

show += "3";

text.setText(show);

}//GEN-LAST:event_jButton3ActionPerformed

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed

show += "4";

text.setText(show);

}//GEN-LAST:event_jButton4ActionPerformed

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed

show += "5";

text.setText(show);

}//GEN-LAST:event_jButton5ActionPerformed

private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed

show += "6";

text.setText(show);

}//GEN-LAST:event_jButton6ActionPerformed

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed

show += "7";

text.setText(show);

}//GEN-LAST:event_jButton7ActionPerformed

private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed

show += "8";

text.setText(show);

}//GEN-LAST:event_jButton8ActionPerformed

private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed

show += "9";

text.setText(show);

}//GEN-LAST:event_jButton9ActionPerformed

private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed

show += "0";

text.setText(show);

}//GEN-LAST:event_jButton10ActionPerformed

private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed

show += "*";

text.setText(show);

}//GEN-LAST:event_jButton13ActionPerformed

private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed

show += "/";

text.setText(show);

}//GEN-LAST:event_jButton14ActionPerformed

private void jButton21ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton21ActionPerformed

show = "";

text.setText("");

}//GEN-LAST:event_jButton21ActionPerformed

private void jButton22ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton22ActionPerformed

show += "=";

text.setText(show);

char str1[] = new char[50];

char str2[] = new char[50];

float result = 0;

str1 = show.toCharArray();

str2 = TranSmit(str1);

result = Count(str2);

text.setText("" + result);

show = "";

}//GEN-LAST:event_jButton22ActionPerformed

private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed

show += "-";

text.setText(show);

}//GEN-LAST:event_jButton12ActionPerformed

private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed

show += "+";

text.setText(show);

}//GEN-LAST:event_jButton11ActionPerformed

public static void main(String args[])

{

jisuanqi j = new jisuanqi();

j.setBounds(300, 300, 300, 195);

j.setVisible(true);

}

// Variables declaration - do not modify//GEN-BEGIN:variables

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton10;

private javax.swing.JButton jButton11;

private javax.swing.JButton jButton12;

private javax.swing.JButton jButton13;

private javax.swing.JButton jButton14;

private javax.swing.JButton jButton2;

private javax.swing.JButton jButton21;

private javax.swing.JButton jButton22;

private javax.swing.JButton jButton3;

private javax.swing.JButton jButton4;

private javax.swing.JButton jButton5;

private javax.swing.JButton jButton6;

private javax.swing.JButton jButton7;

private javax.swing.JButton jButton8;

private javax.swing.JButton jButton9;

private javax.swing.JTextField text;

// End of variables declaration//GEN-END:variables

}


名称栏目:java源代码书写 mainclassjava源代码
分享地址:http://cdkjz.cn/article/doscgss.html
多年建站经验

多一份参考,总有益处

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

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

大客户专线   成都:13518219792   座机:028-86922220