xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 0.01M
    文件類型: .java
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-06-16
  • 語言: Java
  • 標(biāo)簽: 其他??

資源簡介

Main.java

資源截圖

代碼片段和文件信息

import?java.awt.*;
import?java.awt.event.*;
import?javax.swing.*;
class?Myframe?extends?Jframe?implements?ActionListener
{
static?JPanel?pan=new?JPanel();//創(chuàng)建一個面板對象pan
static?JTextField?tf=new?JTextField(““);//創(chuàng)建文本框tf
static?JButton[]?b=new?JButton[10];//聲明按鈕數(shù)組b
static?JButton?bpbabsbmbdbeleftrightacback;//聲明按鈕對象
Myframe()
{
setLocation(200200);//設(shè)置窗口生成的相對位置
for(int?i=0;i<=9;i++)
{
b[i]?=new?JButton(““+i);?//創(chuàng)建按鈕對象
b[i].setBackground(Color.pink);//設(shè)置按鈕顏色
}
left=new?JButton(“(“);right=new?JButton(“)“);ac=new?JButton(“清屏“);//創(chuàng)建操作按鈕對象
back=new?JButton(“退格“);bp=new?JButton(“.“);?ba=new?JButton(“+“);
bs=new?JButton(“-“);bm=new?JButton(“*“);bd=new?JButton(“/“);?be=new?JButton(“=“);
//設(shè)置按鈕顏色
be.setBackground(Color.orange);bp.setBackground(Color.yellow);
settitle(“計算器“);//設(shè)置窗口標(biāo)題
setLayout(null);//取消窗口的布局管理器
setSize(450400);//設(shè)置窗口的大小
setResizable(false);//設(shè)置窗口的大小為不可改變
GridLayout?grid=new?GridLayout?(54);//創(chuàng)建5行4列的頁面布局
pan.setLayout(grid);//將面板對象pan的布局策略設(shè)為網(wǎng)格布局方式
tf.setBounds(351524860);//設(shè)置面板pan的相對窗口的相對位置及大小
tf.setEditable(false);//設(shè)置文本框為不可編輯的
pan.setBounds(35100250200);//設(shè)置面板相對窗口的位置和大小
tf.setBackground(Color.CYAN);//設(shè)置文本框的背景色
tf.setHorizontalAlignment(JTextField.RIGHT);//設(shè)置文本框的文字右對齊
Font?font?=?new?Font(“黑體“?Font.PLAIN?20);//創(chuàng)建字體
tf.setFont(font);//設(shè)置文本框字體
pan.add(left);?pan.add(right);?pan.add(ac);?pan.add(back);//添加按鈕到面板
pan.add(b[7]);??pan.add(b[8]);??pan.add(b[9]);??pan.add(bd);
pan.add(b[4]);??pan.add(b[5]);??pan.add(b[6]);??pan.add(bm);
pan.add(b[1]);??pan.add(b[2]);??pan.add(b[3]);??pan.add(bs);
pan.add(b[0]);??pan.add(bp);??pan.add(be);??pan.add(ba);
//設(shè)置按鈕的監(jiān)聽者是本窗口
left.addActionListener(this);?right.addActionListener(this);
ac.addActionListener(this);back.addActionListener(this);
bp.addActionListener(this);ba.addActionListener(this);bm.addActionListener(this);
bd.addActionListener(this);be.addActionListener(this);bs.addActionListener(this);
for(int?i=0;i<10;i++)//為按鈕注冊監(jiān)聽者
b[i].addActionListener(this);
add(tf);//添加文本框到窗口
add(pan);//添加面板到窗口
setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);//處理關(guān)閉窗口事件
setVisible(true);//設(shè)置窗口為可見
}
public?void?actionPerformed(ActionEvent?e)
{
JButton?jb=(JButton)e.getSource();
????if(jb.getText().equals(“清屏“))//如果清屏按鈕被點擊
{
tf.setText(““);
}
else?if(jb.getText().equals(“退格“))//如果退格按鈕被點擊
{
char?[]str=tf.getText().toCharArray();??
????????????if(str.length>0)
????????????tf.setText(new?String(str0str.leng

評論

共有 條評論