成都网站建设设计

将想法与焦点和您一起共享

个人日记系统代码java 日记本源码

java日记本源代码

晚上,已经快九点钟了,我看了会儿电视,肚子饿得“咕咕”直叫,于是我对妈妈说:“我饿了。”妈妈说:“想吃些什么呢?”我想了想说:“那就吃点面条吧。”

创新互联成立于2013年,先为礼县等服务建站,礼县等地企业,进行企业商务咨询服务。为礼县企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

“自己也十岁了,该做点事情了。”妈妈对我说。

于是我来到厨房自己下面条吃。我先放了半锅水,然后把锅放在煤气灶上烧,蓝色的炉火很快把水烧开了。打开锅盖,一股热所直扑我的脸,锅里的水上下翻滚。

我用勺子小心翼翼地打了点开水倒进碗里,然后抓一把干面放进锅里烧,再用筷子轻轻地翻一翻。趁锅里在煮面条的时候,我往碗里放作料把猪油、葱花、味精、酱油放进碗里 。眨眼工夫,只见锅里边一层白沫慢慢往外溢。我知道面已经熟了,就关掉了煤气灶,把面条装进碗里,再用筷子拌一拌就可以吃了。

了解Java日志系统框架的设计与实现

在Java 领域 存在大量的日志组件 open open收录了 个日志组件 日志系统作为一种应用程序服务 对于跟踪调试 程序状态记录 崩溃数据恢复都有着重要的作用 我们可以把Java日志系统看作是必不可少的跟踪调试工具

简介

日志系统是一种不可或缺的跟踪调试工具 特别是在任何无人职守的后台程序以及那些没有跟踪调试环境的系统中有着广泛的应用 长期以来 日志系统作为一种应用程序服务 对于跟踪调试 程序状态记录 崩溃数据恢复都有非常现实的意义 这种服务通常以两种方式存在

日志系统作为服务进程存在 Windows中的的事件日志服务就属于这种类型 该类型的日志系统通常通过消息队列机制将所需要记录的日志由日志发送端发送给日志服务 日志发送端和日志保存端通常不在同一进程当中 日志的发送是异步过程 这种日志服务通常用于管理员监控各种系统服务的状态

日志系统作为系统调用存在 Java世界中的日志系统和Unix环境下诸多守护进程所使用的日志系统都属于这种类型 日志系统的代码作为系统调用被编译进日志发送端 日志系统的运行和业务代码的运行在同一进程空间 日志的发送多数属于同步过程 这种日志服务由于能够同步反映处系统运行状态 通常用于调试跟踪和崩溃恢复

本文建立的日志系统基本属于第二种类型 但又有所不同 该日志系统将利用Java线程技术实现一个既能够反映统一线程空间中程序运行状态的同步日志发送过程 又能够提供快速的日志记录服务 还能够提供灵活的日志格式配置和过滤机制

系统调试的误区

在控制台环境上调试Java程序时 此时往控制台或者文本文件输出一段文字是查看程序运行状态最简单的做法 但这种方式并不能解决全部的问题 有时候 对于一个我们无法实时查看系统输出的系统或者一个确实需要保留我们输出信息的系统 良好的日志系统显得相当必要 因此 不能随意的输出各种不规范的调试信息 这些随意输出的信息是不可控的 难以清除 可能为后台监控 错误排除和错误恢复带来相当大的阻力

日志系统框架的基本功能

一个完备的日志系统框架通常应当包括如下基本特性

所输出的日志拥有自己的分类 这样在调试时便于针对不同系统的不同模块进行查询 从而快速定位到发生日志事件的代码

日志按照某种标准分成不同级别 分级以后的日志 可以用于同一分类下的日志筛选

支持多线程 日志系统通常会在多线程环境中使用 特别是在Java系统当中 因此作为一种系统资源 日志系统应当保证是线程安全的

支持不同的记录媒介 不同的工程项目往往对日志系统的记录媒介要求不同 因此日志系统必须提供必要的开发接口 以保证能够比较容易的更换记录介质

高性能 日志系统通常要提供高速的日志记录功能以应对大系统下大请求流量下系统的正常运转

稳定性 日志系统必须是保持高度的稳定性 不能因为日志系统内部错误导致主要业务代码的崩溃

常用日志系统简介

在Java世界中 以下三种日志框架比较优秀

)Log J

最早的Java日志框架之一 由Apache基金会发起 提供灵活而强大的日志记录机制 但是其复杂的配置过程和内部概念往往令使用者望而却步

)JDK LoggingFramework

继Log J之后 JDK标准委员会将Log J的基本思想吸收到JDK当中 在JDK 中发布了第一个日志框架接口 并提供了一个简单实现

)CommonsLoggingFramwork

该框架同样是Apache基金会项目 其出现主要是为了使得Java项目能够在Log J和JDK lLoggingFramework的使用上随意进行切换 因此该框架提供了统一的调用接口和配置方法

系统设计

由于Log J得到广泛应用 从使用者的角度考虑 本文所设计的框架 采用了部分Log J的接口和概念 但内部实现则完全不同 使用Java实现日志框架 关键的技术在于前面提及的日志框架特性的内部实现 特别是 日志的分类和级别 日志分发框架的设计 日志记录器的设计以及在设计中的高性能和高稳定性的考虑

系统架构

日志系统框架可以分为日志记录模块和日志输出模块两大部分 日志记录模块负责创建和管理日志记录器(Logger) 每一个Logger对象负责按照不同的级别(LoggerLevel)接收各种记录了日志信息的日志对象(LogItem) Logger对象首先获取所有需要记录的日志 并且同步地将日志分派给日志输出模块 日志输出模块则负责日志输出器(Appender)的创建和管理 以及日志的输出 系统中允许有多个不同的日志输出器 日志输出器负责将日志记录到存储介质当中 系统结构如下图 所示

java如何做系统操作日志?

手头没有代码,用文字书写比较麻烦,说说思路吧:

1):操作日志与每一个人的系统权限密切相关,在前期定义权限的时候,必须区分好每一个用户级别的权限(一级菜单与菜单下具体功能),需要用多张表进行权限标识,并且建立各个表之间的关联关系(具体设置此处略)。

2):当用户点击系统内每一个功能(每一个功能按钮)的时候,一方面实现按钮功能(新建按钮实现新建功能),另外一方面将此处的功能名称、模块名称、用户名、时间等信息一并存储到用户操作表里面。

3):在用户操作查询页面输入相应的条件,在用户操作表内查询即可。

谁帮用java编一个日记本程式

谁帮用java编一个日记本程式

请问楼主有没有学过JAVA,如果没有学过我可以帮我做,如果学过你自己做一遍我帮你检查一下。现在我已经帮你做好了这个JAVA日记本程式,并用讯息发给你了,请查收吧。

求JAVA高手教我程式设计,要求做一个日记本.谢谢.

我有做记事本的程式。QQ群:18600314

一个文具盒和2个日记本54元钱,2个书包和2个日记本80元钱,一个文具盒和一个日记本一共多少钱

一个文具盒和2个日记本54元钱,2个书包和2个日记本80元钱,一个文具盒和一个日记本一共多少钱

提供的条件不够充分

无法解题

王阿姨三天卖了七包日记本一包30个日记本每个日记本五元平均每天卖了多少个日记本

这道题这样算,

30×7÷3=70个,

平均每天卖了70个。

推荐一个日记本软体

资料夹保护2008

可以对资料夹进行加密码、隐藏、伪装的保护。快捷,方便的解决你档案保密问题。

【软体特色】

1 保密性好:资料夹加密码后,开启资料夹要输入正确密码。而且在任何环境下均不失效。资料夹隐藏后,在任何环境下不通过本软体无法找到你隐藏的资料夹。资料夹伪装后,资料夹变成了伪装的物件,开启也看不到资料夹里原有的档案。

2 使用简单方便:在要保护的资料夹上单击右键,在弹出的选单中有[资料夹加密码]、[资料夹隐藏]、[资料夹伪装]这三项保护措施。你选择需要的一种保护即可。

3 快速安全:进行保护的速度特快,无论资料夹大小。软体采用的是成熟、优秀的资料保护技术,安全性高。

4 加密码的资料夹,使用完毕后,依然是一个加密码的资料夹,无须再次加密码。

帮忙找一个手机java日记本

难找啊!

怎样装扮一个日记本?_?

嘻嘻,还 可以在日记本上贴每天做的事情中的一个标志,就是比如今天你剪了头发了就贴一根头发在那页上,去那里旅游了 就把照片或那里带来的笑东西贴上去(当然是 要 很小的东西如花瓣啊树叶啊)。

还可以在每篇日志写完后画画今天遇到的人的样子或今天你的整体表情。漫画般的很可爱哦

4支钢笔5个日记本共用22元,如买5支钢笔4个日记本要用23元,钢笔和日记本各是多少元? 求解题过程

设钢笔x元,日记本y元,列方程如下:

4x+5y=22

5x+4y=23

解二元一次方程,得x=3,y=2

钢笔3元,日记本2元

找个日记本软体

恩 东日笔记本是不错 我也在用

还可以记流水账的

女孩子可以用 秘密花园日记本

用java编写一个“我的日记”的界面并使其实现写日记的功能, 最好含有登陆界面的

代码如下,自己测试哦

import java.awt.event.ActionListener;

import javax.swing.*;

import java.awt.*;

import java.awt.Color;

import java.awt.event.ActionEvent;

import javax.swing.tree.*;

import javax.swing.event.*;

import java.io.*;

import java.util.*;

import javax.swing.JColorChooser;

class Diary extends JFrame implements ActionListener,TreeSelectionListener{

JMenuBar menubar;

JMenu menu1,menu2,menu3,menu4,menu5,menu6;

JMenuItem item1,item2,item3,item4,item5,item6,item7,item8,item52,item61,item62,item63,item64;

JTextArea text=new JTextArea(20,40);

JButton b_save=new JButton("保存日志");

JButton b_del=new JButton("删除日志");

JButton b3=new JButton("锁定日志");

JButton b4=new JButton("解除锁定");

JSplitPane split1,split2;

JScrollPane scroll1,scroll2;

JPanel p;

JTree tree=null;

int i=0;

DefaultMutableTreeNode root;

DefaultMutableTreeNode month[]=new DefaultMutableTreeNode[13];

Diary(){

final JFrame frame = this;

menubar=new JMenuBar();

menu4=new JMenu("登陆");

item6=new JMenuItem("密码登陆");

menu4.add(item6);

menubar.add(menu4);

menu1=new JMenu("文件");

item1=new JMenuItem("新建");

item2=new JMenuItem("退出");

menu1.add(item1);

menu1.add(item2);

menubar.add(menu1);

menu2=new JMenu("编辑");

item3=new JMenuItem("复制");

item4=new JMenuItem("剪切");

item5=new JMenuItem("粘贴");

item52=new JMenuItem("全选");

menu2.add(item3);

menu2.add(item4);

menu2.add(item5);

menu2.add(item52);

menubar.add(menu2);

menu3=new JMenu("设置");

//item6=new JMenuItem("密码设置");

item63=new JMenuItem("设置字体颜色");

item64=new JMenuItem("设置背景颜色");

item61=new JMenuItem("锁定编辑区");

item62=new JMenuItem("解除锁定");

//menu3.add(item6);

menu3.add(item63);

menu3.add(item64);

menu3.add(item61);

menu3.add(item62);

menubar.add(menu3);

menu4=new JMenu("查看");

item7=new JMenuItem("状态栏");

menu4.add(item7);

menubar.add(menu4);

menu5=new JMenu("帮助");

item8=new JMenuItem("我的日记本信息");

menu5.add(item8);

menubar.add(menu5);

setJMenuBar(menubar); //把菜单条添加到窗口顶端

Container con=getContentPane(); //调用getContentPane()方法获的内容面板

root=new DefaultMutableTreeNode("日历记事本"); //结合树的输入与输出建立一个日历记事本

for(i=1;i=12;i++)

{

month[i]=new DefaultMutableTreeNode(""+i+"月");

root.add(month[i]);

}

for(i=1;i=12;i++)

{

if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)

{

for(int j=1;j=31;j++)

month[i].add(new DefaultMutableTreeNode(j+"日"));

}

else if(i==4||i==6||i==9||i==11)

{

for(int j=1;j=30;j++)

month[i].add(new DefaultMutableTreeNode(j+"日"));

}

else

{

for(int j=1;j=28;j++)

month[i].add(new DefaultMutableTreeNode(j+"日"));

}

}

tree=new JTree(root);

p=new JPanel(); //使用JPanel创建一个面板

p.add(b_save);p.add(b_del);p.add(b3);p.add(b4); //把这4个按钮组件假如面板中

scroll1=new JScrollPane(text,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); //把文本框放入滚动窗格中

b_save.addActionListener((ActionListener) this); //按钮的监听器

b_del.addActionListener((ActionListener) this);

scroll2=new JScrollPane(tree);

split1=new JSplitPane(JSplitPane.VERTICAL_SPLIT,true,p,scroll1); //水平拆分这4个按钮和文本区

split2=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,scroll2,split1); //竖直拆分树行日历和文本按钮区

item1.addActionListener((ActionListener) this); //菜单栏的监听器

item2.addActionListener((ActionListener) this);

item3.addActionListener((ActionListener) this);

item4.addActionListener((ActionListener) this);

item5.addActionListener((ActionListener) this);

item6.addActionListener((ActionListener) this);

item7.addActionListener((ActionListener) this);

item8.addActionListener((ActionListener) this);

item52.addActionListener((ActionListener) this);

item61.addActionListener((ActionListener) this);

item62.addActionListener((ActionListener) this);

item63.addActionListener((ActionListener) this);

tree.addTreeSelectionListener((TreeSelectionListener) this); //树形日历的监听器

con.setLayout(new FlowLayout()); //设置布局

setSize(600,500); //设置窗体的大小

Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();

setLocation((screen.width-300)/2,(screen.height-220)/2);

setResizable(false); //设置窗口不可以调节大小

setVisible(true); //设置窗口为可视

con.add(split2); //把树形日历和按钮,文本区都加入到内容面板中

setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //单击关闭图标后关闭窗口

}

public void valueChanged(TreeSelectionEvent e) //处理树形事件的接口

{

text.setText(null);

if(e.getSource()==tree)

{

DefaultMutableTreeNode node=(DefaultMutableTreeNode)tree.getLastSelectedPathComponent();

if(node.isLeaf())

{

String str=node.toString();

for( i=0;i=12;i++)

{

if(node.getParent()==month[i])

{

try{String temp=null;

File f=new File(node.getParent().toString()+str+".text");

FileReader file=new FileReader(f);

BufferedReader in=new BufferedReader(file);

while((temp=in.readLine())!=null)

text.append(temp+'\n');

file.close();

in.close();

}

catch(Exception el){}

}

}

}

}

}

//}

public void actionPerformed(ActionEvent e)

{

if(e.getSource()==b_save) //保存按钮的实现方法

{

DefaultMutableTreeNode node=(DefaultMutableTreeNode)tree.getLastSelectedPathComponent();

String str=node.toString();

if(node.isLeaf())

{

try{

File f=new File(node.getParent().toString()+str+".text");

FileWriter tofile=new FileWriter(f);

BufferedWriter out=new BufferedWriter(tofile);

out.write(text.getText(),0,(text.getText()).length());

out.flush();

tofile.close(); out.close();

}

catch(Exception el){}

}

}

else if(e.getSource()==b_del)

{

int n=JOptionPane.showConfirmDialog(this, "该文件还没有保存,确定要删除吗?","确认对话框", JOptionPane.YES_NO_OPTION);

if(n==JOptionPane.YES_OPTION)

{

DefaultMutableTreeNode node=(DefaultMutableTreeNode)tree.getLastSelectedPathComponent();

String str=node.toString();

if(node.isLeaf())

{

File f=new File(node.getParent().toString()+str+".text");

f.delete();

}

}

else if(n==JOptionPane.NO_OPTION)

{

System.exit(0);

}

}

else if(e.getSource()==b3)

{

text.setEditable(false);

}

else if(e.getSource()==b4)

{

text.setEditable(true);

}

String selected=e.getActionCommand(); //获取命令

if(selected.equals("退出")){ //执行"退出"命令

dispose();

}

else if(selected.equals("新建")){

text.setText("");

}

else if(selected.equals("复制"))

{

text.copy();

}

else if(selected.equals("剪切"))

{

text.cut();

}

else if(selected. equals("粘贴"))

{

text.paste();

}

else if(selected.equals("全选"))

{

text.selectAll();

}

else if(selected.equals("密码登陆"))

{

LoginWindow login=new LoginWindow();

}

else if(selected.equals("设置字体颜色")){

Color newColor=JColorChooser.showDialog(this, "选择字体颜色", text.getForeground());

if(newColor !=null)

{

text.setForeground(newColor);

}

}

else if(selected.equals("设置背景颜色"))

{

Color newColor=JColorChooser.showDialog(this, "选择背景颜色", text.getBackground());

if(newColor !=null)

{

text.setBackground(newColor);

}

}

else if(selected.equals("锁定编辑区"))

{

text.setEditable(false);

}

else if(selected.equals("解除锁定"))

{

text.setEditable(true);

}

}

}

class LoginWindow extends JFrame implements ActionListener {

JPanel p1=new JPanel(); //定义并建立面板

JPanel p2=new JPanel();

JPanel p3=new JPanel();

JPanel p4=new JPanel();

JPanel p5=new JPanel();

JTextField text1=new JTextField(15); //用户名文本框

JPasswordField text2=new JPasswordField(15); //密码域

JButton ok=new JButton("确定");

JButton cancel=new JButton("取消");

LoginWindow()

{

setBackground(Color.DARK_GRAY); //设置背景颜色

Container con=getContentPane(); //取出内容面板

con.setLayout(new GridLayout(5,1)); //设置布局为5行1列

p2.add(new JLabel("用户名:"));p2.add(text1); //将组件添加到中间容器

p3.add(new JLabel("密码"));p3.add(text2);

p4.add(ok);p4.add(cancel);

ok.addActionListener(this); //注册事件监听器

cancel.addActionListener(this);

text1.addActionListener(this);

text2.addActionListener(this);

con.add(p1); con.add(p2); con.add(p3); con.add(p4); con.add(p5); //将面板添加到内容面板

setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //单击关闭图标后关闭窗口

setSize(300,220); //设置窗口的大小

Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();

setLocation((screen.width-300)/2,(screen.height-220)/2);

setTitle("登录窗口");

setResizable(false); // 不让用户改变窗口大小

setVisible(true);

}

public void actionPerformed(ActionEvent e) {

if(e.getSource()==ok||e.getSource()==text2){

if(text1.getText().trim().equals("meijianwen") text2.getText().trim().equals("070341320")){

dispose(); //关闭登陆窗口

}

else{

JOptionPane.showMessageDialog(null, "用户名或密码错误!");

text1.requestFocus(); //设置焦点

text1.setSelectionStart(0); //设置选中文本开始位置

text1.setSelectionEnd(text1.getText().length());

}

}

else if(e.getSource()==cancel){ //单击取消按钮

dispose();

//System.exit(0);

}

else if(e.getSource()==text1) //在用户名文本框按回车焦点移到密码域

text2.requestFocus();

}

}

public class MyDiary

{

public static void main(String args[])

{

JFrame.setDefaultLookAndFeelDecorated(true);

Font font=new Font("JFrame",Font.PLAIN,14); //定义字体

Enumeration keys=UIManager.getLookAndFeelDefaults().keys(); //枚举风格关键字

while(keys.hasMoreElements())

{

Object key=keys.nextElement();

// if(((String)key).equals("Menu.foreground")||((String)key).equals("MenuItem.foreground"))

// UIManager.put(key,Color.DARK_GRAY); //设置菜单文字颜色

if(UIManager.get(key)instanceof Font)UIManager.put(key,font);

}

Diary win=new Diary();

win.validate();

}

}

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 日记本源码
URL地址:http://chengdu.cdxwcx.cn/article/hgdsdg.html