JAVA电脑组装代码 java组装一台计算机

求一个用Java编写的简易笔记本代码。跪求

import java.awt.*;

成都创新互联公司坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站建设、成都做网站、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的达孜网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!

import java.awt.event.*;

import java.io.*;

import javax.swing.*;

public class MyNotepad implements ActionListener

{

private JFrame frame=new JFrame("新记事本");

private JTextArea jta=new JTextArea();

private String result="";

private boolean flag=true;

private File f;

private JButton jb=new JButton("开始");

private JTextField jtf=new JTextField(15);

private JTextField jt=new JTextField(15);

private JButton jbt=new JButton("替换为");

private JButton jba=new JButton("全部替换");

private Icon ic=new ImageIcon("D:\\java课堂笔记\\GUI\\11.gif");

private String value;

private int start=0;

private JFrame jf=new JFrame("查找");

private JFrame jfc=new JFrame("替换");

@Override

public void actionPerformed(ActionEvent e) 

{

String comm=e.getActionCommand();

if("新建".equals(comm))

{

if(!(frame.getTitle().equals("新记事本")))

{

if(!flag)

{

write();

newNew();

}

else

{

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

int returnVal = jfc.showDialog(null,"保存为");

if(returnVal == JFileChooser.APPROVE_OPTION) 

{//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

flag=false;

write();

}

}

}

else if(!(jta.getText().isEmpty()))

{

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

int returnVal = jfc.showDialog(null,"保存为");

if(returnVal == JFileChooser.APPROVE_OPTION) 

{//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

flag=false;

write();

newNew();

}

}

else

{

newNew();

}

}

else if("打开".equals(comm))

{

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

jfc.setDialogType(JFileChooser.OPEN_DIALOG);

int returnVal = jfc.showOpenDialog(null);

if(returnVal == JFileChooser.APPROVE_OPTION)

{//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

frame.setTitle(f.getName());

result=read();

flag=false;

value=result;

jta.setText(result);

}

}else if("保存".equals(comm))

{

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

if(flag)

{

int returnVal = jfc.showDialog(null,"保存为");

if(returnVal == JFileChooser.APPROVE_OPTION)

{//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

flag=false;

write();

}

}

else

{

write();

}

}

else if("另存".equals(comm))

{

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

int returnVal = jfc.showDialog(null,"另存");

if(returnVal == JFileChooser.APPROVE_OPTION) 

{//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

write();

}

}

else if("退出".equals(comm))

{

System.exit(0);

}

else if("撤销".equals(comm))

{

jta.setText(value);

}

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

{

value=jta.getText();

jta.cut();

}

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

{

jta.copy();

}

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

{

value=jta.getText();

jta.paste();

}

else if("删除".equals(comm))

{

value=jta.getText();

jta.replaceSelection(null);

}

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

{

jta.selectAll();

}

else if("查找".equals(comm))

{

value=jta.getText();

jf.add(jtf,BorderLayout.CENTER);

jf.add(jb,BorderLayout.SOUTH);

jf.setLocation(300,300);

jf.pack();

jf.setVisible(true);

jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

}

else if("替换".equals(comm))

{

value=jta.getText();

GridLayout gl=new GridLayout(3,3);

JLabel jl1=new JLabel("查找内容:");

JLabel jl2=new JLabel("替换为:");

jfc.setLayout(gl);

jfc.add(jl1);

jfc.add(jtf);

jfc.add(jb);

jfc.add(jl2);

jfc.add(jt);

jfc.add(jbt);

JLabel jl3=new JLabel();

JLabel jl4=new JLabel();

jfc.add(jl3);

jfc.add(jl4);

jfc.add(jba);

jfc.setLocation(300,300);

jfc.pack();

jfc.setVisible(true);

jfc.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

}

else if("版本".equals(comm))

{

JDialog jd=new JDialog(frame,"关于对话框");

jd.setSize(200,200);

JLabel l=new JLabel("哈哈哈哈哈哈哈哈哈哈呵呵呵呵呵呵呵呵呵呵呵呵呵");

jd.add(l,BorderLayout.CENTER);

jd.setLocation(100,200);

jd.setSize(300,300);

jd.setVisible(true);

//  jd.pack();

jd.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

}

else if("开始".equals(comm)||"下一个".equals(comm))

{

String temp=jtf.getText();

int s=value.indexOf(temp,start);

if(value.indexOf(temp,start)!=-1)

{

jta.setSelectionStart(s);

jta.setSelectionEnd(s+temp.length());

jta.setSelectedTextColor(Color.GREEN);

start=s+1;

jb.setText("下一个");

//  value=value.substring(s+temp.length());//不能截取字串

}

else 

{

JOptionPane.showMessageDialog(jf, "查找完毕!", "提示", 0, ic);

jf.dispose();

}

}

else if("替换为".equals(comm))

{

String temp=jtf.getText();

int s=value.indexOf(temp,start);

if(value.indexOf(temp,start)!=-1)

{

jta.setSelectionStart(s);

jta.setSelectionEnd(s+temp.length());

jta.setSelectedTextColor(Color.GREEN);

start=s+1;

jta.replaceSelection(jt.getText());

}

else

{

JOptionPane.showMessageDialog(jf, "查找完毕!", "提示", 0, ic);

jf.dispose();

}

}

else if("全部替换".equals(comm))

{

String temp=jta.getText();

temp=temp.replaceAll(jtf.getText(), jt.getText());

jta.setText(temp);

}

}

public String read()

{

String temp="";

try 

{

FileInputStream fis = new FileInputStream(f.getAbsolutePath());

byte[] b=new byte[1024];

while(true)

{

int num=fis.read(b);

if(num==-1)

break;

temp=temp+new String(b,0,num);

}

fis.close();

}

catch (Exception e1)

{

e1.printStackTrace();

}

return temp;

}

public void write()

{

try

{

FileOutputStream fos=new FileOutputStream(f);

fos.write(jta.getText().getBytes());

fos.close();

}

catch (Exception e)

{

e.printStackTrace();

}

}

public void newNew()

{

frame.dispose();

new MyNotepad();

flag=true;

}

public MyNotepad()

{

JMenuBar jmb=new JMenuBar();

String[] menuLab={"文件","编辑","帮助"};

String[][] menuItemLab={{"新建","打开","保存","另存","退出"},

{"撤销","剪切","复制","粘贴","删除","全选","查找","替换"},

{"版本"}};

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

{

JMenu menu=new JMenu(menuLab[i]);

jmb.add(menu);

for(int j=0;jmenuItemLab[i].length;j++)

{

JMenuItem jmi=new JMenuItem(menuItemLab[i][j]);

menu.add(jmi);

jmi.addActionListener(this);

}

}

frame.setJMenuBar(jmb);

jta.setLineWrap(true);//自动换行

JScrollPane jsp=new JScrollPane(jta);//滚动窗口面板

frame.add(jsp);

jb.addActionListener(this);

jbt.addActionListener(this);

jba.addActionListener(this);

frame.setLocation(200,50);

frame.setSize(620,660);

frame.setVisible(true);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public static void main(String[] args)

{

new MyNotepad();

}

}

求JAVA简易计算机源代码

试试这个

import java.util.*;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import java.applet.*;

public class SZJSQ extends JApplet implements ActionListener

{

boolean i=true;

private JButton num0=new JButton("0");

private JButton num1=new JButton("1");

private JButton num2=new JButton("2");

private JButton num3=new JButton("3");

private JButton num4=new JButton("4");

private JButton num5=new JButton("5");

private JButton num6=new JButton("6");

private JButton num7=new JButton("7");

private JButton num8=new JButton("8");

private JButton num9=new JButton("9");

private JButton zuok=new JButton("(");

private JButton youk=new JButton(")");

private JButton dian=new JButton(".");

private JButton NULL=new JButton("N");

private JButton plu=new JButton("+");

private JButton min=new JButton("-");

private JButton mul=new JButton("x");

private JButton div=new JButton("/");

private JButton equ=new JButton("=");

private JButton cle=new JButton("C");//清除

private JTextField space=new JTextField(30);

public void init()

{

JPanel text=new JPanel();

text.setLayout(new FlowLayout());

text.add(space);

JPanel buttons=new JPanel();

buttons.setLayout(new GridLayout(5,4));

buttons.add(num9);

buttons.add(num8);

buttons.add(num7);

buttons.add(plu);

buttons.add(num6);

buttons.add(num5);

buttons.add(num4);

buttons.add(min);

buttons.add(num3);

buttons.add(num2);

buttons.add(num1);

buttons.add(mul);

buttons.add(num0);

buttons.add(cle);

buttons.add(equ);

buttons.add(div);

buttons.add(zuok);

buttons.add(youk);

buttons.add(dian);

buttons.add(NULL);

(num9).addActionListener(this);

(num8).addActionListener(this);

(num7).addActionListener(this);

(num6).addActionListener(this);

(num5).addActionListener(this);

(num4).addActionListener(this);

(num3).addActionListener(this);

(num2).addActionListener(this);

(num1).addActionListener(this);

(num0).addActionListener(this);

(plu).addActionListener(this);

(min).addActionListener(this);

(mul).addActionListener(this);

(div).addActionListener(this);

(equ).addActionListener(this);

(cle).addActionListener(this);

(zuok).addActionListener(this);

(youk).addActionListener(this);

(dian).addActionListener(this);

setLayout(new BorderLayout());

add("North",text);

add("South",buttons);

space.setText("0");

}

public void actionPerformed(ActionEvent e)

{

if(e.getSource()==num9)

{

if(i==true)

{

space.setText("9");

i=false;

}

else space.setText(space.getText()+'9');

}

if(e.getSource()==num8)

{

if(i==true)

{

space.setText("8");

i=false;

}

else space.setText(space.getText()+'8');

}

if(e.getSource()==num7)

{

if(i==true)

{

space.setText("7");

i=false;

}

else space.setText(space.getText()+'7');

}

if(e.getSource()==num6)

{

if(i==true)

{

space.setText("6");

i=false;

}

else space.setText(space.getText()+'6');

}

if(e.getSource()==num5)

{

if(i==true)

{

space.setText("5");

i=false;

}

else space.setText(space.getText()+'5');

}

if(e.getSource()==num4)

{

if(i==true)

{

space.setText("4");

i=false;

}

else space.setText(space.getText()+'4');

}

if(e.getSource()==num3)

{

if(i==true)

{

space.setText("3");

i=false;

}

else space.setText(space.getText()+'3');

}

if(e.getSource()==num2)

{

if(i==true)

{

space.setText("2");

i=false;

}

else space.setText(space.getText()+'2');

}

if(e.getSource()==num1)

{

if(i==true)

{

space.setText("1");

i=false;

}

else space.setText(space.getText()+'1');

}

if(e.getSource()==num0)

{

if(i==true)

{

space.setText("0");

i=false;

}

else space.setText(space.getText()+'0');

}

if(e.getSource()==zuok)

{

if(i==true)

{

space.setText("(");

i=false;

}

else space.setText(space.getText()+'(');

} if(e.getSource()==youk)

{

if(i==false)

space.setText(space.getText()+')');

}

if(e.getSource()==dian)

{

if(i==false)

space.setText(space.getText()+'.');

}

if(e.getSource()==plu)

{

space.setText(space.getText()+'+');

i=false;

}

if(e.getSource()==min)

{

space.setText(space.getText()+'-');

i=false;

}

if(e.getSource()==mul)

{

space.setText(space.getText()+'*');

i=false;

}

if(e.getSource()==div)

{

space.setText(space.getText()+'/');

i=false;

}

if(e.getSource()==equ)

{

space.setText(String.valueOf(Calculator(space.getText())));

i=true;

}

if(e.getSource()==cle)

{

space.setText("0");

i=true;

}

}

public double Calculator(String f)//科学计算

{

int i=0,j=0,k;

char c;

StringBuffer s=new StringBuffer();

s.append(f);

s.append('=');

String formula=s.toString();

char[] anArray;

anArray=new char[50];

StackCharacter mystack=new StackCharacter();

while(formula.charAt(i)!='=')

{

c=formula.charAt(i);

switch(c)

{

case '(': mystack.push(new Character(c));

i++;

break;

case ')':

while(mystack.peek().charValue()!='(')

{

anArray[j++]=mystack.pop().charValue();

}

mystack.pop();

i++;

break;

case '+':

case '-':

while(!mystack.empty()mystack.peek().charValue()!='(')

{

anArray[j++]=mystack.pop().charValue();

}

mystack.push(new Character(c));

i++;

break;

case '*':

case '/':

while(!mystack.empty()(mystack.peek().charValue()=='*'||mystack.peek().charValue()=='/'))

{

anArray[j++]=mystack.pop().charValue();

}

mystack.push(new Character(c));

i++;

break;

case' ': i++;

break;

default: while((c='0'c='9')||c=='.')

{

anArray[j++]=c;

i++;

c=formula.charAt(i);

}

anArray[j++]='#';

break;

}

}

while(!(mystack.empty()))

anArray[j++]=mystack.pop().charValue();

i=0;

int count;

double a,b,d;

StackDouble mystack1 =new StackDouble();

while(ij)

{

c=anArray[i];

switch(c)

{

case '+':

a=mystack1.pop().doubleValue();

b=mystack1.pop().doubleValue();

d=b+a;

mystack1.push(new Double(d));

i++;

break;

case '-':

a=mystack1.pop().doubleValue();

b=mystack1.pop().doubleValue();

d=b-a;

mystack1.push(new Double(d));

i++;

break;

case '*':

a=mystack1.pop().doubleValue();

b=mystack1.pop().doubleValue();

d=b*a;

mystack1.push(new Double(d));

i++;

break;

case '/':

a=mystack1.pop().doubleValue();

b=mystack1.pop().doubleValue();

if(a!=0)

{

d=b/a;

mystack1.push(new Double(d));

i++;

}

else

{

System.out.println("Error!");

}

break;

default:

d=0;count=0;

while((c='0'c='9'))

{

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

i++;

c=anArray[i];

}

if(c=='.')

{

i++;

c=anArray[i];

while((c='0'c='9'))

{

count++;

d=d+(c-'0')/Math.pow(10,count);

i++;

c=anArray[i];

}

}

if(c=='#')

mystack1.push(new Double(d));

i++;

break;

}

}

return(mystack1.peek().doubleValue());

}

}

如何用java组装成这样格式的

这就是一个jsonObject啊,你搜索下JSONObject,就知道怎么弄。

基本伪代码示例如下:

JSONObject json = new JSONObject()

JSONObject tmp = new JSONObject()

tmp.put("value":,"你好!");

tmp.put("color": "#173177");

json.put("first",tmp); 

system.out.print(json.toString()) ;

/* 输出结果

{

"first": {

"value": "你好!",

"color": "#173177"

}}

*/

按照上面的,多加几个,就是能得到你想要的。

方法二:

String jsonStr="xxxxx" ; //就是你题目中的那长串

JSONObject json = JSonObject.fromString(jsonStr);

win8.1电脑安装java出现错误代码1619

安装JAVA提示错误代码1619的原因很多,以下是常见的原因及解决方法:

1)验证错误

如果出现这种情况,你可以通过验证Java是否可以正常工作来排除这个错误

2)与旧版本冲突

这时需要查看Windows的控制面板,看看里面是否存在Java的控制版块。如果没有,问题往往是JavaFX与旧的Java代码冲突导致的。

解决办法是,在Windows控制面板中删除所有的Java实例,然后清理Windows中遗留的Java代码片段,重新安装即可。

 

3)使用管理员权限安装

可以尝试下使用管理员(administrator)权限进行安装。

4)暂时禁用用户账户控制

用户账户控制功能可能会影响Java的安装。如果你确实怀疑,你可以暂时禁用它。

5)检查用户配置文件

已经被损坏的用户配置文件很可能就是导致Java安装失败的罪魁祸首。这时候你可以创建一个新的用户,并为该用户分配本地的管理权限,然后登陆该账户,再进行Java的安装。

6)使用系统配置工具

Java安装失败,往往与系统正在运行的其他软件有关系,这时候你需要暂时禁止这些软件的运行。最简单的方法是,打开运行,输入MSCONFIG,启动Windows系统配置程序,这里你可以选择要禁用的启动项。

现学习java,需要买一台组装电脑,初学者,目前用到了vm虚拟机,source inside,

我也是学java的,给你说下我的电脑配置: C PU: I3 4170带散热器 819

内存: 金士顿(Kingston)DDR3 1600 4GB 129

S SD: 希捷(Seagate)1TB 7200转64M SATA3 309

主板: 华硕(ASUS) B85M-E 469

显卡:集成HD4400

电源: 爱国者(aigo)额定400W 黑暗骑士550DK 149

机箱 金河田(Golden field)启源 游戏机箱 99

合计 1974

显示器: AOC E2252SWDN 21.5英寸LED背光宽屏液晶显示器 676合计:2650

java安装错误代码1603

可能原因:

可能是因为你的电脑本身是32位的,但是你更新的java是64位的,造成安装失败。

如果安装过程中内存不足,也会出现类似的情况。

java的安装路径中有中文,造成安装失败。

解决方法:

将安装系统换成32位。

清理内存,腾出空间。

换一个安装路径,或者将原本安装路径中的中文删去。


分享标题:JAVA电脑组装代码 java组装一台计算机
网站链接:http://scyanting.com/article/hihjdo.html