記事本java代碼解釋 記事本java代碼解釋大全

java記事本代碼注釋

import java.awt.*;

成都創(chuàng)新互聯(lián)公司擁有一支富有激情的企業(yè)網站制作團隊,在互聯(lián)網網站建設行業(yè)深耕10多年,專業(yè)且經驗豐富。10多年網站優(yōu)化營銷經驗,我們已為上1000家中小企業(yè)提供了成都做網站、成都網站建設解決方案,按需設計,設計滿意,售后服務無憂。所有客戶皆提供一年免費網站維護!

import java.awt.event.*;

import java.io.*;

public class tt

extends Frame

implements ActionListener {

static tt frm = new tt();

//創(chuàng)建一個菜單欄

static MenuBar menubar = new MenuBar();

//創(chuàng)建一個下拉式菜單組件——"文件"

static Menu menu1 = new Menu("文件");

//創(chuàng)建一個下拉式菜單組件——"關于"

static Menu menu2 = new Menu("關于");

//創(chuàng)建一個菜單的所有項——"打開"

static MenuItem item1 = new MenuItem("打開");

//創(chuàng)建一個菜單的所有項——"保存"

static MenuItem item2 = new MenuItem("保存");

//創(chuàng)建一個菜單的所有項——"關于我們"

static MenuItem item3 = new MenuItem("關于我們");

//FileDialog 類顯示一個對話框窗口,用戶可以從中選擇文件。

static FileDialog dia1 = new FileDialog(frm, "打開");

//FileDialog.SAVE此常量值指示文件對話框窗口的作用是查找要寫入的文件。

static FileDialog dia2 = new FileDialog(frm, "保存", FileDialog.SAVE);

//創(chuàng)建一個文本區(qū)

static TextArea txa = new TextArea();

//創(chuàng)建一個窗口事件對象

static WinLis wlis = new WinLis();

public static void main(String agrs[]) {

//創(chuàng)建一個邊框布局

BorderLayout br = new BorderLayout();

//設置Frame的title

frm.setTitle("小記事本");

/*將下拉式菜單menu1、menu2添加到菜單欄中*/

menubar.add(menu1);

menubar.add(menu2);

/*將菜單item1、item2添加到下拉式菜單menu1中,將菜單item3添加到下拉式菜單menu2中*/

menu1.add(item1);

menu1.add(item2);

menu2.add(item3);

/*為item1、item2、item3添加指定的動作偵聽器,以從此菜單項接收動作事件*/

item1.addActionListener(frm);

item2.addActionListener(frm);

item3.addActionListener(frm);

//將文本去txa添加到Frame中

frm.add(txa);

//將此窗體的菜單欄設置為指定的menubar菜單欄。

frm.setMenuBar(menubar);

//調整Frame組件的大小寬800高650

frm.setSize(800, 650);

//顯示組件

frm.setVisible(true);

/*為組件添加窗口事件*/

frm.addWindowListener(wlis);

frm.addWindowListener(wlis);

}

/*窗口事件的實現(xiàn),在關閉窗口的同時關閉運行程序*/

static class WinLis

extends WindowAdapter {

public void windowClosing(WindowEvent e) {

frm.dispose();

}

}

public void actionPerformed(ActionEvent e) {

//獲取當前點擊的菜單對象,getSource()返回最初發(fā)生 Event 的對象。

MenuItem item = (MenuItem) e.getSource();

if (item == item1) {

dia1.setVisible(true);

/*getDirectory()獲取dia1對話框的目錄,getFile()獲取dia1對話框的選定文件*/

String fname = dia1.getDirectory() + dia1.getFile();

try {

//創(chuàng)建一個文件輸入字節(jié)流

FileInputStream fi = new FileInputStream(fname);

/*fi.available()返回下一次對此輸入流調用的方法可以不受阻塞地從此輸入流讀取(或跳過)的估計剩余字節(jié)數(shù)*/

byte ba[] = new byte[fi.available()];

//從此輸入流中將最多ba.length個字節(jié)的數(shù)據(jù)讀入到一個byte數(shù)組中

fi.read(ba);

//將值賦到文本區(qū)中(new String(ba)將字符轉換成字符串).

txa.setText(new String(ba));

//關閉輸入流

fi.close();

}

catch (IOException ioe) {}

;

}

if (item == item2) {

dia2.setVisible(true);

//getDirectory()獲取dia2對話框的目錄

String fname2 = dia2.getDirectory();

//dia2.getFile()獲得dia2對話框中的選定文件,并為其拼接上后綴.txt

File file = new File(dia2.getFile() + ".txt");

//獲得文本區(qū)中的內容

String s = txa.getText();

try {

//創(chuàng)建一個文本寫入字符輸出流,F(xiàn)IleWriter用來寫入字符文件的便捷類

BufferedWriter out = new BufferedWriter(new FileWriter(fname2 + file));

//寫入

out.write(s);

//關閉流

out.close();

}

catch (Exception ioe) {

ioe.printStackTrace();

}

}

}

}

關于選項幫你添上了(事件監(jiān)聽也加上了),具體要實現(xiàn)什么功能,自己看著加吧!

java記事本代碼誰能解釋一下? if(!(frame.getTitle().equals(“記事本”

自己寫的,有問題可以hi:

import java.awt.BorderLayout;

import java.awt.FileDialog;

import java.awt.Font;

import java.awt.datatransfer.Clipboard;

import java.awt.datatransfer.DataFlavor;

import java.awt.datatransfer.StringSelection;

import java.awt.datatransfer.Transferable;

import java.awt.datatransfer.UnsupportedFlavorException;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.BufferedReader;

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.io.FileWriter;

import java.io.IOException;

import javax.swing.JFrame;

import javax.swing.JMenu;

import javax.swing.JMenuBar;

import javax.swing.JMenuItem;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

import javax.swing.JScrollPane;

import javax.swing.JTextArea;

import javax.swing.border.TitledBorder;

/*因為根據(jù)個人的電腦路徑可能有所偏差,沒有源路徑的情況下,設置默認保存路徑為D盤根目錄下

* 若要選擇保存其他地方,可以選擇 另存為*/

public class TestDemo extends JFrame {

private static final long serialVersionUID = -5355432125621015300L;

private String url = null;//文件路徑

private String str=null;//復制或剪切 的字符串

private StringSelection stringSelection=null;

private Clipboard clipboard=new Clipboard(str);

private Transferable transferable=null;

private DataFlavor flavor=null;

public TestDemo() {

init();

}

private void init() {

setTitle("我的記事本");

setSize(500, 600);

setContentPane(createContentPane());//添加主面板

}

/*創(chuàng)建主面板*/

private JPanel createContentPane() {

JPanel pane = new JPanel(new BorderLayout());

pane.add(BorderLayout.NORTH, createChocePane());//添加菜單欄

pane.add(createAreaPane());//添加文本編輯區(qū)域

return pane;

}

/*創(chuàng)建菜單欄,以及實現(xiàn)功能*/

private JPanel createChocePane() {

JPanel pane = new JPanel();

JMenuBar menuBar1 = new JMenuBar();

JMenu menu = new JMenu("文件");

menuBar1.add(menu);

JMenuItem menuIt1 = new JMenuItem("新建");

JMenuItem menuIt2 = new JMenuItem("打開");

JMenuItem menuIt3 = new JMenuItem("保存");

JMenuItem menuIt4 = new JMenuItem("另存為");

menu.add(menuIt1);

menu.add(menuIt2);

menu.add(menuIt3);

menu.add(menuIt4);

JMenuBar menuBar2 = new JMenuBar();

JMenu menu2 = new JMenu("編輯");

menuBar2.add(menu2);

JMenuItem menuIt5 = new JMenuItem("復制");

JMenuItem menuIt6 = new JMenuItem("剪切");

JMenuItem menuIt7 = new JMenuItem("粘帖");

menu2.add(menuIt5);

menu2.add(menuIt6);

menu2.add(menuIt7);

JMenuBar menuBar3 = new JMenuBar();

JMenu menu3 = new JMenu("幫助");

menuBar3.add(menu3);

JMenuItem menuIt8 = new JMenuItem("關于記事本");

menu3.add(menuIt8);

pane.add(menuBar1);

pane.add(menuBar2);

pane.add(menuBar3);

menuIt1.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

testArea.setText(null);

}

});

menuIt2.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

final FileDialog fd = new FileDialog(new JFrame(), "查找文件",

FileDialog.LOAD);

fd.setVisible(true);

if (fd.getDirectory() != null fd.getFile() != null) {

testArea.setText(null);

url = fd.getDirectory() + fd.getFile();

try {

BufferedReader in = new BufferedReader(new FileReader(

url));

for (int i = 0;; i++) {

testArea.append(in.readLine());

if (in.read() == -1) {

break;

} else

continue;

}

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

}

}

});

menuIt3.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if (url==null) {

url="D:\\新建 文本文檔.txt";

}

File f = new File(url);

BufferedWriter out = null;

try {

out = new BufferedWriter(new FileWriter(url));

f.createNewFile();

out.append(testArea.getText());

out.flush();

} catch (IOException e1) {

e1.printStackTrace();

} finally {

try {

out.close();

} catch (IOException e1) {

e1.printStackTrace();

}

}

}

});

menuIt4.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

FileDialog fd = new FileDialog(new JFrame(), "保存文本",

FileDialog.SAVE);

fd.setVisible(true);

if (url!=null) {

File f = new File(url);

BufferedWriter out = null;

try {

f.createNewFile();

out = new BufferedWriter(new FileWriter(url));

out.append(testArea.getText());

out.flush();

} catch (IOException e) {

e.printStackTrace();

} finally {

try {

out.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

}

});

menuIt5.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

str=testArea.getSelectedText();

stringSelection=new StringSelection(str);

clipboard.setContents(stringSelection, null);

}

});

menuIt6.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

str=testArea.getSelectedText();

stringSelection=new StringSelection(str);

clipboard.setContents(stringSelection, null);

int start=testArea.getSelectionStart();

int end=testArea.getSelectionEnd();

testArea.replaceRange( null,start,end);

}

});

menuIt7.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

transferable=clipboard.getContents(this);

flavor=DataFlavor.stringFlavor;

if (transferable.isDataFlavorSupported(flavor)) {

int start=testArea.getSelectionStart();

int end=testArea.getSelectionEnd();

testArea.replaceRange( null,start,end);

int pos=testArea.getCaretPosition();

try {

str=(String)transferable.getTransferData(flavor);

testArea.insert(str, pos);

} catch (UnsupportedFlavorException e1) {

e1.printStackTrace();

} catch (IOException e1) {

e1.printStackTrace();

}

}

}

});

menuIt8.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

JOptionPane.showMessageDialog(null,"功能簡單,絕對原創(chuàng) ");

}

});

return pane;

}

JTextArea testArea;

private JScrollPane createAreaPane() {

JScrollPane pane = new JScrollPane();

pane.setBorder(new TitledBorder("編輯區(qū)域"));

testArea = new JTextArea();

testArea.setFont(new Font("宋體", Font.BOLD, 13));

testArea.setLineWrap(true);

pane.getViewport().add(testArea);

return pane;

}

public static void main(String[] args) {

TestDemo td = new TestDemo();

td.setVisible(true);

}

}

分享

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

}

}

}

分享標題:記事本java代碼解釋 記事本java代碼解釋大全
當前地址:http://muchs.cn/article44/dophhhe.html

成都網站建設公司_創(chuàng)新互聯(lián),為您提供電子商務、網站導航、網站改版、App設計、微信公眾號、全網營銷推廣

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

h5響應式網站建設