⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd.java

📁 简单的GUI程序 建一个小型的计算器, 是一个简单的GUL, 具有以下元素 (1) 数字键 1, 2, 3 (2) 清除显示键C (3) 显示窗口
💻 JAVA
字号:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.JPanel;
import java.awt.*;


public class Lcd extends JPanel implements ActionListener {

	@Override
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub
      String cmd = arg0.getActionCommand();
      if(cmd.equals("clear"))
      {  clear();
      }
      else if(count<MAX)
      {
    	  if(count == 0 )
    		  in = cmd;
    	  else 
    		  in += cmd;
    	  d.setText(h1+in+ht);
    	  count++;
      }
	}   //joptionpane.showMessageDialog(NULL, title);
    protected void clear()
    {
    	count = 0 ; in ="0";
    	d.setText(h1+in+ht);
    }
    Lcd(int size)
    {
    	MAX = size;
    	setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(),BorderFactory.createEmptyBorder(5,10,5,10)));
        d = new JLabel(in , JLabel.RIGHT);
        setLayout(new BorderLayout());
        add( d, BorderLayout.CENTER);
        clear();
    }
    protected String in = "0";
    protected int count= 0;
    protected static int MAX;
    protected JLabel d;
    
    protected String h1 = "<html><p aligh= right>"+ "<fontcolor=blue size=+1><tt><b>";
    protected String ht= "</font></b></tt></p></html>";
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -