真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

java編寫便簽源代碼 網(wǎng)頁便簽源碼

java語言寫一個文本編輯器的源代碼

import java.awt.*;

郊區(qū)ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應用場景,ssl證書未來市場廣闊!成為成都創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書合作)期待與您的合作!

import javax.swing.*;

import java.awt.event.*;

import javax.swing.event.*;

import java.util.*; //Date needed

import java.io.PrintWriter;

public class NotePad extends JFrame

{

JTextArea jta;

class newl implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

jta.setText("");

}

}

class openl implements ActionListener

{ public void actionPerformed(ActionEvent e)

{

JFileChooser jf=new JFileChooser();

jf.showOpenDialog(NotePad.this);

}

}

//保存文件的監(jiān)聽

class savel implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

JFileChooser jf = new JFileChooser();

jf.showSaveDialog(NotePad.this);

}

}

//打印的監(jiān)聽 ?

class printl implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

// PrintWriter p = new PrintWriter(NotePad.this);

}

}

//退出記事本的監(jiān)聽

class exitl implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

System.exit(0);//退出

}

}

//拷貝的監(jiān)聽

class copyl implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

jta.copy();

}

}

//粘貼的監(jiān)聽

class pastel implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

jta.paste();

}

}

//剪切的監(jiān)聽

class cutl implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

jta.cut();

}

}

//查找的監(jiān)聽

//添加日期的監(jiān)聽

class datel implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

Date d=new Date();

jta.append(d.toString());

}

}

//構造函數(shù)

public NotePad()

{

jta=new JTextArea("",24,40);

JScrollPane jsp=new JScrollPane(jta);

JMenuBar jmb=new JMenuBar();

JMenu mFile=new JMenu("File");

JMenu mEdit=new JMenu("Edit");

JMenuItem mNew=new JMenuItem("New",KeyEvent.VK_N);

mNew.addActionListener(new newl());

mFile.add(mNew);

JMenuItem mOpen=new JMenuItem("Open",KeyEvent.VK_O);

mOpen.addActionListener(new openl());

mFile.add(mOpen);

JMenuItem mSave=new JMenuItem("Save");

mSave.addActionListener(new savel());

mFile.add(mSave);

mFile.addSeparator(); //添加分割線

JMenuItem mPrint = new JMenuItem("Print");

mPrint.addActionListener(new printl());

mFile.add(mPrint);

mFile.addSeparator(); //添加分割線

JMenuItem mExit=new JMenuItem("Exit");

mExit.addActionListener(new exitl());

mFile.add(mExit);

mFile.setMnemonic(KeyEvent.VK_F);

//編輯菜單的子菜單的處理

JMenuItem jmi;

jmi=new JMenuItem("Copy");

jmi.addActionListener(new copyl());

mEdit.add(jmi);

jmi=new JMenuItem("Cut");

jmi.addActionListener(new cutl());

mEdit.add(jmi);

jmi=new JMenuItem("Paste");

jmi.addActionListener(new pastel());

mEdit.add(jmi);

mEdit.addSeparator(); //添加分割線

jmi=new JMenuItem("Find");

mEdit.add(jmi);

jmi=new JMenuItem("FindNext");

mEdit.add(jmi);

mEdit.addSeparator();

jmi=new JMenuItem("Select All");

mEdit.add(jmi);

jmi=new JMenuItem("Date/Time");

jmi.addActionListener(new datel());

mEdit.add(jmi);

jmb.add(mFile);

jmb.add(mEdit);

this.setJMenuBar(jmb);

this.getContentPane().add(jsp);

this.setSize(200,200);

this.setVisible(true);

}

//主函數(shù),程序入口點

public static void main(String s[])

{

new NotePad();

}

}

用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);//文字編輯區(qū)域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);//狀態(tài)欄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的實現(xiàn)對象\n"+"歡迎網(wǎng)友下載研究交流\n\n"+"/","關于JNotePad",JOptionPane.DEFAULT_OPTION,JOptionPane.INFORMATION_MESSAGE,null,null,null);}});//編輯區(qū)鍵盤事件textArea.addKeyListener(newKeyAdapter(){publicvoidkeyTyped(KeyEvente){processTextArea();}});//編輯區(qū)鼠標事件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()){//文件是否為保存狀態(tài)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("");//設定狀態(tài)欄stateBar.setText("未修改");//取得系統(tǒng)相依的換行字符StringlineSeparator=System.getProperty("line.separator");//讀取文件并附加至文字編輯區(qū)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()){//執(zhí)行另存為saveFileAs();}else{try{//開啟指定的文件BufferedWriterbuf=newBufferedWriter(newFileWriter(file));//將文字編輯區(qū)的文字寫入文件buf.write(textArea.getText());buf.close();//設定狀態(tài)欄為未修改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();}}

根據(jù)以下的設計要求編寫源代碼。java

class?Student{

private?String?name;

private?int?age;

public?Student(){

this.name?=?"nobody";

this.age?=20;

}

public?void?setName(String?name){

this.name?=?name;

}

public?String?getName(){

return?name;

}

public?void?setAge(int?age){

this.age?=?age;

}

public?int?getAge(){

return?age;

}

public?boolean?isSameAge(Student?s){

return?age?==?s.age;

}????

}

java簡單記事本源代碼 帶解釋

import java.awt.*;

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());

}

}

}


網(wǎng)站欄目:java編寫便簽源代碼 網(wǎng)頁便簽源碼
本文網(wǎng)址:http://weahome.cn/article/hjsjoj.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部