京东快速计算的快捷键是什么

京东快速计算的快捷键是什么,第1张

电脑中的计算机快捷键需要自己设定的。

设置电脑计算器的快捷键步骤如下:

1、点击电脑屏幕的最左下角的“开始菜单”,此时磨猜d出总程序菜单

2、点击【所有程序】,此时会d出程序队列

3、在程序队列中,找到【附件】,点击

4、点击附加后,此时会d出分类目程序,我们可以看到【计算器】,这就是我们要用到的计算器程序

5、鼠标对准【附件】,注意了,点击【鼠标右键】(之前是点击左键的),d出【计算器属性对话框】

6、在属性对话框中的【快捷键(K)】一栏中,用鼠标左键点击一下,此时,将您所想要设置的对应的快捷键按氏芹一下这里我们就着左手瞎核型方便,设置了【F1】,然后按【确定】,到此设置完毕。(意思是我每次按【F1】,计算器程序就会d出来。)

7、设置好了,我们来测试一下。按一下【F1】,计算器d出来了。

界面漂亮堪比系统自基枯余带计算器,功能完美加减乘除开平方等等全部具备,还有清零按钮,小数点的使用,连加败派连乘功能完全参考系统官方计算搏滚器经过长期调试改进而成,马上拷贝代码拿去试试看吧,绝不后悔!

代码如下:

import java.awt.*

import java.awt.event.*

import javax.swing.*

import java.util.*

public class Counter {

public static void main(String[] args) {

CounterFrame frame = new CounterFrame()

frame.show()

}

}

class CounterFrame extends JFrame {

public CounterFrame() {

JMenuBar menuBar = new JMenuBar()

JMenu menuFile = new JMenu()

JMenu menuFile1 = new JMenu()

JMenu menuFile2 = new JMenu()

JMenu menuFile3 = new JMenu()

JMenuItem menuFileExit = new JMenuItem()

menuFile.setText("文件")

menuFile1.setText("编辑")

menuFile2.setText("查看")

menuFile3.setText("帮助")

menuFileExit.setText("退出")

menuFileExit.addActionListener

(

new ActionListener() {

public void actionPerformed(ActionEvent e) {

CounterFrame.this.windowClosed()

}

}

)

menuFile.add(menuFileExit)

menuBar.add(menuFile)

menuBar.add(menuFile1)

menuBar.add(menuFile2)

menuBar.add(menuFile3)

setTitle("计算器")

setJMenuBar(menuBar)

setSize(new Dimension(400, 280))

this.getContentPane().add(new Allpanel())

this.addWindowListener

(

new WindowAdapter() {

public void windowClosing(WindowEvent e) {

CounterFrame.this.windowClosed()

}

}

)

}

protected void windowClosed() {

System.exit(0)

}

}

class Tool {

public static Tool instance

private JTextField field

private Tool() {

this.field=new JTextField(30)

this.field.setHorizontalAlignment(JTextField.RIGHT)

}

public static Tool getinstance()

{

if(instance==null)

{

instance=new Tool()

}

return instance

}

public JTextField getfield()

{

return (this.field)

}

}

class Allpanel extends JPanel {

public Allpanel() {

this.setLayout(new BorderLayout(0,7))

Northpanel np=new Northpanel()

Centerpanel cp=new Centerpanel()

this.add(np,BorderLayout.NORTH)

this.add(cp,BorderLayout.CENTER)

}

}

class Centercenter extends JPanel {

static Vector Vec=new Vector()

static Vector vc=new Vector()

static Vector vc1=new Vector()

static Vector vc2=new Vector()

static Vector vc3=new Vector()

static String begin="yes"

static double add

static double jq

static double cs

static double cq

static double dy

static String jg

static String what

static double tool=0

static String to="yes"

/**

* Method Centercenter

*

*

*/

public Centercenter() {

// TODO: Add your code here

final JTextField text=Tool.getinstance().getfield()

this.setLayout(new GridLayout(4,5,3,3))

String arg[] ={"7","8","9","/","sqrt","4","5","6","*","%","1","2","3","-","1/x","0","+/-",".","+","="}

for(int i=0i<20i++)

{

final JButton b=new JButton(arg[i])

//this.add(new JButton(arg[i]))

this.add(b)

if(i==0||i==1||i==2||i==5||i==6||i==7||i==10||i==11||i==12||i==15)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String mark=b.getText()

String ma=text.getText()

if(vc3.contains("v3"))

{

text.setText("0."+mark)

vc3.clear()

}

else if(vc.contains("a"))

{

if(vc2.contains("v2"))

{

text.setText("0."+mark)

vc.clear()

vc2.clear()

}

else

{

text.setText(mark)

vc.clear()

Vec.clear()

Vec.add(mark)

}

}

else

{

text.setText(ma.trim()+mark)

Vec.add(mark)

}

begin="no"

to="yes"

}

})

}

if(i==17)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String mar=b.getText()

String m=text.getText()

if("yes".equals(begin))

{

vc3.add("v3")

}

if(vc1.contains("v1"))

{

vc2.add("v2")

vc1.clear()

}

if(!Vec.contains(".")&&!vc.contains("a"))

{

text.setText(m.trim()+mar)

Vec.add(".")

}

}

})

}

if(i==18)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText()

add=Double.parseDouble(ma)

if(what==null)

{

tool=add

what="add"

}

else

{

tool=tool+add

text.setText(String.valueOf((tool)))

}

vc.add("a")

vc1.add("v1")

to="+"

}

})

}

if(i==13)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText()

jq=Double.parseDouble(ma)

if(what==null)

{

tool=jq

what="jq"

}

else

{

tool=tool-jq

text.setText(String.valueOf((tool)))

}

vc.add("a")

vc1.add("v1")

to="-"

}

})

}

if(i==3)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText()

cq=Double.parseDouble(ma)

if(what==null)

{

tool=cq

what="cq"

}

else

{

tool=tool/cq

text.setText(String.valueOf((tool)))

}

vc.add("a")

vc1.add("v1")

to="/"

}

})

}

if(i==4)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText()

cq=Double.parseDouble(ma)

text.setText(String.valueOf(Math.sqrt(cq)))

}

})

}

if(i==8)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText()

cs=Double.parseDouble(ma)

if(what==null)

{

tool=cs

what="cs"

}

else

{

tool=tool*cs

text.setText(String.valueOf((tool)))

}

vc.add("a")

vc1.add("v1")

to="*"

}

})

}

if(i==19)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText()

dy=Double.parseDouble(ma)

if(what=="add")

{

jg=String.valueOf((tool+dy))

}

if(what=="jq")

{

jg=String.valueOf((tool-dy))

}

if(what=="cs")

{

jg=String.valueOf((tool*dy))

}

if(what=="cq")

{

jg=String.valueOf((tool/dy))

}

if(what==null)

{

if(to=="+")

{

tool=add

jg=String.valueOf(tool+dy)

}

else if(to=="-")

{

tool=jq

jg=String.valueOf(dy-tool)

}

else if(to=="*")

{

tool=cs

jg=String.valueOf(dy*tool)

}

else if(to=="/")

{

tool=cq

jg=String.valueOf(dy/tool)

}

else

{

jg=String.valueOf(dy)

}

}

text.setText(jg)

Vec.clear()

Vec.add(".")

vc.add("a")

vc1.add("v1")

what=null

tool=0

}

})

}

}

}

}

class Centernorth extends JPanel {

public Centernorth() {

final JTextField text=Tool.getinstance().getfield()

JButton jb1=new JButton("Backspace")

JButton jb2=new JButton(" CE ")

JButton jb3=new JButton(" C ")

this.add(jb1)

this.add(jb2)

this.add(jb3)

jb1.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e)

{

String back=Tool.getinstance().getfield().getText()

text.setText(backmethod(back))

Centercenter.Vec.remove(Centercenter.Vec.size()-1)

}

})

jb3.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e)

{

text.setText("0.")

Centercenter.Vec.clear()

Centercenter.Vec.add(".")

Centercenter.vc.add("a")

Centercenter.begin="yes"

Centercenter.vc1.clear()

Centercenter.what=null

Centercenter.tool=0

}

})

}

public String backmethod(String str)

{

return str.substring(0,str.length()-1)

}

}

class Centerpanel extends JPanel {

public Centerpanel() {

this.setLayout(new BorderLayout(8,7))

Centernorth cn=new Centernorth()

Centercenter cc=new Centercenter()

Centerwest cw=new Centerwest()

this.add(cn,BorderLayout.NORTH)

this.add(cc,BorderLayout.CENTER)

this.add(cw,BorderLayout.WEST)

}

}

class Centerwest extends JPanel {

public Centerwest() {

this.setLayout(new GridLayout(4,1,3,3))

this.add(new JButton("MC"))

this.add(new JButton("MR"))

this.add(new JButton("MS"))

this.add(new JButton("M+"))

}

}

class Northpanel extends JPanel {

private JTextField tf

public Northpanel() {

tf=Tool.getinstance().getfield()

this.add(tf)

}

}

---------------------------------------------------------------------------

=============《按你要求特意后改过的最简单功能的代码如下》========================

import java.awt.*

import java.awt.event.*

import javax.swing.*

import java.util.*

public class Counter2 {

public static void main(String[] args) {

CounterFrame frame = new CounterFrame()

frame.show()

}

}

class CounterFrame extends JFrame {

public CounterFrame() {

setTitle("计算器")

setSize(new Dimension(400, 280))

this.getContentPane().add(new Allpanel())

this.addWindowListener

(

new WindowAdapter() {

public void windowClosing(WindowEvent e) {

CounterFrame.this.windowClosed()

}

}

)

}

protected void windowClosed() {

System.exit(0)

}

}

class Tool {

public static Tool instance

private JTextField field

private Tool() {

this.field=new JTextField(30)

this.field.setHorizontalAlignment(JTextField.RIGHT)

}

public static Tool getinstance()

{

if(instance==null)

{

instance=new Tool()

}

return instance

}

public JTextField getfield()

{

return (this.field)

}

}

class Allpanel extends JPanel {

public Allpanel() {

this.setLayout(new BorderLayout(0,7))

Northpanel np=new Northpanel()

Centerpanel cp=new Centerpanel()

this.add(np,BorderLayout.NORTH)

this.add(cp,BorderLayout.CENTER)

}

}

class Centercenter extends JPanel {

static Vector Vec=new Vector()

static Vector vc=new Vector()

static Vector vc1=new Vector()

static Vector vc2=new Vector()

static Vector vc3=new Vector()

static String begin="yes"

static double add

static double jq

static double cs

static double cq

static double dy

static String jg

static String what

static double tool=0

static String to="yes"

/**

* Method Centercenter

*

*

*/

public Centercenter() {

// TODO: Add your code here

final JTextField text=Tool.getinstance().getfield()

this.setLayout(new GridLayout(4,5,3,3))

String arg[] ={"7","8","9","/","4","5","6","*","1","2","3","-","0","=",".","+"}

for(int i=0i<16i++)

{

final JButton b=new JButton(arg[i])

//this.add(new JButton(arg[i]))

this.add(b)

if(i==0||i==1||i==2||i==4||i==5||i==6||i==8||i==9||i==10||i==12)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String mark=b.getText()

String ma=text.getText()

if(vc3.contains("v3"))

{

text.setText("0."+mark)

vc3.clear()

}

else if(vc.contains("a"))

{

if(vc2.contains("v2"))

{

text.setText("0."+mark)

vc.clear()

vc2.clear()

}

else

{

text.setText(mark)

vc.clear()

Vec.clear()

Vec.add(mark)

}

}

else

{

text.setText(ma.trim()+mark)

Vec.add(mark)

}

begin="no"

to="yes"

}

})

}

if(i==14)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String mar=b.getText()

String m=text.getText()

if("yes".equals(begin))

{

vc3.add("v3")

}

if(vc1.contains("v1"))

{

vc2.add("v2")

vc1.clear()

}

if(!Vec.contains(".")&&!vc.contains("a"))

{

text.setText(m.trim()+mar)

Vec.add(".")

}

}

})

}

if(i==15)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText()

add=Double.parseDouble(ma)

if(what==null)

{

tool=add

what="add"

}

else

{

tool=tool+add

text.setText(String.valueOf((tool)))

}

vc.add("a")

vc1.add("v1")

to="+"

}

})

}

if(i==11)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText()

jq=Double.parseDouble(ma)

if(what==null)

{

tool=jq

what="jq"

}

else

{

tool=tool-jq

text.setText(String.valueOf((tool)))

}

vc.add("a")

vc1.add("v1")

to="-"

}

})

}

if(i==3)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText()

cq=Double.parseDouble(ma)

if(what==null)

{

tool=cq

what="cq"

}

else

{

tool=tool/cq

text.setText(String.valueOf((tool)))

}

vc.add("a")

vc1.add("v1")

to="/"

}

})

}

if(i==7)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText()

cs=Double.parseDouble(ma)

if(what==null)

{

tool=cs

what="cs"

}

else

{

tool=tool*cs

text.setText(String.valueOf((tool)))

}

vc.add("a")

vc1.add("v1")

to="*"

}

})

}

if(i==13)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText()

dy=Double.parseDouble(ma)

if(what=="add")

{

jg=String.valueOf((tool+dy))

}

if(what=="jq")

{

jg=String.valueOf((tool-dy))

}

if(what=="cs")

{

jg=String.valueOf((tool*dy))

}

if(what=="cq")

{

jg=String.valueOf((tool/dy))

}

if(what==null)

{

if(to=="+")

{

tool=add

jg=String.valueOf(tool+dy)

}

else if(to=="-")

{

tool=jq

jg=String.valueOf(dy-tool)

}

else if(to=="*")

{

tool=cs

jg=String.valueOf(dy*tool)

}

else if(to=="/")

{

tool=cq

jg=String.valueOf(dy/tool)

}

else

{

jg=String.valueOf(dy)

}

}

text.setText(jg)

Vec.clear()

Vec.add(".")

vc.add("a")

vc1.add("v1")

what=null

tool=0

}

})

}

}

}

}

class Centernorth extends JPanel {

public Centernorth() {

final JTextField text=Tool.getinstance().getfield()

}

}

class Centerpanel extends JPanel {

public Centerpanel() {

this.setLayout(new BorderLayout(8,7))

Centernorth cn=new Centernorth()

Centercenter cc=new Centercenter()

Centerwest cw=new Centerwest()

this.add(cn,BorderLayout.NORTH)

this.add(cc,BorderLayout.CENTER)

this.add(cw,BorderLayout.WEST)

}

}

class Centerwest extends JPanel {

public Centerwest() {

}

}

class Northpanel extends JPanel {

private JTextField tf

public Northpanel() {

tf=Tool.getinstance().getfield()

this.add(tf)

}

}

------------------------------------------------------------

才子_辉祝您愉快!

这是我自己唯肆前几天刚写的,希望对你有用!

import java.awt.Color

import java.awt.FlowLayout

import java.awt.Font

import java.awt.GridLayout

import java.awt.event.ActionEvent

import java.awt.event.ActionListener

import java.awt.event.WindowAdapter

import javax.swing.JButton

import javax.swing.JFrame

import javax.swing.JLabel

import javax.swing.JPanel

import javax.swing.JTextArea

import javax.swing.JTextField

class paiban12{

JFrame frame=new JFrame("计算器")

JPanel jp=new JPanel()

JPanel jp1=new JPanel()

JPanel jp2=new JPanel()

JPanel jp3=new JPanel()

JLabel jl=new JLabel("温馨提示:为了节约您宝贵的时间,请正确输入运算式,如:12+13;")

JLabel jl1=new JLabel("如要计算9的开方数,携谈可先按9键,在按sqrt键即可")

JTextField text=new JTextField(40)

Font fnt=new Font("辩山碰Serief",Font.BOLD,38)

Font fnt1=new Font("Serief",Font.BOLD,28)

Font fnt2=new Font("Serief",Font.BOLD,20)

JButton but=null

String str=""

public paiban12(){

final JButton buta=new JButton(""+0)buta.setFont(fnt)jp.add(buta)

final JButton butb=new JButton(""+1)butb.setFont(fnt)jp.add(butb)

final JButton butc=new JButton(""+2)butc.setFont(fnt)jp.add(butc)

final JButton butd=new JButton(""+3)butd.setFont(fnt)jp.add(butd)

final JButton bute=new JButton(""+4)bute.setFont(fnt)jp.add(bute)

final JButton butf=new JButton(""+5)butf.setFont(fnt)jp.add(butf)

final JButton butg=new JButton(""+6)butg.setFont(fnt)jp.add(butg)

final JButton buth=new JButton(""+7)buth.setFont(fnt)jp.add(buth)

final JButton buti=new JButton(""+8)buti.setFont(fnt)jp.add(buti)

final JButton butj=new JButton(""+9)butj.setFont(fnt)jp.add(butj)

final JButton but=new JButton("+")jp.add(but)but.setFont(fnt)

final JButton but2=new JButton("-")jp.add(but2)but2.setFont(fnt)

final JButton but3=new JButton("×")jp.add(but3)but3.setFont(fnt)

final JButton but4=new JButton("÷")jp.add(but4)but4.setFont(fnt)

final JButton but5=new JButton("=")jp.add(but5)but5.setFont(fnt)

final JButton but6=new JButton("清空")jp.add(but6)but6.setFont(fnt1)jp2.add(but6)

final JButton but7=new JButton("sqrt")jp.add(but7)but7.setFont(fnt1)jp2.add(but7)

final JButton but8=new JButton("n次方")jp.add(but8)but8.setFont(fnt2)jp2.add(but8)

jp.setBounds(10, 100, 350, 400)

jp3.setBounds(0, 30, 450, 70)

jp3.add(jl)

jp3.add(jl1)

jp3.setLayout(new GridLayout(3,5,2,1))

frame.add(jp3)

jp.setLayout(new GridLayout(5,5,3,3))

frame.add(jp)

jp2.setBounds(380, 100, 100, 400)

jp2.setLayout(new GridLayout(3,5,3,1))

frame.add(jp2)

frame.setSize(500, 540)

frame.setBackground(Color.BLACK)

//frame.setLayout(new GridLayout(3,3))

text.setBounds(0, 0, 100, 90)

jp1.setLayout(new FlowLayout())

jp1.add(text)

jp1.setBounds(0, 0, 100, 90)

frame.add(jp1)

frame.setLocation(100, 100)

frame.setVisible(true)

but2.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if(e.getSource()==but2){

str=str+"-"

text.setText(str)

}

}

})

but.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if(e.getSource()==but){

str=str+"+"

text.setText(str)

}

}

})

but3.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if(e.getSource()==but3){

str=str+"×"

text.setText(str)

}

}

})

but4.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if(e.getSource()==but4){

str=str+"÷"

text.setText(str)

}

}

})

but5.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e){

if(e.getSource()==but5){

str=text.getText()int v=0boolean temp

char c[]= str.toCharArray()double i=0,j=0,sum=0

while(true){

if(c[v]=='+'||c[v]=='-'||c[v]=='×'||c[v]=='÷'||c[v]=='0'||c[v]=='^'){

int vb=str.substring(0, v).length()

int nb=str.substring(v+1, str.length()).length()

String str2="\\d{"+vb+"}.\\d{"+nb+"}"

temp=str.matches(str2)

break

}

v++

}

if(temp==true){

i=Float.parseFloat(str.substring(0, v))

j=Float.parseFloat(str.substring(v+1,c.length))

if(c[v]=='+'){

sum=i+j

}

if(c[v]=='-'){

sum=i-j

}

if(c[v]=='×'){

sum=i*j

}

if(c[v]=='÷'){

sum=i/j

}

if(c[v]=='^'){

sum=Math.pow(i, j)

}

text.setText(str+"="+sum)

str=""

}

else{

text.setText("")

str=""

text.setText("温馨提示:请输入正确的计算式!!!")

}

}

}

})

buta.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if(e.getSource()==buta){

str=str+"0"

text.setText(str)

}

}

})

butb.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if(e.getSource()==butb){

str=str+"1"

text.setText(str)

}

}

})

butc.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if(e.getSource()==butc){

str=str+"2"

text.setText(str)

}

}

})

butd.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if(e.getSource()==butd){

str=str+"3"

text.setText(str)

}

}

})

bute.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if(e.getSource()==bute){

str=str+"4"

text.setText(str)

}

}

})

butf.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if(e.getSource()==butf){

str=str+"5"

text.setText(str)

}

}

})

butg.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if(e.getSource()==butg){

str=str+"6"

text.setText(str)

}

}

})

buth.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if(e.getSource()==buth){

str=str+"7"

text.setText(str)

}

}

})

buti.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if(e.getSource()==buti){

str=str+"8"

text.setText(str)

}

}

})

butj.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if(e.getSource()==butj){

str=str+"9"

text.setText(str)

}

}

})

but6.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if(e.getSource()==but6){

str=""

text.setText("")

}

}

})

but7.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if(e.getSource()==but7){

int i=(int) Float.parseFloat(str)

double sum=Math.sqrt(i)

text.setText("sqrt("+i+")="+sum)

str=""

}

}

})

but8.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if(e.getSource()==but8){

int i=(int) Float.parseFloat(str)

str=str+'^'

text.setText(str)

}

}

})

frame.addWindowListener(new WindowAdapter() {})

}

}

class practise14{

public static void main(String args[]){

new paiban12()

}

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12529757.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-26
下一篇 2023-05-26

发表评论

登录后才能评论

评论列表(0条)

保存